Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function(){
'use strict';

function mdtSelectAllRowsHandlerDirective(){
function mdtSelectAllRowsHandlerDirective($timeout){
return {
restrict: 'A',
scope: false,
Expand All @@ -10,6 +10,20 @@
$scope.selectAllRows = false;

$scope.$watch('selectAllRows', function(val){
if($scope.initTable){
$timeout(function(){
$scope.initTable = false;
}, attrs.hideDelay);
}else{
_.each(ctrl.dataStorage.storage, function(data){
if(data.optionList.selected === false){
val = true;
$('th md-checkbox').addClass('md-checked');
return false;
}
});
}

ctrl.dataStorage.setAllRowsSelected(val, $scope.isPaginationEnabled());
});
}
Expand Down
4 changes: 4 additions & 0 deletions app/modules/main/directives/mdtTableDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@
controller: function mdtTable($scope){
var vm = this;

//set init scope to true for those that
//are using locationchanges
$scope.initTable = true;

$scope.rippleEffectCallback = function(){
return $scope.rippleEffect ? $scope.rippleEffect : false;
};
Expand Down
7 changes: 5 additions & 2 deletions app/modules/main/features/SelectableRowsFeature.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
(function(){
'use strict';

function SelectableRowsFeatureFactory($timeout){
function SelectableRowsFeatureFactory($timeout, CheckBoxMgmtProvider){

function SelectableRowsFeature(params){
this.$scope = params.$scope;
this.ctrl = params.ctrl;
SelectableRowsFeature.$inject = ["CheckBoxMgmtProvider"];

this.$scope.onCheckboxChange = _.bind(this.onCheckboxChange, this);
}

SelectableRowsFeature.prototype.onCheckboxChange = function(){
var that = this;

CheckBoxMgmtProvider.getCheckOption(that.ctrl.dataStorage);
// we need to push it to the event loop to make it happen last
// (e.g.: all the elements can be selected before we call the callback)
$timeout(function(){
Expand All @@ -31,4 +34,4 @@
angular
.module('mdDataTable')
.service('SelectableRowsFeature', SelectableRowsFeatureFactory);
}());
}());
35 changes: 35 additions & 0 deletions app/modules/main/providers/CheckBoxMgmtProvider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
(function(){
'use strict';

/**
* @name CheckBoxMgmtProvider
* @used as CheckBox management service
*/
function CheckBoxMgmtProvider(){
var service = this;

service.getCheckOption = getCheckOption;
function getCheckOption(storageData){
var foundFalse = false;
_.each(storageData, function(data){
if(foundFalse){
return false;
}
_.each(data, function(subData){
if(subData.optionList.selected === false){
// find a way not to use css directly here
$('th md-checkbox').removeClass('md-checked');
foundFalse = true;
return false;
}else{
$('th md-checkbox').addClass('md-checked');
}
})
});
}
}

angular
.module('mdDataTable')
.service('CheckBoxMgmtProvider', CheckBoxMgmtProvider);
})();