added a status service.

pull/1065/head
Richard 11 years ago committed by Till Breuer
parent 5973176d9e
commit aeade066c8
  1. 2
      app/assets/javascripts/angular/controllers/work-packages-controller.js
  2. 14
      app/assets/javascripts/angular/directives/work_packages/query-filter-directive.js
  3. 3
      app/assets/javascripts/angular/helpers/components/path-helper.js
  4. 25
      app/assets/javascripts/angular/services/status-service.js

@ -88,6 +88,8 @@ angular.module('openproject.workPackages.controllers')
};
function initialLoad(){
// TODO RS: Around about now we need to get the project from the api so that we know about its
// custom fields so that we can use them as filters.
setupPagination(PAGINATION_OPTIONS);
$scope.updateResults();
};

@ -1,13 +1,23 @@
angular.module('openproject.workPackages.directives')
.directive('queryFilter', ['WorkPackagesTableHelper', 'WorkPackageService', 'FunctionDecorators', function(WorkPackagesTableHelper, WorkPackageService, FunctionDecorators) {
.directive('queryFilter', ['WorkPackagesTableHelper', 'WorkPackageService', 'FunctionDecorators', 'StatusService', function(WorkPackagesTableHelper, WorkPackageService, FunctionDecorators, StatusService) {
return {
restrict: 'A',
link: function(scope, element, attributes) {
function populateValues(data){
// Do something...
}
// TODO RS: We need to extend this so that it gets possible values from the api if it is a 'list_model' filter
scope.availableValues = scope.query.getAvailableFilterValues(scope.filter.name);
scope.showValueOptionsAsSelect = ['list', 'list_optional', 'list_status', 'list_subprojects'].indexOf(scope.query.getFilterType(scope.filter.name)) !== -1;
scope.showValueOptionsAsSelect = ['list', 'list_optional', 'list_status', 'list_subprojects', 'list_model'].indexOf(scope.query.getFilterType(scope.filter.name)) !== -1;
if(scope.filter.name == 'list_model'){
// Get possible values
StatusService.getStatuses().then(populateValues);
}
scope.$watch('filter.operator', function(operator) {
if(operator) scope.showValuesInput = scope.filter.requiresValues();

@ -31,6 +31,9 @@ angular.module('openproject.helpers')
},
versionPath: function(versionId) {
return '/versions/' + versionId;
},
statusesPath: function() {
return '/statuses'
}
};

@ -0,0 +1,25 @@
angular.module('openproject.services')
.service('StatusService', ['$http', 'PathHelper', function($http, PathHelper) {
var StatusService = {
getStatuses: function() {
var url = PathHelper.statusesPath();
return WorkPackageService.doQuery(url);
},
doQuery: function(url, params) {
return $http({
method: 'GET',
url: url,
params: params,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).then(function(response){
return response.data;
});
}
};
return StatusService;
}]);
Loading…
Cancel
Save