Merge Request #64

Open
noosfero-themes/angular-theme!64
Created by Tallys Martins

Profile description block component

I Also made a MR to noosfero core to retrieve the profile description through the API. See the MR

Archived projects cannot be committed to!

Commits (1)
2 participants
src/app/layout/blocks/profile-description-block-plugin-profile-description-block/index.ts 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +/* Module Index Entry - generated using the script npm run generate-index */
  2 +export * from "./profile-description-block-plugin-profile-description-block.component";
... ...
src/app/layout/blocks/profile-description-block-plugin-profile-description-block/profile-description-block-plugin-profile-description-block.component.ts 0 → 100644
... ... @@ -0,0 +1,27 @@
  1 +import { Input, Inject, Component } from 'ng-forward';
  2 +import {BlockService} from "../../../../lib/ng-noosfero-api/http/block.service";
  3 +import {Arrays} from "./../../../../lib/util/arrays";
  4 +
  5 +@Component({
  6 + selector: 'noosfero-profile-description-block',
  7 + templateUrl: 'app/layout/blocks/profile-description-block-plugin-profile-description-block/profile-description-block-plugin-profile-description-block.html'
  8 +})
  9 +@Inject(BlockService, "$state")
  10 +export class ProfileDescriptionBlockPluginProfileDescriptionBlockComponent {
  11 +
  12 + @Input() block: any;
  13 + @Input() owner: any;
  14 +
  15 + profile: any;
  16 + description: any;
  17 +
  18 + constructor(private blockService: BlockService, private $state: any) { }
  19 +
  20 + ngOnInit() {
  21 + this.profile = this.owner;
  22 + this.blockService.getApiContent(this.block).then((content: any) => {
  23 + this.description = content.description;
  24 + });
  25 + console.log(this.description);
  26 + }
  27 +}
... ...
src/app/layout/blocks/profile-description-block-plugin-profile-description-block/profile-description-block-plugin-profile-description-block.html 0 → 100644
... ... @@ -0,0 +1 @@
  1 +<span class="profile-description"> {{ ctrl.description }} </span>
... ...
src/app/layout/blocks/profile-description-block-plugin-profile-description-block/profile-description-block-plugin-profile-description-block.spec.ts 0 → 100644
... ... @@ -0,0 +1,54 @@
  1 +import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder';
  2 +import {Provider, Input, provide, Component} from 'ng-forward';
  3 +import {provideFilters} from '../../../../spec/helpers';
  4 +import {ProfileDescriptionBlockPluginProfileDescriptionBlockComponent} from './profile-description-block-plugin-profile-description-block.component';
  5 +import * as helpers from "./../../../../spec/helpers";
  6 +
  7 +const htmlTemplate: string = '<noosfero-profile-description-block [block]="ctrl.block" [owner]="ctrl.owner"></noosfero-profile-description-block>';
  8 +
  9 +const tcb = new TestComponentBuilder();
  10 +
  11 +describe("Components", () => {
  12 + describe("Profile Description Block Component", () => {
  13 +
  14 + let person = <noosfero.Person>{ name: "Person" };
  15 + let mockedService = {
  16 + getApiContent: (block: noosfero.Block): any => {
  17 + return Promise.resolve({ description: "This is my description", headers: (name: string) => { return name; } });
  18 + }
  19 + };
  20 + beforeEach(angular.mock.module("templates"));
  21 +
  22 + let state = jasmine.createSpyObj("state", ["go"]);
  23 +
  24 + function getProviders() {
  25 + return [
  26 + new Provider('$state', { useValue: state }),
  27 + new Provider('BlockService', {
  28 + useValue: mockedService
  29 + })
  30 + ].concat(provideFilters("truncateFilter", "stripTagsFilter"));
  31 + }
  32 + let componentClass: any = null;
  33 +
  34 + function getComponent() {
  35 + @Component({ selector: 'test-container-component', template: htmlTemplate, directives: [ProfileDescriptionBlockPluginProfileDescriptionBlockComponent], providers: getProviders() })
  36 + class BlockContainerComponent {
  37 + block = { type: 'Block', settings: {} };
  38 + owner = person;
  39 + constructor() {
  40 + }
  41 + }
  42 + return BlockContainerComponent;
  43 + }
  44 +
  45 + it("get description from block service", done => {
  46 + tcb.createAsync(getComponent()).then(fixture => {
  47 + let ProfileDescriptionBlockPluginProfileDescriptionBlock: ProfileDescriptionBlockPluginProfileDescriptionBlockComponent = fixture.debugElement.componentViewChildren[0].componentInstance;
  48 + expect(ProfileDescriptionBlockPluginProfileDescriptionBlock.description).toEqual('This is my description');
  49 + done();
  50 + });
  51 + });
  52 +
  53 + });
  54 +});
... ...
src/app/layout/blocks/profile-description-block-plugin-profile-description-block/profile-descrpition-block-plugin-profile-description-block.scss 0 → 100644
src/app/main/main.component.ts
... ... @@ -22,6 +22,7 @@ import { TagsBlockComponent } from &quot;../layout/blocks/tags/tags-block.component&quot;;
22 22 import { CustomContentComponent } from "../profile/custom-content/custom-content.component";
23 23 import { RecentActivitiesPluginActivitiesBlockComponent } from "../layout/blocks/recent-activities-plugin-activities/recent-activities-plugin-activities-block.component";
24 24 import { ProfileImagesPluginProfileImagesBlockComponent } from "../layout/blocks/profile-images-plugin-profile-images/profile-images-plugin-profile-images-block.component";
  25 +import { ProfileDescriptionBlockPluginProfileDescriptionBlockComponent } from "../layout/blocks/profile-description-block-plugin-profile-description-block/profile-description-block-plugin-profile-description-block.component";
25 26 import { RegisterComponent } from "../account/register.component";
26 27  
27 28 import { MembersBlockComponent } from "../layout/blocks/members/members-block.component";
... ... @@ -120,7 +121,8 @@ export class EnvironmentContent {
120 121 MembersBlockComponent, NoosferoTemplate, DateFormat, RawHTMLBlockComponent, StatisticsBlockComponent,
121 122 LoginBlockComponent, CustomContentComponent, PermissionDirective, SearchFormComponent, SearchComponent,
122 123 PersonTagsPluginInterestsBlockComponent, TagsBlockComponent, RecentActivitiesPluginActivitiesBlockComponent,
123   - ProfileImagesPluginProfileImagesBlockComponent, BlockComponent, RegisterComponent, TasksMenuComponent, TaskListComponent
  124 + ProfileImagesPluginProfileImagesBlockComponent, BlockComponent, RegisterComponent, TasksMenuComponent, TaskListComponent,
  125 + ProfileDescriptionBlockPluginProfileDescriptionBlockComponent
124 126 ].concat(plugins.mainComponents).concat(plugins.hotspots),
125 127 providers: [AuthService, SessionService, NotificationService, BodyStateClassesService,
126 128 "ngAnimate", "ngCookies", "ngStorage", "ngTouch",
... ...