From 805b75497168c109e73036143531055301a4df01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Thu, 12 May 2016 08:41:14 +0200 Subject: [PATCH] Add wpEditModeState service to register form --- ...ow.controller.js => wp-show.controller.ts} | 21 +++--- .../components/routing/wp-show/wp.show.html | 16 +++-- .../wp-edit/wp-edit-form.directive.ts | 8 +++ .../wp-edit/wp-edit-mode-state.service.ts | 68 +++++++++++++++++++ 4 files changed, 95 insertions(+), 18 deletions(-) rename frontend/app/components/routing/wp-show/{wp-show.controller.js => wp-show.controller.ts} (94%) create mode 100644 frontend/app/components/wp-edit/wp-edit-mode-state.service.ts diff --git a/frontend/app/components/routing/wp-show/wp-show.controller.js b/frontend/app/components/routing/wp-show/wp-show.controller.ts similarity index 94% rename from frontend/app/components/routing/wp-show/wp-show.controller.js rename to frontend/app/components/routing/wp-show/wp-show.controller.ts index 268e60e146..1478ce0bd1 100644 --- a/frontend/app/components/routing/wp-show/wp-show.controller.js +++ b/frontend/app/components/routing/wp-show/wp-show.controller.ts @@ -26,6 +26,8 @@ // See doc/COPYRIGHT.rdoc for more details. // ++ +import {scopedObservable} from "../../../helpers/angular-rx-utils"; +import {WorkPackageResource} from "../../api/api-v3/hal-resources/work-package-resource.service"; function WorkPackageShowController($scope, $rootScope, $state, @@ -43,23 +45,18 @@ function WorkPackageShowController($scope, CommonRelationsHandler, ChildrenRelationsHandler, ParentRelationsHandler, - EditableFieldsState, WorkPackageAuthorization, HookService, AuthorisationService, - inplaceEditAll) { + wpCacheService, + wpEditModeState) { - $scope.editAll = inplaceEditAll; - $scope.canEdit = EditableFieldsState.canEdit; + $scope.wpEditModeState = wpEditModeState; - //Show all attributes in Edit-Mode - $scope.$watch(function(){ - return inplaceEditAll.state; - },function(newState, oldState){ - if(newState !== oldState){ - vm.hideEmptyFields = !newState; - } - }); + scopedObservable($scope, wpCacheService.loadWorkPackage(workPackage.props.id)) + .subscribe((wp: WorkPackageResource) => { + $scope.workPackageResource = wp; + }); // Listen to the event globally, as listeners are not necessarily // in the child scope diff --git a/frontend/app/components/routing/wp-show/wp.show.html b/frontend/app/components/routing/wp-show/wp.show.html index 5101179638..ae8694e2e4 100644 --- a/frontend/app/components/routing/wp-show/wp.show.html +++ b/frontend/app/components/routing/wp-show/wp.show.html @@ -1,17 +1,21 @@ -
+
  • @@ -35,7 +39,7 @@