Wire up available filter values service in query filter directive

pull/1065/head
Till Breuer 11 years ago
parent 8e7ffdb872
commit 80afb2b0f9
  1. 22
      app/assets/javascripts/angular/directives/work_packages/query-filter-directive.js
  2. 2
      public/templates/work_packages/query_filters.html

@ -1,26 +1,24 @@
angular.module('openproject.workPackages.directives')
.directive('queryFilter', ['WorkPackagesTableHelper', 'WorkPackageService', 'FunctionDecorators', 'StatusService', function(WorkPackagesTableHelper, WorkPackageService, FunctionDecorators, StatusService) {
.directive('queryFilter', ['WorkPackagesTableHelper', 'WorkPackageService', 'FunctionDecorators', 'QueryService', 'StatusService', function(WorkPackagesTableHelper, WorkPackageService, FunctionDecorators, QueryService, StatusService) {
return {
restrict: 'A',
link: function(scope, element, attributes) {
function populateValues(data){
scope.availableValues = data.statuses.map(function(v){
return [v.id, v.name.toString()];
});
}
scope.showValueOptionsAsSelect = ['list', 'list_optional', 'list_status', 'list_subprojects', 'list_model'].indexOf(scope.query.getFilterType(scope.filter.name)) !== -1;
if(scope.query.getFilterType(scope.filter.name) == 'list_model'){
// Get possible values
// TODO: Choose users, statuses, priorities etc based on filter something
StatusService.getStatuses().then(populateValues);
} else {
scope.availableValues = scope.query.getAvailableFilterValues(scope.filter.name);
if (scope.showValueOptionsAsSelect) {
QueryService.getAvailableFilterValues(scope.filter.name)
.then(function(values) {
scope.availableFilterValues = values.map(function(value) {
return [value.name, value.id];
});
});
}
// Filter updates
scope.$watch('filter.operator', function(operator) {
if(operator) scope.showValuesInput = scope.filter.requiresValues();
});

@ -130,7 +130,7 @@
<div ng-if="showValueOptionsAsSelect"
ng-show="showValuesInput">
<toggled-multiselect available-filter-values="query.getAvailableFilterValues(filter.name)"
<toggled-multiselect available-filter-values="availableFilterValues"
name="filter.name"
values="filter.values"
is-multiselect="false"

Loading…
Cancel
Save