Avoid early observing of work package before constructor has completed

pull/4643/head
Oliver Günther 8 years ago
parent bf23aabbfd
commit 7a7b9a71ca
  1. 1
      frontend/app/components/routing/wp-details/wp-details.controller.ts
  2. 2
      frontend/app/components/routing/wp-show/wp-show.controller.ts
  3. 15
      frontend/app/components/routing/wp-view-base/wp-view-base.controller.ts

@ -35,6 +35,7 @@ export class WorkPackageDetailsController extends WorkPackageViewController {
public $scope,
public $state) {
super($injector, $scope, $state.params['workPackageId']);
this.observeWorkPackage();
}
public onWorkPackageSave() {

@ -26,7 +26,6 @@
// See doc/COPYRIGHT.rdoc for more details.
// ++
import {WorkPackageEditModeStateService} from "../../wp-edit/wp-edit-mode-state.service";
import {wpControllersModule} from '../../../angular-modules';
import {WorkPackageViewController} from '../wp-view-base/wp-view-base.controller';
import {WorkPackageResourceInterface} from '../../api/api-v3/hal-resources/work-package-resource.service';
@ -60,6 +59,7 @@ export class WorkPackageShowController extends WorkPackageViewController {
public WorkPackageAuthorization,
public PERMITTED_MORE_MENU_ACTIONS) {
super($injector, $scope, $state.params['workPackageId']);
this.observeWorkPackage();
}
protected init() {

@ -47,7 +47,7 @@ export class WorkPackageViewController {
// Helper promise to detect when the controller has been initialized
// (when a WP has loaded).
public initialized:ng.IPromise<any>;
public initialized:ng.IDeferred<any>;
// Static texts
public text:any = {};
@ -63,15 +63,20 @@ export class WorkPackageViewController {
this.$inject('$q', '$state', 'keepTab', 'wpCacheService', 'WorkPackageService',
'wpEditModeState', 'PathHelper', 'I18n');
var deferred = this.$q.defer();
this.initialized = deferred.promise;
this.initialized = this.$q.defer();
this.initializeTexts();
}
scopedObservable($scope, this.wpCacheService.loadWorkPackage(workPackageId))
/**
* Observe changes of work package and re-run initialization.
* Needs to be run explicitly by descendants.
*/
protected observeWorkPackage() {
scopedObservable(this.$scope, this.wpCacheService.loadWorkPackage(this.workPackageId))
.subscribe((wp:WorkPackageResourceInterface) => {
this.workPackage = wp;
this.init();
deferred.resolve();
this.initialized.resolve();
});
}

Loading…
Cancel
Save