diff --git a/src/app/layout/blocks/block-edition/block-edition.component.ts b/src/app/layout/blocks/block-edition/block-edition.component.ts
new file mode 100644
index 0000000..446a717
--- /dev/null
+++ b/src/app/layout/blocks/block-edition/block-edition.component.ts
@@ -0,0 +1,18 @@
+import { Input, Component } from 'ng-forward';
+
+@Component({
+ selector: 'noosfero-block-edition',
+ templateUrl: 'app/layout/blocks/block-edition/block-edition.html'
+})
+export class BlockEditionComponent {
+
+ displayOptions: any;
+ displayUserOptions: any;
+ languageOptions: any;
+
+ constructor() {
+ this.displayOptions = ["always", "home_page_only", "except_home_page", "never"];
+ this.displayUserOptions = ["all", "logged", "not_logged"];
+ this.languageOptions = ["all", "en", "pt"]; // FIXME get language list
+ }
+}
diff --git a/src/app/layout/blocks/block-edition/block-edition.html b/src/app/layout/blocks/block-edition/block-edition.html
new file mode 100644
index 0000000..07fa4cf
--- /dev/null
+++ b/src/app/layout/blocks/block-edition/block-edition.html
@@ -0,0 +1,34 @@
+
+
{{"block.edition.title" | translate}}
+
+
+
+
+
+
+
+
+
diff --git a/src/app/layout/blocks/block-edition/block-edition.scss b/src/app/layout/blocks/block-edition/block-edition.scss
new file mode 100644
index 0000000..bafe4d7
--- /dev/null
+++ b/src/app/layout/blocks/block-edition/block-edition.scss
@@ -0,0 +1,14 @@
+.edit-block {
+ margin: 20px;
+
+ .options {
+ margin-bottom: 20px;
+
+ .block-option {
+ @extend .form-group;
+ .block-input {
+ @extend .form-control;
+ }
+ }
+ }
+}
diff --git a/src/app/layout/blocks/block.component.ts b/src/app/layout/blocks/block.component.ts
new file mode 100644
index 0000000..ceb38b6
--- /dev/null
+++ b/src/app/layout/blocks/block.component.ts
@@ -0,0 +1,67 @@
+import { Input, Component, Inject } from 'ng-forward';
+import { BlockEditionComponent } from './block-edition/block-edition.component';
+import { BlockService } from '../../../lib/ng-noosfero-api/http/block.service';
+import {NotificationService} from '../../shared/services/notification.service';
+
+@Component({
+ selector: 'noosfero-block',
+ templateUrl: 'app/layout/blocks/block.html',
+ directives: [BlockEditionComponent]
+})
+@Inject("$uibModal", "$scope", BlockService, NotificationService)
+export class BlockComponent {
+
+ @Input() block: any;
+ @Input() owner: any;
+
+ private modalInstance: any = null;
+ originalBlock: noosfero.Block;
+
+ constructor(private $uibModal: any, private $scope: ng.IScope, private blockService: BlockService, private notificationService: NotificationService) { }
+
+ openEdit() {
+ if (!this.originalBlock) this.originalBlock = JSON.parse(JSON.stringify(this.block)); // deep copy of block data
+ this.modalInstance = this.$uibModal.open({
+ templateUrl: 'app/layout/blocks/block-edition/block-edition.html',
+ size: 'lg',
+ controller: BlockEditionComponent,
+ controllerAs: 'modal',
+ bindToController: true,
+ scope: this.$scope
+ });
+ }
+
+ save() {
+ this.blockService.update(this.attributesToUpdate(this.block)).then(() => {
+ this.closeEdit();
+ this.notificationService.success({ title: "block.edition.success.title", message: "block.edition.success.message" });
+ });
+ }
+
+ preview() {
+ this.closeEdit();
+ }
+
+ cancel() {
+ this.block = this.originalBlock;
+ this.closeEdit();
+ }
+
+ protected attributesToUpdate(block: noosfero.Block) {
+ return {
+ id: this.block.id,
+ display: this.block.settings.display,
+ title: this.block.title,
+ display_user: this.block.settings.display_user,
+ language: this.block.settings.language
+ };
+ }
+
+ private closeEdit() {
+ if (this.modalInstance) {
+ this.modalInstance.close();
+ this.modalInstance = null;
+ }
+ }
+
+}
diff --git a/src/app/layout/blocks/block.html b/src/app/layout/blocks/block.html
new file mode 100644
index 0000000..4d1e49d
--- /dev/null
+++ b/src/app/layout/blocks/block.html
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
{{ctrl.block.title}}
+
+
+
+
+
+
diff --git a/src/app/layout/blocks/block.scss b/src/app/layout/blocks/block.scss
index f6df6ba..558ca9e 100644
--- a/src/app/layout/blocks/block.scss
+++ b/src/app/layout/blocks/block.scss
@@ -1,10 +1,23 @@
-.block {
- .panel-title {
- font-size: 15px;
- font-weight: bold;
+.noosfero-block {
+ &.invisible-block {
+ .block {
+ opacity: 0.4;
+ }
}
- .panel-heading {
- background-color: transparent;
- border: 0;
+ .block {
+ .panel-title {
+ font-size: 15px;
+ font-weight: bold;
+ }
+ .panel-heading {
+ background-color: transparent;
+ border: 0;
+ }
+ }
+ .actions {
+ position: absolute;
+ z-index: 100;
+ right: 16px;
+ top: 1px;
}
}
diff --git a/src/app/layout/boxes/box.html b/src/app/layout/boxes/box.html
index 0d5da91..a0de606 100644
--- a/src/app/layout/boxes/box.html
+++ b/src/app/layout/boxes/box.html
@@ -1,10 +1,3 @@
-
-
-
{{block.title}}
-
-
-
-
-
+
diff --git a/src/app/main/main.component.ts b/src/app/main/main.component.ts
index 0830f3c..b5c693b 100644
--- a/src/app/main/main.component.ts
+++ b/src/app/main/main.component.ts
@@ -7,6 +7,7 @@ import {ArticleViewComponent} from "./../article/article-default-view.component"
import {ProfileComponent} from "../profile/profile.component";
import {BoxesComponent} from "../layout/boxes/boxes.component";
import {BlockContentComponent} from "../layout/blocks/block-content.component";
+import {BlockComponent} from "../layout/blocks/block.component";
import {EnvironmentComponent} from "../environment/environment.component";
import {EnvironmentHomeComponent} from "../environment/environment-home.component";
import {PeopleBlockComponent} from "../layout/blocks/people/people-block.component";
@@ -100,7 +101,7 @@ export class EnvironmentContent {
LinkListBlockComponent, CommunitiesBlockComponent, HtmlEditorComponent, ProfileComponent,
MainBlockComponent, RecentDocumentsBlockComponent, Navbar, SidebarComponent, ProfileImageBlockComponent,
MembersBlockComponent, NoosferoTemplate, DateFormat, RawHTMLBlockComponent, StatisticsBlockComponent,
- LoginBlockComponent, CustomContentComponent, PermissionDirective
+ LoginBlockComponent, CustomContentComponent, PermissionDirective, BlockComponent
].concat(plugins.mainComponents).concat(plugins.hotspots),
providers: [AuthService, SessionService, NotificationService, BodyStateClassesService,
"ngAnimate", "ngCookies", "ngStorage", "ngTouch",
diff --git a/src/languages/en.json b/src/languages/en.json
index ffc7034..530087f 100644
--- a/src/languages/en.json
+++ b/src/languages/en.json
@@ -6,6 +6,7 @@
"navbar.logout": "Log Out",
"navbar.login": "Login",
"navbar.toggle_menu": "Toggle navigation",
+ "language.all": "All languages",
"language.en": "English",
"language.pt": "Portuguese",
"language.selector": "Language",
@@ -74,5 +75,20 @@
"profile.content.success.message": "Profile saved!",
"custom_content.title": "Edit content",
"profile.custom_header.label": "Header",
- "profile.custom_footer.label": "Footer"
+ "profile.custom_footer.label": "Footer",
+ "block.edit": "Edit",
+ "block.edition.title": "Edit Block",
+ "block.edition.success.title": "Good job!",
+ "block.edition.success.message": "Block saved!",
+ "block.edition.display.label": "Display this block:",
+ "block.edition.title.label": "Custom title for this block:",
+ "block.edition.display.always": "In all pages",
+ "block.edition.display.home_page_only": "Only in the homepage",
+ "block.edition.display.except_home_page": "In all pages, except in the homepage",
+ "block.edition.display.never": "Don't display",
+ "block.edition.display_user.label": "Display to users:",
+ "block.edition.display_user.all": "All users",
+ "block.edition.display_user.logged": "Logged",
+ "block.edition.display_user.not_logged": "Not logged",
+ "block.edition.language.label": "Show for:"
}
diff --git a/src/languages/pt.json b/src/languages/pt.json
index bf1d05d..5682a4c 100644
--- a/src/languages/pt.json
+++ b/src/languages/pt.json
@@ -6,6 +6,7 @@
"navbar.logout": "Sair",
"navbar.login": "Login",
"navbar.toggle_menu": "Abrir Menu",
+ "language.all": "Todos os idiomas",
"language.en": "Inglês",
"language.pt": "Português",
"language.selector": "Idioma",
@@ -74,5 +75,20 @@
"profile.content.success.message": "Perfil salvo!",
"custom_content.title": "Editar conteúdo",
"profile.custom_header.label": "Cabeçalho",
- "profile.custom_footer.label": "Rodapé"
+ "profile.custom_footer.label": "Rodapé",
+ "block.edit": "Editar",
+ "block.edition.title": "Editar Bloco",
+ "block.edition.success.title": "Bom trabalho!",
+ "block.edition.success.message": "Bloco salvo com sucesso!",
+ "block.edition.display.label": "Exibir este bloco:",
+ "block.edition.title.label": "Título personalizado do bloco:",
+ "block.edition.display.always": "Em todas as páginas",
+ "block.edition.display.home_page_only": "Apenas na página inicial",
+ "block.edition.display.except_home_page": "Em todas as páginas, exceto na inicial",
+ "block.edition.display.never": "Não exibir",
+ "block.edition.display_user.label": "Exibir para usuários:",
+ "block.edition.display_user.all": "Todos os usuários",
+ "block.edition.display_user.logged": "Logados",
+ "block.edition.display_user.not_logged": "Não logados",
+ "block.edition.language.label": "Exibir para:"
}
diff --git a/src/lib/ng-noosfero-api/http/block.service.spec.ts b/src/lib/ng-noosfero-api/http/block.service.spec.ts
index 6407447..dd40469 100644
--- a/src/lib/ng-noosfero-api/http/block.service.spec.ts
+++ b/src/lib/ng-noosfero-api/http/block.service.spec.ts
@@ -29,6 +29,16 @@ describe("Services", () => {
});
$httpBackend.flush();
});
+
+ it("update block settings", (done) => {
+ let blockId = 1;
+ $httpBackend.expectPOST(`/api/v1/blocks/${blockId}`).respond(200, { block: { id: blockId } });
+ blockService.update({ id: blockId, display: 'never' }).then((result: noosfero.RestResult) => {
+ expect(result.data).toEqual({ id: blockId });
+ done();
+ });
+ $httpBackend.flush();
+ });
});
diff --git a/src/lib/ng-noosfero-api/http/block.service.ts b/src/lib/ng-noosfero-api/http/block.service.ts
index de768dd..944f22e 100644
--- a/src/lib/ng-noosfero-api/http/block.service.ts
+++ b/src/lib/ng-noosfero-api/http/block.service.ts
@@ -47,4 +47,12 @@ export class BlockService extends RestangularService {
return deferred.promise;
}
+ update(block: noosfero.Block) {
+ let element = this.getElement(block.id);
+ let headers = {
+ 'Content-Type': 'application/json'
+ };
+ return this.post(null, element, { block: block }, headers);
+ }
+
}
diff --git a/src/lib/ng-noosfero-api/http/restangular_service.ts b/src/lib/ng-noosfero-api/http/restangular_service.ts
index 75d063d..9f5c154 100644
--- a/src/lib/ng-noosfero-api/http/restangular_service.ts
+++ b/src/lib/ng-noosfero-api/http/restangular_service.ts
@@ -289,7 +289,7 @@ export abstract class RestangularService {
let restRequest: ng.IPromise;
if (rootElement) {
- restRequest = rootElement.customPOST(data, path, headers);
+ restRequest = rootElement.customPOST(data, path, null, headers);
} else {
restRequest = this.baseResource.customPOST(data, path, headers);
}
--
libgit2 0.21.2