Use param service in query

Uses `ApiParamMappingService.constructor` which sounds wrong... ?
pull/4159/head
Oliver Günther 9 years ago committed by Jens Ulferts
parent 00d1d8efc3
commit 44fcdc74f4
  1. 13
      frontend/app/components/api/api-experimental/api-param-mapping.service.ts
  2. 2
      frontend/app/components/api/api-work-packages/api-work-packages.service.ts
  3. 4
      frontend/app/components/query/query-service.service.ts

@ -29,16 +29,21 @@
export class ApiParamMappingService {
//TODO: Add missing properties.
protected propertyMap = {
protected static propertyMap = {
assigned_to: 'assignee',
updated_at: 'updatedAt'
};
public transformV3(columns: any[]) {
return columns.map(column => column.name = this.propertyMap[column.name] || column.name);
public static columnListToV3(columns: any[]) {
columns.forEach(column => column.name = ApiParamMappingService.columnToV3(column));
return columns;
}
public static columnToV3(column: any) {
return ApiParamMappingService.propertyMap[column.name] || column.name;
}
}
angular
.module('openproject.api')
.service('apiParamMapping', ApiParamMappingService);
.service('ApiParamMappingService', ApiParamMappingService);

@ -36,7 +36,7 @@ export class ApiWorkPackagesService {
protected $stateParams,
protected $q:ng.IQService,
protected apiV3:restangular.IService,
protected apiParamMapping:ApiParamMappingService) {
protected apiMetaData:ApiMetaDataService) {
this.WorkPackages = apiV3.service('work_packages');
}

@ -27,11 +27,11 @@
// ++
function QueryService(Query,
ApiParamMappingService,
$http,
PathHelper,
$q,
AVAILABLE_WORK_PACKAGE_FILTERS,
ApiParamMappingService,
StatusService,
TypeService,
PriorityService,
@ -199,7 +199,7 @@ function QueryService(Query,
var url = projectIdentifier ? PathHelper.apiProjectAvailableColumnsPath(projectIdentifier) : PathHelper.apiAvailableColumnsPath();
return QueryService.doGet(url, function(response){
availableColumns = response.data.available_columns;
availableColumns = ApiParamMappingService.constructor.columnListToV3(response.data.available_columns);
return availableColumns;
});
},
Loading…
Cancel
Save