Add osFilter that filters for an explicit text

This commit is contained in:
Oskar Hahn 2016-01-09 16:45:47 +01:00
parent 890383006b
commit e3b6fd8d6d
3 changed files with 28 additions and 2 deletions

View File

@ -267,6 +267,20 @@ angular.module('OpenSlidesApp.core', [
}
])
.filter('osFilter', [
'$filter',
function ($filter) {
return function (array, string, getFilterString) {
if (!string) {
return array;
}
return Array.prototype.filter.call(array, function (item) {
return getFilterString(item).toLowerCase().indexOf(string.toLowerCase()) > -1;
});
}
}
])
/* Options for CKEditor used in various create and edit views. */
.value('CKEditorOptions', {
allowedContent:

View File

@ -284,12 +284,24 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
$scope.filterPresent = '';
$scope.reverse = false;
// function to sort by clicked column
$scope.toggleSort = function ( column ) {
$scope.toggleSort = function (column) {
if ( $scope.sortColumn === column ) {
$scope.reverse = !$scope.reverse;
}
$scope.sortColumn = column;
};
$scope.getFilterString = function (motion) {
if (motion.category) {
var category = motion.category.name;
} else {
var category = ''
}
return [
motion.getTitle(),
motion.getText(),
_.map(motion.submitters, function (submitter) {return submitter.get_short_name()}).join(" "),
category].join(" ");
}
// collect all states of all workflows
// TODO: regard workflows only which are used by motions

View File

@ -112,7 +112,7 @@
ng-class="reverse ? 'fa-sort-desc' : 'fa-sort-asc'">
</i>
<tbody>
<tr ng-repeat="motion in motions | filter: filter.search | filter: {state_id: stateFilter} |
<tr ng-repeat="motion in motions | osFilter: filter.search : getFilterString | filter: {state_id: stateFilter} |
orderBy: sortColumn:reverse"
class="animate-item"
ng-class="{ 'activeline': motion.isProjected(), 'selected': motion.selected }">