Commit 5cead4fce5a03c52849b3ea01ede62f74a77dcbb
1 parent
d6ea8765
Exists in
master
and in
35 other branches
Migrate profile image block to ngforward
Showing
6 changed files
with
54 additions
and
27 deletions
Show diff stats
src/app/components/noosfero-blocks/profile-image/profile-image.component.js
@@ -1,22 +0,0 @@ | @@ -1,22 +0,0 @@ | ||
1 | -(function() { | ||
2 | - 'use strict'; | ||
3 | - | ||
4 | - angular | ||
5 | - .module('noosferoApp') | ||
6 | - .component('noosferoProfileImageBlock', { | ||
7 | - restrict: 'E', | ||
8 | - templateUrl: 'app/components/noosfero-blocks/profile-image/profile-image.html', | ||
9 | - bindings: { | ||
10 | - block: '<', | ||
11 | - owner: '<' | ||
12 | - }, | ||
13 | - controller: ProfileImageBlockController | ||
14 | - }); | ||
15 | - | ||
16 | - /** @ngInject */ | ||
17 | - function ProfileImageBlockController() { | ||
18 | - var vm = this; | ||
19 | - vm.profile = vm.owner; | ||
20 | - } | ||
21 | - | ||
22 | -})(); |
src/app/components/noosfero-blocks/profile-image/profile-image.component.spec.ts
0 → 100644
@@ -0,0 +1,37 @@ | @@ -0,0 +1,37 @@ | ||
1 | +import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; | ||
2 | +import {Pipe, Input, provide, Component} from 'ng-forward'; | ||
3 | + | ||
4 | +import {ProfileImageBlock} from './profile-image.component'; | ||
5 | + | ||
6 | +const tcb = new TestComponentBuilder(); | ||
7 | + | ||
8 | +const htmlTemplate: string = '<noosfero-profile-image-block [block]="ctrl.block" [owner]="ctrl.owner"></noosfero-profile-image-block>'; | ||
9 | + | ||
10 | + | ||
11 | +describe("Profile Image Block Component", () => { | ||
12 | + | ||
13 | + beforeEach(angular.mock.module("templates")); | ||
14 | + | ||
15 | + @Component({ selector: 'test-container-component', template: htmlTemplate, directives: [ProfileImageBlock] }) | ||
16 | + class BlockContainerComponent { | ||
17 | + block = { type: 'Block' }; | ||
18 | + owner = { name: 'profile-name' }; | ||
19 | + constructor() { | ||
20 | + } | ||
21 | + } | ||
22 | + | ||
23 | + it("render the profile image", done => { | ||
24 | + tcb.createAsync(BlockContainerComponent).then(fixture => { | ||
25 | + expect(fixture.debugElement.queryAll("noosfero-profile-image").length).toEqual(1); | ||
26 | + done(); | ||
27 | + }); | ||
28 | + }); | ||
29 | + | ||
30 | + it("render the settings link", done => { | ||
31 | + tcb.createAsync(BlockContainerComponent).then(fixture => { | ||
32 | + expect(fixture.debugElement.queryAll(".settings-link").length).toEqual(1); | ||
33 | + done(); | ||
34 | + }); | ||
35 | + }); | ||
36 | + | ||
37 | +}); |
src/app/components/noosfero-blocks/profile-image/profile-image.component.ts
0 → 100644
@@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
1 | +import {Input, Component} from "ng-forward"; | ||
2 | + | ||
3 | +@Component({ | ||
4 | + selector: "noosfero-profile-image-block", | ||
5 | + templateUrl: 'app/components/noosfero-blocks/profile-image/profile-image.html', | ||
6 | +}) | ||
7 | +export class ProfileImageBlock { | ||
8 | + | ||
9 | + @Input() block: any; | ||
10 | + @Input() owner: any; | ||
11 | + | ||
12 | +} |
src/app/components/noosfero-blocks/profile-image/profile-image.html
1 | <div class="center-block text-center profile-image-block"> | 1 | <div class="center-block text-center profile-image-block"> |
2 | - <a ui-sref="main.profile.info({profile: $ctrl.owner.identifier})"> | ||
3 | - <noosfero-profile-image profile="$ctrl.owner"></noosfero-profile-image> | 2 | + <a ui-sref="main.profile.info({profile: ctrl.owner.identifier})"> |
3 | + <noosfero-profile-image profile="ctrl.owner"></noosfero-profile-image> | ||
4 | </a> | 4 | </a> |
5 | - <a class="settings-link" target="_self" ui-sref="main.profile.settings({profile: $ctrl.owner.identifier})">Control panel</a> | 5 | + <a class="settings-link" target="_self" ui-sref="main.profile.settings({profile: ctrl.owner.identifier})">Control panel</a> |
6 | </div> | 6 | </div> |
src/app/index.ts
@@ -46,7 +46,6 @@ NoosferoApp.addController("AuthController", AuthController); | @@ -46,7 +46,6 @@ NoosferoApp.addController("AuthController", AuthController); | ||
46 | require("./components/noosfero-activities/activities.component.js"); | 46 | require("./components/noosfero-activities/activities.component.js"); |
47 | require("./components/noosfero-activities/activity/activity.component.js"); | 47 | require("./components/noosfero-activities/activity/activity.component.js"); |
48 | require("./components/noosfero-blocks/members-block/members-block.component.js"); | 48 | require("./components/noosfero-blocks/members-block/members-block.component.js"); |
49 | -require("./components/noosfero-blocks/profile-image/profile-image.component.js"); | ||
50 | require("./components/noosfero/noosfero-template.filter.js"); | 49 | require("./components/noosfero/noosfero-template.filter.js"); |
51 | require("./components/noosfero/noosfero.service.js"); | 50 | require("./components/noosfero/noosfero.service.js"); |
52 | require("./components/noosfero/profile-image/profile-image.component.js"); | 51 | require("./components/noosfero/profile-image/profile-image.component.js"); |
src/app/main/main.component.ts
@@ -8,6 +8,7 @@ import {Boxes} from "../components/noosfero-boxes/boxes.component"; | @@ -8,6 +8,7 @@ import {Boxes} from "../components/noosfero-boxes/boxes.component"; | ||
8 | import {Block} from "../components/noosfero-blocks/block.component"; | 8 | import {Block} from "../components/noosfero-blocks/block.component"; |
9 | import {LinkListBlock} from "../components/noosfero-blocks/link-list/link-list.component"; | 9 | import {LinkListBlock} from "../components/noosfero-blocks/link-list/link-list.component"; |
10 | import {RecentDocumentsBlock} from "../components/noosfero-blocks/recent-documents/recent-documents.component"; | 10 | import {RecentDocumentsBlock} from "../components/noosfero-blocks/recent-documents/recent-documents.component"; |
11 | +import {ProfileImageBlock} from "../components/noosfero-blocks/profile-image/profile-image.component"; | ||
11 | 12 | ||
12 | 13 | ||
13 | import {AuthService} from "./../components/auth/auth_service"; | 14 | import {AuthService} from "./../components/auth/auth_service"; |
@@ -31,7 +32,7 @@ export class MainContent { | @@ -31,7 +32,7 @@ export class MainContent { | ||
31 | @Component({ | 32 | @Component({ |
32 | selector: 'main', | 33 | selector: 'main', |
33 | template: '<div ng-view></div>', | 34 | template: '<div ng-view></div>', |
34 | - directives: [NoosferoArticleBlog, ArticleView, Boxes, Block, LinkListBlock, MainBlock, RecentDocumentsBlock, Navbar], | 35 | + directives: [NoosferoArticleBlog, ArticleView, Boxes, Block, LinkListBlock, MainBlock, RecentDocumentsBlock, Navbar, ProfileImageBlock], |
35 | providers: [AuthService, Session] | 36 | providers: [AuthService, Session] |
36 | }) | 37 | }) |
37 | @StateConfig([ | 38 | @StateConfig([ |