Use osFilter for motions, assignments and mediafiles. (Fixes #1784)

This commit is contained in:
Emanuel Schuetze 2016-01-21 23:20:14 +01:00
parent b4482afa38
commit 7bc1851a09
5 changed files with 33 additions and 5 deletions

View File

@ -38,7 +38,10 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
},
phases: function(Assignment) {
return Assignment.getPhases();
}
},
users: function(User) {
return User.findAll();
},
}
})
.state('assignments.assignment.detail', {
@ -159,12 +162,22 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
$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;
};
// define custom search filter string
$scope.getFilterString = function (assignment) {
return [
assignment.title,
assignment.description,
$scope.phases[assignment.phase].display_name,
_.map(assignment.assignment_related_users,
function (candidate) {return candidate.user.get_short_name()}).join(" "),
].join(" ");
}
// open new/edit dialog
$scope.openDialog = function (assignment) {

View File

@ -99,7 +99,7 @@
ng-class="reverse ? 'fa-sort-desc' : 'fa-sort-asc'">
</i>
<tbody>
<tr ng-repeat="assignment in assignmentsFiltered = (assignments | filter: filter.search |
<tr ng-repeat="assignment in assignmentsFiltered = (assignments | osFilter: filter.search : getFilterString |
filter: {phase: phaseFilter} | orderBy: sortColumn:reverse)"
class="animate-item"
ng-class="{ 'activeline': assignment.isProjected(), 'selected': assignment.selected }">

View File

@ -79,6 +79,15 @@ angular.module('OpenSlidesApp.mediafiles.site', ['ngFileUpload', 'OpenSlidesApp.
}
$scope.sortColumn = column;
};
// define custom search filter string
$scope.getFilterString = function (mediafile) {
return [
mediafile.title,
mediafile.mediafile.type,
mediafile.mediafile.name,
mediafile.uploader.get_short_name()
].join(" ");
}
// delete
$scope.delete = function (mediafile) {

View File

@ -51,7 +51,7 @@
</th>
</tr>
<tbody>
<tr ng-repeat="mediafile in mediafiles | filter: filter.search |
<tr ng-repeat="mediafile in mediafiles | osFilter: filter.search : getFilterString |
orderBy: sortColumn:reverse">
<td><a ng-href="{{ mediafile.mediafileUrl }}" target="_blank">{{ mediafile.title_or_filename }}</a>
<td class="optional">{{ mediafile.mediafile.type }}

View File

@ -399,6 +399,7 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
}
$scope.sortColumn = column;
};
// define custom search filter string
$scope.getFilterString = function (motion) {
if (motion.category) {
var category = motion.category.name;
@ -406,10 +407,15 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
var category = ''
}
return [
motion.identifier,
motion.getTitle(),
motion.getText(),
motion.getReason(),
_.map(motion.submitters, function (submitter) {return submitter.get_short_name()}).join(" "),
category].join(" ");
_.map(motion.supporters, function (supporter) {return supporter.get_short_name()}).join(" "),
_.map(motion.tags, function (tag) {return tag.name}).join(" "),
category
].join(" ");
}
// collect all states of all workflows