Commit 2ea040a4c8c1b110f325e1f3fd52d9b3d41e7728

Authored by Victor Costa
1 parent 18b99fd3

Enable header and footer edition when toggle design mode

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 3 @Injectable()
5 4 export class DesignModeService {
... ... @@ -20,4 +19,4 @@ export class DesignModeService {
20 19  
21 20 constructor() {
22 21 }
23   -}
24 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 2 import {ProfileService} from '../../../lib/ng-noosfero-api/http/profile.service';
3 3 import {NotificationService} from '../../shared/services/notification.service';
4 4 import {PermissionDirective} from '../../shared/components/permission/permission.directive';
  5 +import {DesignModeService} from '../../admin/layout-edit/designMode.service';
5 6  
6 7 @Component({
7 8 selector: 'custom-content',
8 9 templateUrl: "app/profile/custom-content/custom-content.html",
9 10 directives: [PermissionDirective]
10 11 })
11   -@Inject("$uibModal", "$scope", ProfileService, NotificationService)
  12 +@Inject("$uibModal", "$scope", ProfileService, NotificationService, DesignModeService)
12 13 export class CustomContentComponent {
13 14  
  15 + static $inject = ["DesignModeService"]; // @Inject doesn't works with uibModal.open
  16 +
14 17 @Input() attribute: string;
15 18 @Input() profile: noosfero.Profile;
16 19 @Input() label: string;
17 20  
18 21 content: string;
19 22 originalContent: string;
  23 + editionMode = false;
20 24 private modalInstance: any = null;
21 25  
22 26 constructor(private $uibModal: any,
23 27 private $scope: ng.IScope,
24 28 private profileService: ProfileService,
25   - private notificationService: NotificationService) { }
  29 + private notificationService: NotificationService,
  30 + private designModeService: DesignModeService) { }
26 31  
27 32 ngOnInit() {
28 33 this.$scope.$watch(() => {
... ... @@ -30,6 +35,9 @@ export class CustomContentComponent {
30 35 }, () => {
31 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 43 openEdit() {
... ...
src/app/profile/custom-content/custom-content.html
1 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 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 4 </div>
5 5 <div class="content" ng-bind-html="ctrl.content"></div>
... ...