Commit 553afc42d3b52f99542938d1db5d49d46d97b617
Exists in
staging
Merge branch 'master' into staging
Showing
7 changed files
with
26 additions
and
19 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 | 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/layout/blocks/block.component.ts
| ... | ... | @@ -4,13 +4,14 @@ import { BlockService } from '../../../lib/ng-noosfero-api/http/block.service'; |
| 4 | 4 | import { NotificationService } from '../../shared/services/notification.service'; |
| 5 | 5 | import { AuthService, SessionService, AuthEvents } from "../../login"; |
| 6 | 6 | import { TranslatorService } from "../../shared/services/translator.service"; |
| 7 | +import { DesignModeService } from "../../admin/layout-edit/designMode.service"; | |
| 7 | 8 | |
| 8 | 9 | @Component({ |
| 9 | 10 | selector: 'noosfero-block', |
| 10 | 11 | templateUrl: 'app/layout/blocks/block.html', |
| 11 | 12 | directives: [BlockEditionComponent] |
| 12 | 13 | }) |
| 13 | -@Inject("$uibModal", "$scope", "$state", "$rootScope", BlockService, NotificationService, AuthService, SessionService, TranslatorService) | |
| 14 | +@Inject("$uibModal", "$scope", "$state", "$rootScope", BlockService, NotificationService, AuthService, SessionService, TranslatorService, DesignModeService) | |
| 14 | 15 | export class BlockComponent { |
| 15 | 16 | |
| 16 | 17 | @Input() block: noosfero.Block; |
| ... | ... | @@ -31,7 +32,8 @@ export class BlockComponent { |
| 31 | 32 | private notificationService: NotificationService, |
| 32 | 33 | private authService: AuthService, |
| 33 | 34 | private session: SessionService, |
| 34 | - private translatorService: TranslatorService) { | |
| 35 | + private translatorService: TranslatorService, | |
| 36 | + private designModeService: DesignModeService) { | |
| 35 | 37 | |
| 36 | 38 | this.currentUser = this.session.currentUser(); |
| 37 | 39 | this.authService.subscribe(AuthEvents[AuthEvents.loginSuccess], () => { |
| ... | ... | @@ -45,6 +47,10 @@ export class BlockComponent { |
| 45 | 47 | this.$rootScope.$on("$stateChangeSuccess", (event: ng.IAngularEvent, toState: ng.ui.IState) => { |
| 46 | 48 | this.verifyHomepage(); |
| 47 | 49 | }); |
| 50 | + this.designModeService.onToggle.subscribe((designModeOn: boolean) => { | |
| 51 | + this.editionMode = designModeOn; | |
| 52 | + this.$scope.$apply(); | |
| 53 | + }); | |
| 48 | 54 | } |
| 49 | 55 | |
| 50 | 56 | ngOnInit() { | ... | ... |
src/app/layout/scss/_layout.scss
| ... | ... | @@ -36,14 +36,6 @@ |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - | |
| 40 | -body.noosfero-design-on { | |
| 41 | - | |
| 42 | - div.content-wrapper { | |
| 43 | - opacity: 0.5; | |
| 44 | - } | |
| 45 | -} | |
| 46 | - | |
| 47 | 39 | ul.nav > li.toggler-container { |
| 48 | 40 | position: relative; |
| 49 | 41 | padding-top: 12px; |
| ... | ... | @@ -55,4 +47,4 @@ ul.nav > li.toggler-container { |
| 55 | 47 | margin-left: 0px; |
| 56 | 48 | margin-right: 0px; |
| 57 | 49 | background-color: #edecec; |
| 58 | -} | |
| 59 | 50 | \ No newline at end of file |
| 51 | +} | ... | ... |
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> | ... | ... |
src/app/search/search-form/search-form.component.spec.ts
| ... | ... | @@ -8,7 +8,7 @@ describe("Components", () => { |
| 8 | 8 | describe("Search Form Component", () => { |
| 9 | 9 | |
| 10 | 10 | let helper: ComponentTestHelper<SearchFormComponent>; |
| 11 | - let stateMock = jasmine.createSpyObj("$state", ["go"]); | |
| 11 | + let stateMock = jasmine.createSpyObj("$state", ["go", "params", "current"]); | |
| 12 | 12 | |
| 13 | 13 | beforeEach(angular.mock.module("templates")); |
| 14 | 14 | ... | ... |
src/app/search/search.component.spec.ts
| ... | ... | @@ -12,6 +12,7 @@ describe("Components", () => { |
| 12 | 12 | let articleService = jasmine.createSpyObj("ArticleService", ["search"]); |
| 13 | 13 | let result = Promise.resolve({ data: [{ id: 1 }], headers: (param: string) => { return 1; } }); |
| 14 | 14 | articleService.search = jasmine.createSpy("search").and.returnValue(result); |
| 15 | + let stateMock = jasmine.createSpyObj("$state", ["go"]); | |
| 15 | 16 | |
| 16 | 17 | beforeEach(angular.mock.module("templates")); |
| 17 | 18 | |
| ... | ... | @@ -21,7 +22,8 @@ describe("Components", () => { |
| 21 | 22 | directives: [SearchComponent], |
| 22 | 23 | providers: [ |
| 23 | 24 | helpers.createProviderToValue("$stateParams", stateParams), |
| 24 | - helpers.createProviderToValue("ArticleService", articleService) | |
| 25 | + helpers.createProviderToValue("ArticleService", articleService), | |
| 26 | + helpers.createProviderToValue("$state", stateMock), | |
| 25 | 27 | ].concat(helpers.provideFilters("truncateFilter", "stripTagsFilter")) |
| 26 | 28 | }); |
| 27 | 29 | helper = new ComponentTestHelper<SearchComponent>(cls, done); | ... | ... |