From 5cead4fce5a03c52849b3ea01ede62f74a77dcbb Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Thu, 3 Mar 2016 18:13:35 -0300 Subject: [PATCH] Migrate profile image block to ngforward --- src/app/components/noosfero-blocks/profile-image/profile-image.component.js | 22 ---------------------- src/app/components/noosfero-blocks/profile-image/profile-image.component.spec.ts | 37 +++++++++++++++++++++++++++++++++++++ src/app/components/noosfero-blocks/profile-image/profile-image.component.ts | 12 ++++++++++++ src/app/components/noosfero-blocks/profile-image/profile-image.html | 6 +++--- src/app/index.ts | 1 - src/app/main/main.component.ts | 3 ++- 6 files changed, 54 insertions(+), 27 deletions(-) delete mode 100644 src/app/components/noosfero-blocks/profile-image/profile-image.component.js create mode 100644 src/app/components/noosfero-blocks/profile-image/profile-image.component.spec.ts create mode 100644 src/app/components/noosfero-blocks/profile-image/profile-image.component.ts diff --git a/src/app/components/noosfero-blocks/profile-image/profile-image.component.js b/src/app/components/noosfero-blocks/profile-image/profile-image.component.js deleted file mode 100644 index 33946a1..0000000 --- a/src/app/components/noosfero-blocks/profile-image/profile-image.component.js +++ /dev/null @@ -1,22 +0,0 @@ -(function() { - 'use strict'; - - angular - .module('noosferoApp') - .component('noosferoProfileImageBlock', { - restrict: 'E', - templateUrl: 'app/components/noosfero-blocks/profile-image/profile-image.html', - bindings: { - block: '<', - owner: '<' - }, - controller: ProfileImageBlockController - }); - - /** @ngInject */ - function ProfileImageBlockController() { - var vm = this; - vm.profile = vm.owner; - } - -})(); diff --git a/src/app/components/noosfero-blocks/profile-image/profile-image.component.spec.ts b/src/app/components/noosfero-blocks/profile-image/profile-image.component.spec.ts new file mode 100644 index 0000000..f94465c --- /dev/null +++ b/src/app/components/noosfero-blocks/profile-image/profile-image.component.spec.ts @@ -0,0 +1,37 @@ +import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; +import {Pipe, Input, provide, Component} from 'ng-forward'; + +import {ProfileImageBlock} from './profile-image.component'; + +const tcb = new TestComponentBuilder(); + +const htmlTemplate: string = ''; + + +describe("Profile Image Block Component", () => { + + beforeEach(angular.mock.module("templates")); + + @Component({ selector: 'test-container-component', template: htmlTemplate, directives: [ProfileImageBlock] }) + class BlockContainerComponent { + block = { type: 'Block' }; + owner = { name: 'profile-name' }; + constructor() { + } + } + + it("render the profile image", done => { + tcb.createAsync(BlockContainerComponent).then(fixture => { + expect(fixture.debugElement.queryAll("noosfero-profile-image").length).toEqual(1); + done(); + }); + }); + + it("render the settings link", done => { + tcb.createAsync(BlockContainerComponent).then(fixture => { + expect(fixture.debugElement.queryAll(".settings-link").length).toEqual(1); + done(); + }); + }); + +}); diff --git a/src/app/components/noosfero-blocks/profile-image/profile-image.component.ts b/src/app/components/noosfero-blocks/profile-image/profile-image.component.ts new file mode 100644 index 0000000..12af5b6 --- /dev/null +++ b/src/app/components/noosfero-blocks/profile-image/profile-image.component.ts @@ -0,0 +1,12 @@ +import {Input, Component} from "ng-forward"; + +@Component({ + selector: "noosfero-profile-image-block", + templateUrl: 'app/components/noosfero-blocks/profile-image/profile-image.html', +}) +export class ProfileImageBlock { + + @Input() block: any; + @Input() owner: any; + +} diff --git a/src/app/components/noosfero-blocks/profile-image/profile-image.html b/src/app/components/noosfero-blocks/profile-image/profile-image.html index d7860da..b0fbe3c 100644 --- a/src/app/components/noosfero-blocks/profile-image/profile-image.html +++ b/src/app/components/noosfero-blocks/profile-image/profile-image.html @@ -1,6 +1,6 @@
- - + + - Control panel + Control panel
diff --git a/src/app/index.ts b/src/app/index.ts index 076f32d..8c42603 100644 --- a/src/app/index.ts +++ b/src/app/index.ts @@ -46,7 +46,6 @@ NoosferoApp.addController("AuthController", AuthController); require("./components/noosfero-activities/activities.component.js"); require("./components/noosfero-activities/activity/activity.component.js"); require("./components/noosfero-blocks/members-block/members-block.component.js"); -require("./components/noosfero-blocks/profile-image/profile-image.component.js"); require("./components/noosfero/noosfero-template.filter.js"); require("./components/noosfero/noosfero.service.js"); require("./components/noosfero/profile-image/profile-image.component.js"); diff --git a/src/app/main/main.component.ts b/src/app/main/main.component.ts index cb12d7f..8af368a 100644 --- a/src/app/main/main.component.ts +++ b/src/app/main/main.component.ts @@ -8,6 +8,7 @@ import {Boxes} from "../components/noosfero-boxes/boxes.component"; import {Block} from "../components/noosfero-blocks/block.component"; import {LinkListBlock} from "../components/noosfero-blocks/link-list/link-list.component"; import {RecentDocumentsBlock} from "../components/noosfero-blocks/recent-documents/recent-documents.component"; +import {ProfileImageBlock} from "../components/noosfero-blocks/profile-image/profile-image.component"; import {AuthService} from "./../components/auth/auth_service"; @@ -31,7 +32,7 @@ export class MainContent { @Component({ selector: 'main', template: '
', - directives: [NoosferoArticleBlog, ArticleView, Boxes, Block, LinkListBlock, MainBlock, RecentDocumentsBlock, Navbar], + directives: [NoosferoArticleBlog, ArticleView, Boxes, Block, LinkListBlock, MainBlock, RecentDocumentsBlock, Navbar, ProfileImageBlock], providers: [AuthService, Session] }) @StateConfig([ -- libgit2 0.21.2