Fixed: Empty work package full screen view.

pull/4338/head
Roman Roelofsen 9 years ago
parent 6c93b32c95
commit c605b904d2
  1. 12
      frontend/app/components/api/api-work-packages/api-work-packages.service.ts
  2. 14
      frontend/app/components/work-packages/work-package-cache.service.ts

@ -47,6 +47,16 @@ export class ApiWorkPackagesService {
); );
} }
/**
* Loads a WorkPackage.
*
* @param id The ID of the WorkPackage.
* @returns {IPromise<any>|IPromise<WorkPackageResource>} A promise for the WorkPackage.
*/
public loadWorkPackageById(id: number) {
return this.apiV3.one("work_packages", id).get();
}
/** /**
* Returns a promise to post `/api/v3/work_packages/form`. * Returns a promise to post `/api/v3/work_packages/form`.
* *
@ -69,7 +79,7 @@ export class ApiWorkPackagesService {
if (!!projectIdentifier) { if (!!projectIdentifier) {
args.push(this.apiV3.one('projects', projectIdentifier)); args.push(this.apiV3.one('projects', projectIdentifier));
} }
return this.apiV3.service(...args); return this.apiV3.service(...args);
} }

@ -29,6 +29,8 @@
import {openprojectModule} from "../../angular-modules"; import {openprojectModule} from "../../angular-modules";
import WorkPackageResource from "../api/api-v3/hal-resources/work-package-resource.service"; import WorkPackageResource from "../api/api-v3/hal-resources/work-package-resource.service";
import {ApiWorkPackagesService} from "../api/api-work-packages/api-work-packages.service";
import IScope = angular.IScope;
export class WorkPackageCacheService { export class WorkPackageCacheService {
@ -38,11 +40,13 @@ export class WorkPackageCacheService {
workPackagesSubject = new Rx.ReplaySubject<{[id: number]: WorkPackageResource}>(1); workPackagesSubject = new Rx.ReplaySubject<{[id: number]: WorkPackageResource}>(1);
/*@ngInject*/ /*@ngInject*/
constructor(private $rootScope) { constructor(private $rootScope: IScope, private apiWorkPackages: ApiWorkPackagesService) {
} }
updateWorkPackage(wp: WorkPackageResource) { updateWorkPackage(wp: WorkPackageResource) {
this.updateWorkPackageList([wp]); this.updateWorkPackageList([wp]);
// romanroe: TODO Remove. Only required for 'old' API consumers.
this.$rootScope.$broadcast('workPackageRefreshRequired'); this.$rootScope.$broadcast('workPackageRefreshRequired');
} }
@ -53,7 +57,13 @@ export class WorkPackageCacheService {
this.workPackagesSubject.onNext(this.workPackageCache); this.workPackagesSubject.onNext(this.workPackageCache);
} }
loadWorkPackage(workPackageId: number): Rx.Observable<WorkPackageResource> { loadWorkPackage(workPackageId: number, forceUpdate = false): Rx.Observable<WorkPackageResource> {
if (forceUpdate || this.workPackageCache[workPackageId] === undefined) {
this.apiWorkPackages.loadWorkPackageById(workPackageId).then(wp => {
this.updateWorkPackage(wp);
});
}
return this.workPackagesSubject return this.workPackagesSubject
.map(cache => cache[workPackageId]) .map(cache => cache[workPackageId])
.filter(wp => wp !== undefined); .filter(wp => wp !== undefined);

Loading…
Cancel
Save