From aa71acef19ee02c33d0202e96d8d38d57ad9b313 Mon Sep 17 00:00:00 2001 From: Vincent Fournier Date: Tue, 18 Aug 2015 15:59:44 -0400 Subject: [PATCH] Fix checkbox bug Change-Id: Icf6194c78bf3d124c83afb3e455d9b023775d084 --- app/components/datasource/datasource.js | 10 ++++++++++ app/components/directive/table/table.html | 4 ++-- app/components/directive/table/table.js | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/components/datasource/datasource.js b/app/components/datasource/datasource.js index 2acbb2b..fa6f20d 100644 --- a/app/components/datasource/datasource.js +++ b/app/components/datasource/datasource.js @@ -83,6 +83,16 @@ angular.module('bansho.datasource', ['bansho.surveil']) listeners[datasourceId].push(callback); }, + isAllCheckedTable: function (datasourceId) { + var isAllChecked = true; + angular.forEach(filteredData[datasourceId], function (entry) { + if (!entry.is_checked) { + isAllChecked = false; + } + }); + + return isAllChecked; + }, setAllCheckTable: function (datasourceId, isChecked) { config[datasourceId].isCheckAll = isChecked; angular.forEach(filteredData[datasourceId], function (entry) { diff --git a/app/components/directive/table/table.html b/app/components/directive/table/table.html index cf1f3e4..ae7662b 100644 --- a/app/components/directive/table/table.html +++ b/app/components/directive/table/table.html @@ -3,7 +3,7 @@ - + {{column.title}} @@ -13,7 +13,7 @@ - + diff --git a/app/components/directive/table/table.js b/app/components/directive/table/table.js index b5bbf1e..ad2cb4e 100644 --- a/app/components/directive/table/table.js +++ b/app/components/directive/table/table.js @@ -65,9 +65,14 @@ angular.module('bansho.table', ['bansho.datasource', } }; - $scope.onCheckChange = function () { + $scope.onClick = function () { + $scope.isCheckAll = !$scope.isCheckAll; datasource.setAllCheckTable($scope.datasourceId, $scope.isCheckAll); }; + + $scope.entryOnClick = function () { + $scope.isCheckAll = datasource.isAllCheckedTable($scope.datasourceId); + }; }] }; })