Commit bcf376e35e8af51e6e2488fc685b969f65e1ce45
1 parent
36470e94
Exists in
master
and in
1 other branch
Added people block
Showing
5 changed files
with
103 additions
and
0 deletions
Show diff stats
src/app/layout/blocks/people-block/people-block.component.spec.ts
0 → 100644
... | ... | @@ -0,0 +1,53 @@ |
1 | +import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; | |
2 | +import {Provider, Input, provide, Component} from 'ng-forward'; | |
3 | + | |
4 | +import {PeopleBlockComponent} from './people-block.component'; | |
5 | + | |
6 | +const htmlTemplate: string = '<noosfero-people-block [block]="ctrl.block" [owner]="ctrl.owner"></noosfero-people-block>'; | |
7 | + | |
8 | +const tcb = new TestComponentBuilder(); | |
9 | + | |
10 | +describe("Components", () => { | |
11 | + describe("People Block Component", () => { | |
12 | + | |
13 | + beforeEach(angular.mock.module("templates")); | |
14 | + | |
15 | + let state = jasmine.createSpyObj("state", ["go"]); | |
16 | + let providers = [ | |
17 | + new Provider('truncateFilter', { useValue: () => { } }), | |
18 | + new Provider('stripTagsFilter', { useValue: () => { } }), | |
19 | + new Provider('$state', { useValue: state }), | |
20 | + new Provider('ProfileService', { | |
21 | + useValue: { | |
22 | + getProfileMembers: (profileId: number, filters: any): any => { | |
23 | + return Promise.resolve({ data: { people: [{ identifier: "person1" }] } }); | |
24 | + } | |
25 | + } | |
26 | + }), | |
27 | + ]; | |
28 | + @Component({ selector: 'test-container-component', template: htmlTemplate, directives: [PeopleBlockComponent], providers: providers }) | |
29 | + class BlockContainerComponent { | |
30 | + block = { type: 'Block', settings: {} }; | |
31 | + owner = { name: 'profile-name' }; | |
32 | + constructor() { | |
33 | + } | |
34 | + } | |
35 | + | |
36 | + it("get people of the block owner", done => { | |
37 | + tcb.createAsync(BlockContainerComponent).then(fixture => { | |
38 | + let block: PeopleBlockComponent = fixture.debugElement.componentViewChildren[0].componentInstance; | |
39 | + expect(block.people).toEqual([{ identifier: "person1" }]); | |
40 | + done(); | |
41 | + }); | |
42 | + }); | |
43 | + | |
44 | + it("render the profile image for each person", done => { | |
45 | + tcb.createAsync(BlockContainerComponent).then(fixture => { | |
46 | + fixture.debugElement.getLocal("$rootScope").$apply(); | |
47 | + expect(fixture.debugElement.queryAll("noosfero-profile-image").length).toEqual(1); | |
48 | + done(); | |
49 | + }); | |
50 | + }); | |
51 | + | |
52 | + }); | |
53 | +}); | |
0 | 54 | \ No newline at end of file | ... | ... |
src/app/layout/blocks/people-block/people-block.component.ts
0 → 100644
... | ... | @@ -0,0 +1,26 @@ |
1 | +import {Input, Inject, Component} from "ng-forward"; | |
2 | +import {EnvironmentService} from "../../../../lib/ng-noosfero-api/http/environment.service"; | |
3 | + | |
4 | +@Component({ | |
5 | + selector: "noosfero-people-block", | |
6 | + templateUrl: 'app/layout/blocks/people-block/people-block.html', | |
7 | +}) | |
8 | +@Inject(EnvironmentService) | |
9 | +export class PeopleBlockComponent { | |
10 | + | |
11 | + @Input() block: noosfero.Block; | |
12 | + @Input() owner: noosfero.Environment; | |
13 | + | |
14 | + people: noosfero.Person[] = []; | |
15 | + | |
16 | + constructor(private environmentService: EnvironmentService) { | |
17 | + console.debug("Created PeopleBlockComponent"); | |
18 | + } | |
19 | + | |
20 | + ngOnInit() { | |
21 | + this.environmentService.getEnvironmentPeople({ limit: '6' }).then((people: noosfero.Person[]) => { | |
22 | + console.debug("People returned in PeopleBlockComponent: ", people); | |
23 | + this.people = people; | |
24 | + }); | |
25 | + } | |
26 | +} | ... | ... |
... | ... | @@ -0,0 +1,17 @@ |
1 | +.members-block { | |
2 | + .member { | |
3 | + img, i.profile-image { | |
4 | + width: 60px; | |
5 | + } | |
6 | + img { | |
7 | + display: inline-block; | |
8 | + vertical-align: top; | |
9 | + } | |
10 | + i.profile-image { | |
11 | + text-align: center; | |
12 | + background-color: #889DB1; | |
13 | + color: #F1F1F1; | |
14 | + font-size: 4.5em; | |
15 | + } | |
16 | + } | |
17 | +} | ... | ... |