From e3b6fd8d6d4fd6c012e29a1184a516c1d10c75a1 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Sat, 9 Jan 2016 16:45:47 +0100 Subject: [PATCH] Add osFilter that filters for an explicit text --- openslides/core/static/js/core/base.js | 14 ++++++++++++++ openslides/motions/static/js/motions/site.js | 14 +++++++++++++- .../static/templates/motions/motion-list.html | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/openslides/core/static/js/core/base.js b/openslides/core/static/js/core/base.js index 169a1aa66..e812b601e 100644 --- a/openslides/core/static/js/core/base.js +++ b/openslides/core/static/js/core/base.js @@ -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: diff --git a/openslides/motions/static/js/motions/site.js b/openslides/motions/static/js/motions/site.js index 08e14f313..38436a5e2 100644 --- a/openslides/motions/static/js/motions/site.js +++ b/openslides/motions/static/js/motions/site.js @@ -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 diff --git a/openslides/motions/static/templates/motions/motion-list.html b/openslides/motions/static/templates/motions/motion-list.html index bad9a75fa..8ce25726b 100644 --- a/openslides/motions/static/templates/motions/motion-list.html +++ b/openslides/motions/static/templates/motions/motion-list.html @@ -112,7 +112,7 @@ ng-class="reverse ? 'fa-sort-desc' : 'fa-sort-asc'"> -