Adding 'done' option in motion state filter

This commit is contained in:
FinnStutzenstein 2016-12-09 13:10:09 +01:00
parent c2edf134e2
commit efaa00483c
2 changed files with 44 additions and 4 deletions

View File

@ -825,6 +825,24 @@ angular.module('OpenSlidesApp.motions.site', [
});
});
$scope.stateFilter = [];
var updateStateFilter = function () {
if (_.indexOf($scope.filter.multiselectFilters.state, -1) > -1) { // contains -1
$scope.stateFilter = _.filter($scope.filter.multiselectFilters.state, function (id) {
return id >= 0;
}); // remove -1
_.forEach($scope.states, function (state) {
if (!state.workflowHeader) {
if (state.getNextStates().length === 0) { // done state
$scope.stateFilter.push(state.id);
}
}
});
} else {
$scope.stateFilter = _.clone($scope.filter.multiselectFilters.state);
}
};
// Filtering
$scope.filter = osTableFilter.createInstance('MotionTableFilter');
@ -837,6 +855,7 @@ angular.module('OpenSlidesApp.motions.site', [
recommendation: [],
};
}
updateStateFilter();
$scope.filter.propertyList = ['identifier', 'origin'];
$scope.filter.propertyFunctionList = [
function (motion) {return motion.getTitle();},
@ -864,6 +883,14 @@ angular.module('OpenSlidesApp.motions.site', [
tag: function (motion) {return motion.tags_id;},
recommendation: function (motion) {return motion.recommendation_id;},
};
$scope.operateStateFilter = function (id, danger) {
$scope.filter.operateMultiselectFilter('state', id, danger);
updateStateFilter();
};
$scope.resetFilters = function () {
$scope.filter.reset();
updateStateFilter();
};
// Sorting
$scope.sort = osTableSort.createInstance();
$scope.sort.column = 'identifier';

View File

@ -104,7 +104,7 @@
<div class="col-xs-11 main-header">
<span class="form-inline text-right pull-right">
<!-- clear all filters -->
<span class="sort-spacer pointer" ng-click="filter.reset()"
<span class="sort-spacer pointer" ng-click="resetFilters()"
ng-if="filter.areFiltersSet()" ng-disabled="isSelectMode"
ng-class="{'disabled': isSelectMode}">
<i class="fa fa-times-circle"></i>
@ -124,11 +124,18 @@
{{ state.headername | translate }}
</a>
<a href ng-if="!state.workflowHeader"
ng-click="filter.operateMultiselectFilter('state', state.id, isSelectMode)">
ng-click="operateStateFilter(state.id, isSelectMode)">
<i class="fa fa-check" ng-if="filter.multiselectFilters.state.indexOf(state.id) > -1"></i>
{{ state.name | translate }}
</a>
</li>
<li class="divider"></li>
<li>
<a href ng-click="operateStateFilter(-1, isSelectMode)">
<i class="fa fa-check" ng-if="filter.multiselectFilters.category.indexOf(-1) > -1"></i>
<translate>Done</translate>
</a>
</li>
</ul>
</span>
<!-- Category filter -->
@ -279,13 +286,19 @@
<!-- state -->
<span ng-repeat="state in states" class="pointer spacer-left-lg"
ng-if="!state.workflowHeader && filter.multiselectFilters.state.indexOf(state.id) > -1"
ng-click="filter.operateMultiselectFilter('state', state.id, isSelectMode)"
ng-click="operateStateFilter(state.id, isSelectMode)"
ng-class="{'disabled': isSelectMode}">
<span class="nobr">
<i class="fa fa-times-circle"></i>
{{ state.name | translate }}
</span>
</span>
<span ng-if="filter.multiselectFilters.state.indexOf(-1) > -1" class="pointer spacer-left-lg"
ng-click="operateStateFilter(-1, isSelectMode)"
ng-class="{'disabled': isSelectMode}">
<i class="fa fa-times-circle"></i>
<translate>Done</translate>
</span>
<!-- category -->
<span ng-repeat="category in categories" class="pointer spacer-left-lg"
ng-if="filter.multiselectFilters.category.indexOf(category.id) > -1"
@ -354,7 +367,7 @@
ng-class="{'projected': motion.isProjected().length}"
ng-repeat="motion in motionsFiltered = (motions
| osFilter: filter.filterString : filter.getObjectQueryString
| MultiselectFilter: filter.multiselectFilters.state : getItemId.state
| MultiselectFilter: stateFilter : getItemId.state
| MultiselectFilter: filter.multiselectFilters.category : getItemId.category
| MultiselectFilter: filter.multiselectFilters.motionBlock : getItemId.motionBlock
| MultiselectFilter: filter.multiselectFilters.recommendation : getItemId.recommendation