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) { phases: function(Assignment) {
return Assignment.getPhases(); return Assignment.getPhases();
} },
users: function(User) {
return User.findAll();
},
} }
}) })
.state('assignments.assignment.detail', { .state('assignments.assignment.detail', {
@ -159,12 +162,22 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
$scope.filterPresent = ''; $scope.filterPresent = '';
$scope.reverse = false; $scope.reverse = false;
// function to sort by clicked column // function to sort by clicked column
$scope.toggleSort = function ( column ) { $scope.toggleSort = function (column) {
if ( $scope.sortColumn === column ) { if ( $scope.sortColumn === column ) {
$scope.reverse = !$scope.reverse; $scope.reverse = !$scope.reverse;
} }
$scope.sortColumn = column; $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 // open new/edit dialog
$scope.openDialog = function (assignment) { $scope.openDialog = function (assignment) {

View File

@ -99,7 +99,7 @@
ng-class="reverse ? 'fa-sort-desc' : 'fa-sort-asc'"> ng-class="reverse ? 'fa-sort-desc' : 'fa-sort-asc'">
</i> </i>
<tbody> <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)" filter: {phase: phaseFilter} | orderBy: sortColumn:reverse)"
class="animate-item" class="animate-item"
ng-class="{ 'activeline': assignment.isProjected(), 'selected': assignment.selected }"> ng-class="{ 'activeline': assignment.isProjected(), 'selected': assignment.selected }">

View File

@ -79,6 +79,15 @@ angular.module('OpenSlidesApp.mediafiles.site', ['ngFileUpload', 'OpenSlidesApp.
} }
$scope.sortColumn = column; $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 // delete
$scope.delete = function (mediafile) { $scope.delete = function (mediafile) {

View File

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

View File

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