Merge pull request #1803 from ostcar/os_filter

Add osFilter that filters for an explicit text
This commit is contained in:
Norman Jäckel 2016-01-09 17:07:31 +01:00
commit 193d318bc9
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 }">