From 44fcdc74f4c39adf93168941d57fad705a951d6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Wed, 24 Feb 2016 15:23:44 +0100 Subject: [PATCH] Use param service in query Uses `ApiParamMappingService.constructor` which sounds wrong... ? --- .../api-experimental/api-param-mapping.service.ts | 13 +++++++++---- .../api-work-packages/api-work-packages.service.ts | 2 +- ...-service.service.js => query-service.service.ts} | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) rename frontend/app/components/query/{query-service.service.js => query-service.service.ts} (99%) diff --git a/frontend/app/components/api/api-experimental/api-param-mapping.service.ts b/frontend/app/components/api/api-experimental/api-param-mapping.service.ts index 0434e7331c..a5cd6f5d4d 100644 --- a/frontend/app/components/api/api-experimental/api-param-mapping.service.ts +++ b/frontend/app/components/api/api-experimental/api-param-mapping.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); diff --git a/frontend/app/components/api/api-work-packages/api-work-packages.service.ts b/frontend/app/components/api/api-work-packages/api-work-packages.service.ts index 6d380540c6..8c78dfa212 100644 --- a/frontend/app/components/api/api-work-packages/api-work-packages.service.ts +++ b/frontend/app/components/api/api-work-packages/api-work-packages.service.ts @@ -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'); } diff --git a/frontend/app/components/query/query-service.service.js b/frontend/app/components/query/query-service.service.ts similarity index 99% rename from frontend/app/components/query/query-service.service.js rename to frontend/app/components/query/query-service.service.ts index 08c8727323..c3382a1676 100644 --- a/frontend/app/components/query/query-service.service.js +++ b/frontend/app/components/query/query-service.service.ts @@ -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; }); },