Commit 5cead4fce5a03c52849b3ea01ede62f74a77dcbb

Authored by Victor Costa
1 parent d6ea8765

Migrate profile image block to ngforward

src/app/components/noosfero-blocks/profile-image/profile-image.component.js
... ... @@ -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 @@
  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 @@
  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 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 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 6 </div>
... ...
src/app/index.ts
... ... @@ -46,7 +46,6 @@ NoosferoApp.addController(&quot;AuthController&quot;, AuthController);
46 46 require("./components/noosfero-activities/activities.component.js");
47 47 require("./components/noosfero-activities/activity/activity.component.js");
48 48 require("./components/noosfero-blocks/members-block/members-block.component.js");
49   -require("./components/noosfero-blocks/profile-image/profile-image.component.js");
50 49 require("./components/noosfero/noosfero-template.filter.js");
51 50 require("./components/noosfero/noosfero.service.js");
52 51 require("./components/noosfero/profile-image/profile-image.component.js");
... ...
src/app/main/main.component.ts
... ... @@ -8,6 +8,7 @@ import {Boxes} from &quot;../components/noosfero-boxes/boxes.component&quot;;
8 8 import {Block} from "../components/noosfero-blocks/block.component";
9 9 import {LinkListBlock} from "../components/noosfero-blocks/link-list/link-list.component";
10 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 14 import {AuthService} from "./../components/auth/auth_service";
... ... @@ -31,7 +32,7 @@ export class MainContent {
31 32 @Component({
32 33 selector: 'main',
33 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 36 providers: [AuthService, Session]
36 37 })
37 38 @StateConfig([
... ...