Apply given project context as a scope when fetching available filter values

pull/1065/head
Till Breuer 11 years ago
parent 30095e6d54
commit e0aec03d64
  1. 2
      app/assets/javascripts/angular/directives/work_packages/query-filter-directive.js
  2. 24
      app/assets/javascripts/angular/helpers/components/path-helper.js
  3. 1
      app/assets/javascripts/angular/services/pagination-service.js
  4. 10
      app/assets/javascripts/angular/services/query-service.js
  5. 4
      app/assets/javascripts/angular/services/type-service.js
  6. 18
      app/assets/javascripts/angular/services/user-service.js

@ -9,7 +9,7 @@ angular.module('openproject.workPackages.directives')
scope.showValueOptionsAsSelect = ['list', 'list_optional', 'list_status', 'list_subprojects', 'list_model'].indexOf(scope.query.getFilterType(scope.filter.name)) !== -1;
if (scope.showValueOptionsAsSelect) {
QueryService.getAvailableFilterValues(scope.filter.name)
QueryService.getAvailableFilterValues(scope.filter.name, scope.projectIdentifier)
.then(function(values) {
scope.availableFilterValues = values.map(function(value) {
return [value.name, value.id];

@ -3,7 +3,7 @@ angular.module('openproject.helpers')
.service('PathHelper', [function() {
PathHelper = {
apiPrefix: '/api/v2',
apiPrefixV2: '/api/v2',
apiPrefixV3: '/api/v3',
projectPath: function(projectIdentifier) {
@ -27,6 +27,9 @@ angular.module('openproject.helpers')
apiProjectPath: function(projectIdentifier) {
return PathHelper.apiPrefixV3 + PathHelper.projectPath(projectIdentifier);
},
apiV2ProjectPath: function(projectIdentifier) {
return PathHelper.apiPrefixV2 + PathHelper.projectPath(projectIdentifier);
},
apiWorkPackagesPath: function() {
return PathHelper.apiPrefixV3 + '/work_packages';
},
@ -40,22 +43,25 @@ angular.module('openproject.helpers')
return PathHelper.apiWorkPackagesPath() + '/column_data';
},
apiPrioritiesPath: function() {
return PathHelper.apiPrefix + '/planning_element_priorities';
return PathHelper.apiPrefixV2 + '/planning_element_priorities';
},
apiStatusesPath: function() {
return PathHelper.apiPrefix + '/statuses';
return PathHelper.apiPrefixV2 + '/statuses';
},
apiProjectStatusesPath: function(projectIdentifier) {
return PathHelper.apiProjectPath(projectIdentifier) + '/statuses';
return PathHelper.apiV2ProjectPath(projectIdentifier) + '/statuses';
},
apiTypesPath: function() {
return PathHelper.apiPrefix + '/planning_element_types';
apiWorkPackageTypesPath: function() {
return PathHelper.apiPrefixV2 + '/planning_element_types';
},
apiProjectTypesPath: function(projectIdentifier) {
return PathHelper.apiProjectPath(projectIdentifier) + '/planning_element_types';
apiProjectWorkPackageTypesPath: function(projectIdentifier) {
return PathHelper.apiV2ProjectPath(projectIdentifier) + '/planning_element_types';
},
apiUsersPath: function() {
return PathHelper.apiPrefix + PathHelper.usersPath();
return PathHelper.apiPrefixV2 + PathHelper.usersPath();
},
apiProjectUsersPath: function(projectIdentifier) {
return PathHelper.apiV2ProjectPath(projectIdentifier) + PathHelper.usersPath();
},
apiWorkPackagesSumsPath: function(projectIdentifier) {
return PathHelper.apiProjectPath(projectIdentifier) + PathHelper.workPackagesPath() + '/column_sums';

@ -43,7 +43,6 @@ angular.module('openproject.services')
nextPage: function() {
paginationOptions.page = paginationOptions.page + 1;
},
previousPage: function() {
paginationOptions.page = paginationOptions.page - 1;
}

@ -11,7 +11,7 @@ angular.module('openproject.services')
return QueryService.doQuery(url);
},
getAvailableFilterValues: function(filterName) {
getAvailableFilterValues: function(filterName, projectIdentifier) {
var modelName = AVAILABLE_WORK_PACKAGE_FILTERS[filterName].modelName;
if(availableFilterValues[modelName]) {
@ -21,16 +21,16 @@ angular.module('openproject.services')
switch(modelName) {
case 'status':
retrieveAvailableValues = StatusService.getStatuses();
retrieveAvailableValues = StatusService.getStatuses(projectIdentifier);
break;
case 'type':
retrieveAvailableValues = TypeService.getTypes();
retrieveAvailableValues = TypeService.getTypes(projectIdentifier);
break;
case 'priority':
retrieveAvailableValues = TypeService.getPriorities();
retrieveAvailableValues = PriorityService.getPriorities(projectIdentifier);
break;
case 'user':
retrieveAvailableValues = UserService.getUsers();
retrieveAvailableValues = UserService.getUsers(projectIdentifier);
break;
}

@ -7,9 +7,9 @@ angular.module('openproject.services')
var url;
if(projectIdentifier) {
url = PathHelper.apiProjectTypesPath(projectIdentifier);
url = PathHelper.apiProjectWorkPackageTypesPath(projectIdentifier);
} else {
url = PathHelper.apiTypesPath();
url = PathHelper.apiWorkPackageTypesPath();
}

@ -4,10 +4,17 @@ angular.module('openproject.services')
var registeredUserIds = [], cachedUsers = {};
UserService = {
getUsers: function() {
var url = PathHelper.apiUsersPath();
getUsers: function(projectIdentifier) {
var url, params;
return UserService.doQuery(url);
if (projectIdentifier) {
url = PathHelper.apiProjectUsersPath(projectIdentifier);
} else {
url = PathHelper.apiUsersPath();
params = {status: 'all'};
}
return UserService.doQuery(url, params);
},
registerUserId: function(id) {
@ -45,11 +52,6 @@ angular.module('openproject.services')
},
doQuery: function(url, params) {
if(!params) {
// TODO find out which scope we want to apply here
params = {status: 'all'};
}
return $http.get(url, { params: params })
.then(function(response){
return response.data.users;

Loading…
Cancel
Save