Commit 976d69f6494f6bb8bca92ac38609c339875605ce

Authored by Carlos Purificação
1 parent c3feee1a

Fixed custom component edit buttons state

src/app/layout/blocks/block.html
1   -<div ng-show="ctrl.canDisplay() || ctrl.editionMode || ctrl.designMode" ng-class="{'invisible-block': !ctrl.canDisplay()}" class="noosfero-block" ng-mouseover="displayActions = true" ng-mouseleave="displayActions = false">
  1 +<div ng-show="ctrl.canDisplay() || ctrl.inEditMode() || ctrl.designMode" ng-class="{'invisible-block': !ctrl.canDisplay()}" class="noosfero-block" ng-mouseover="displayActions = true" ng-mouseleave="displayActions = false">
2 2 <div ng-show="displayActions" class="actions block-actions" permission="ctrl.block.permissions" permission-action="allow_edit">
3 3 <button type="submit" class="btn btn-xs btn-default" ng-click="ctrl.openEdit()"><i class="fa fa-edit fa-fw"></i></button>
4 4 </div>
... ...
src/app/profile/custom-content/custom-content.component.spec.ts
... ... @@ -15,6 +15,7 @@ describe(&quot;Components&quot;, () =&gt; {
15 15 beforeEach((done) => {
16 16 let profileService = jasmine.createSpyObj("profileService", ["update"]);
17 17 let notificationService = jasmine.createSpyObj("notificationService", ["success"]);
  18 + let designModeService = { isInDesignMode: () => { return true; }};
18 19 let properties = { profile: { custom_footer: "footer" } };
19 20 let cls = createClass({
20 21 template: htmlTemplate,
... ... @@ -24,7 +25,8 @@ describe(&quot;Components&quot;, () =&gt; {
24 25 helpers.createProviderToValue("$uibModal", helpers.mocks.$modal),
25 26 helpers.createProviderToValue("ProfileService", profileService),
26 27 helpers.createProviderToValue("NotificationService", notificationService),
27   - helpers.createProviderToValue("DesignModeService", helpers.mocks.designModeService)
  28 + //helpers.createProviderToValue("DesignModeService", helpers.mocks.designModeService)
  29 + helpers.createProviderToValue("DesignModeService", designModeService)
28 30 ]
29 31 });
30 32 helper = new ComponentTestHelper<CustomContentComponent>(cls, done);
... ...
src/app/profile/custom-content/custom-content.component.ts
... ... @@ -20,7 +20,6 @@ export class CustomContentComponent {
20 20  
21 21 content: string;
22 22 originalContent: string;
23   - editionMode = false;
24 23 private modalInstance: any = null;
25 24  
26 25 constructor(private $uibModal: any,
... ... @@ -35,9 +34,10 @@ export class CustomContentComponent {
35 34 }, () => {
36 35 if (this.profile) this.content = (<any>this.profile)[this.attribute];
37 36 });
38   - this.designModeService.onToggle.subscribe((designModeOn: boolean) => {
39   - this.editionMode = designModeOn;
40   - });
  37 + }
  38 +
  39 + inEditMode() {
  40 + return this.designModeService.isInDesignMode();
41 41 }
42 42  
43 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" ng-show="ctrl.editionMode">
  2 + <div class="actions" permission="ctrl.profile.permissions" permission-action="allow_edit" ng-show="ctrl.inEditMode()">
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>
... ...