Use fat arrow function instead of self var in _objects.js. Add 'areAllRowsChecked' controller method.

This commit is contained in:
CJ Cenizal 2016-12-20 09:04:07 -08:00
parent 0f32b83747
commit fd29dbb445
2 changed files with 11 additions and 6 deletions

View file

@ -116,7 +116,7 @@
<input
type="checkbox"
class="kuiCheckBox"
ng-checked="currentTab.data.length > 0 && selectedItems.length == currentTab.data.length"
ng-checked="managementObjectsController.areAllRowsChecked()"
ng-click="toggleAll()"
>
</th>

View file

@ -20,13 +20,19 @@ uiModules.get('apps/management')
restrict: 'E',
controllerAs: 'managementObjectsController',
controller: function ($scope, $injector, $q, AppState, es) {
const self = this;
const notify = new Notifier({ location: 'Saved Objects' });
const $state = $scope.state = new AppState();
$scope.currentTab = null;
$scope.selectedItems = [];
this.areAllRowsChecked = function areAllRowsChecked() {
if ($scope.currentTab.data.length === 0) {
return false;
}
return $scope.selectedItems.length === $scope.currentTab.data.length;
};
const getData = function (filter) {
const services = registry.all().map(function (obj) {
const service = $injector.get(obj.service);
@ -53,6 +59,9 @@ uiModules.get('apps/management')
});
};
const refreshData = () => {
return getData(this.advancedFilter);
};
$scope.toggleAll = function () {
if ($scope.selectedItems.length === $scope.currentTab.data.length) {
@ -154,10 +163,6 @@ uiModules.get('apps/management')
});
}
function refreshData() {
return getData(self.advancedFilter);
}
$scope.changeTab = function (tab) {
$scope.currentTab = tab;
$scope.selectedItems.length = 0;