Skip to content
Open
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
41 changes: 40 additions & 1 deletion ui/src/main/resources/FileManagerCode/LiveTable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@
</th>
</tr>
<tr class="xwiki-livetable-display-filters">
<td ng-if="selection" class="xwiki-livetable-display-header-filter"></td>
<td class="xwiki-livetable-display-header-filter">
<input type="checkbox" ng-model="checkedAll" ng-indeterminate="indeterminate" />
</td>
<td ng-repeat="column in columns" class="xwiki-livetable-display-header-filter">
<div ng-if="column.filterable" ng-include="liveTableFilterTemplate"></div>
</td>
Expand Down Expand Up @@ -280,6 +282,32 @@
}
};

scope.$watch('checkedAll', function(newValue, oldValue) {
angular.forEach(scope.rows.list, function(rowItem) {
scope.selection[rowItem.id] = newValue;
});
}, true);

// synchronize the master checkbox and the rest of the checkboxes.
scope.$watch('[rows.list,selection]', function() {
var checkedCount = 0;
angular.forEach(scope.rows.list, function(rowItem) {
if(scope.selection[rowItem.id] == true){
checkedCount++;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not good. You assume the selected files are from the current page. As I said above, the user needs to be able to select files from different pages.

}
});
if(checkedCount == 0){
scope.indeterminate = false;
scope.checkedAll = false;
}else if(checkedCount == scope.rows.list.length){
scope.indeterminate = false;
scope.checkedAll = true;
}else {
scope.indeterminate = true;
}
}, true);


// The live table filters should not trigger an update immediately, but after a delay. We achieve this by
// deferring the update when the filters are changed and by cancelling the pending update whenever a new change
// is detected.
Expand Down Expand Up @@ -320,6 +348,17 @@
}
}
});

liveTable.directive('ngIndeterminate', function() {
return {
restrict: 'A',
link: function(scope, element, attributes) {
scope.$watch(attributes['ngIndeterminate'], function (value) {
element.prop('indeterminate', !!value);
});
}
};
});
});</code>
</property>
<property>
Expand Down