Commit 2ea040a4c8c1b110f325e1f3fd52d9b3d41e7728
1 parent
18b99fd3
Exists in
master
and in
10 other branches
Enable header and footer edition when toggle design mode
Showing
3 changed files
with
13 additions
and
6 deletions
Show diff stats
src/app/admin/layout-edit/designMode.service.ts
| 1 | -import {Component, Injectable, Output, EventEmitter} from 'ng-forward'; | ||
| 2 | -import {BodyStateClassesService} from '../../layout/services/body-state-classes.service'; | 1 | +import {Injectable, Output, EventEmitter} from 'ng-forward'; |
| 3 | 2 | ||
| 4 | @Injectable() | 3 | @Injectable() |
| 5 | export class DesignModeService { | 4 | export class DesignModeService { |
| @@ -20,4 +19,4 @@ export class DesignModeService { | @@ -20,4 +19,4 @@ export class DesignModeService { | ||
| 20 | 19 | ||
| 21 | constructor() { | 20 | constructor() { |
| 22 | } | 21 | } |
| 23 | -} | ||
| 24 | \ No newline at end of file | 22 | \ No newline at end of file |
| 23 | +} |
src/app/profile/custom-content/custom-content.component.ts
| @@ -2,27 +2,32 @@ import {Component, Input, Inject} from 'ng-forward'; | @@ -2,27 +2,32 @@ import {Component, Input, Inject} from 'ng-forward'; | ||
| 2 | import {ProfileService} from '../../../lib/ng-noosfero-api/http/profile.service'; | 2 | import {ProfileService} from '../../../lib/ng-noosfero-api/http/profile.service'; |
| 3 | import {NotificationService} from '../../shared/services/notification.service'; | 3 | import {NotificationService} from '../../shared/services/notification.service'; |
| 4 | import {PermissionDirective} from '../../shared/components/permission/permission.directive'; | 4 | import {PermissionDirective} from '../../shared/components/permission/permission.directive'; |
| 5 | +import {DesignModeService} from '../../admin/layout-edit/designMode.service'; | ||
| 5 | 6 | ||
| 6 | @Component({ | 7 | @Component({ |
| 7 | selector: 'custom-content', | 8 | selector: 'custom-content', |
| 8 | templateUrl: "app/profile/custom-content/custom-content.html", | 9 | templateUrl: "app/profile/custom-content/custom-content.html", |
| 9 | directives: [PermissionDirective] | 10 | directives: [PermissionDirective] |
| 10 | }) | 11 | }) |
| 11 | -@Inject("$uibModal", "$scope", ProfileService, NotificationService) | 12 | +@Inject("$uibModal", "$scope", ProfileService, NotificationService, DesignModeService) |
| 12 | export class CustomContentComponent { | 13 | export class CustomContentComponent { |
| 13 | 14 | ||
| 15 | + static $inject = ["DesignModeService"]; // @Inject doesn't works with uibModal.open | ||
| 16 | + | ||
| 14 | @Input() attribute: string; | 17 | @Input() attribute: string; |
| 15 | @Input() profile: noosfero.Profile; | 18 | @Input() profile: noosfero.Profile; |
| 16 | @Input() label: string; | 19 | @Input() label: string; |
| 17 | 20 | ||
| 18 | content: string; | 21 | content: string; |
| 19 | originalContent: string; | 22 | originalContent: string; |
| 23 | + editionMode = false; | ||
| 20 | private modalInstance: any = null; | 24 | private modalInstance: any = null; |
| 21 | 25 | ||
| 22 | constructor(private $uibModal: any, | 26 | constructor(private $uibModal: any, |
| 23 | private $scope: ng.IScope, | 27 | private $scope: ng.IScope, |
| 24 | private profileService: ProfileService, | 28 | private profileService: ProfileService, |
| 25 | - private notificationService: NotificationService) { } | 29 | + private notificationService: NotificationService, |
| 30 | + private designModeService: DesignModeService) { } | ||
| 26 | 31 | ||
| 27 | ngOnInit() { | 32 | ngOnInit() { |
| 28 | this.$scope.$watch(() => { | 33 | this.$scope.$watch(() => { |
| @@ -30,6 +35,9 @@ export class CustomContentComponent { | @@ -30,6 +35,9 @@ export class CustomContentComponent { | ||
| 30 | }, () => { | 35 | }, () => { |
| 31 | if (this.profile) this.content = (<any>this.profile)[this.attribute]; | 36 | if (this.profile) this.content = (<any>this.profile)[this.attribute]; |
| 32 | }); | 37 | }); |
| 38 | + this.designModeService.onToggle.subscribe((designModeOn: boolean) => { | ||
| 39 | + this.editionMode = designModeOn; | ||
| 40 | + }); | ||
| 33 | } | 41 | } |
| 34 | 42 | ||
| 35 | openEdit() { | 43 | openEdit() { |
src/app/profile/custom-content/custom-content.html
| 1 | <div class="custom-content"> | 1 | <div class="custom-content"> |
| 2 | - <div class="actions" permission="ctrl.profile.permissions" permission-action="allow_edit"> | 2 | + <div class="actions" permission="ctrl.profile.permissions" permission-action="allow_edit" ng-show="ctrl.editionMode"> |
| 3 | <button type="submit" class="btn btn-xs btn-default" ng-click="ctrl.openEdit()"><i class="fa fa-edit fa-fw"></i> {{ctrl.label | translate}}</button> | 3 | <button type="submit" class="btn btn-xs btn-default" ng-click="ctrl.openEdit()"><i class="fa fa-edit fa-fw"></i> {{ctrl.label | translate}}</button> |
| 4 | </div> | 4 | </div> |
| 5 | <div class="content" ng-bind-html="ctrl.content"></div> | 5 | <div class="content" ng-bind-html="ctrl.content"></div> |