Commit 2c05aa0258ce4157a05a8a41e72af8310ff56865
1 parent
9849cd64
Exists in
activities_block
add first steps for activities block
Signed-off-by: ArthurJahn <stutrzbecher@gmail.com> Signed-off-by: Artur Bersan de Faria <arturbersan@gmail.com>
Showing
13 changed files
with
206 additions
and
1 deletions
Show diff stats
src/app/layout/blocks/activities/activities-block.component.spec.ts
0 → 100644
... | ... | @@ -0,0 +1,36 @@ |
1 | +import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; | |
2 | +import {Pipe, Input, provide, Component} from 'ng-forward'; | |
3 | +import {provideFilters} from '../../../../spec/helpers'; | |
4 | + | |
5 | +import {ActivitiesBlockComponent} from './activities-block.component'; | |
6 | + | |
7 | +const tcb = new TestComponentBuilder(); | |
8 | + | |
9 | +const htmlTemplate: string = '<noosfero-activities [activities]="ctrl.activities"></noosfero-activities>'; | |
10 | + | |
11 | + | |
12 | +describe("Components", () => { | |
13 | + | |
14 | + describe("Noosfero Activities", () => { | |
15 | + | |
16 | + beforeEach(angular.mock.module("templates")); | |
17 | + | |
18 | + @Component({ | |
19 | + selector: 'test-container-component', | |
20 | + template: htmlTemplate, | |
21 | + directives: [ActivitiesBlockComponent], | |
22 | + providers: provideFilters("truncateFilter", "stripTagsFilter", "translateFilter") | |
23 | + }) | |
24 | + class BlockContainerComponent { | |
25 | + activities = [{ name: "activity1", verb: "create_article" }, { name: "activity2", verb: "create_article" }]; | |
26 | + } | |
27 | + | |
28 | + it("render a noosfero activity tag for each activity", done => { | |
29 | + tcb.createAsync(BlockContainerComponent).then(fixture => { | |
30 | + expect(fixture.debugElement.queryAll("noosfero-activity").length).toEqual(2); | |
31 | + done(); | |
32 | + }); | |
33 | + }); | |
34 | + }); | |
35 | + | |
36 | +}); | ... | ... |
src/app/layout/blocks/activities/activities-block.component.ts
0 → 100644
... | ... | @@ -0,0 +1,36 @@ |
1 | +import {Input, Inject, Component} from "ng-forward"; | |
2 | +import {ActivityComponent} from "./activity/activity.component"; | |
3 | +import {ProfileService} from "../../../../lib/ng-noosfero-api/http/profile.service"; | |
4 | + | |
5 | +/** | |
6 | + * @ngdoc controller | |
7 | + * @name NoosferoActivities | |
8 | + * @description | |
9 | + * The controller responsible to retreive profile activities. | |
10 | + */ | |
11 | + | |
12 | +@Component({ | |
13 | + selector: "noosfero-activities", | |
14 | + templateUrl: 'app/layout/blocks/activities/activities.html', | |
15 | + directives: [ActivityComponent] | |
16 | +}) | |
17 | + | |
18 | +@Inject(ProfileService) | |
19 | +export class ActivitiesBlockComponent { | |
20 | + | |
21 | + @Input() block: noosfero.Block; | |
22 | + @Input() owner: noosfero.Profile; | |
23 | + | |
24 | + activities: any; | |
25 | + | |
26 | + ngOnInit() { | |
27 | + let limit: number = ((this.block && this.block.settings) ? this.block.settings.limit : null) || 5; | |
28 | + return this.profileService.getActivities(<number>this.owner.id) | |
29 | + .then((response: restangular.IResponse) => { | |
30 | + this.activities = response.data.activities; | |
31 | + }); | |
32 | + } | |
33 | + | |
34 | + constructor(private profileService: ProfileService) { } | |
35 | + | |
36 | +} | ... | ... |
src/app/layout/blocks/activities/activity/activity.component.spec.ts
0 → 100644
... | ... | @@ -0,0 +1,38 @@ |
1 | +import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; | |
2 | +import {Pipe, Input, provide, Component} from 'ng-forward'; | |
3 | +import {provideFilters} from '../../../../../spec/helpers'; | |
4 | + | |
5 | +import {ActivityComponent} from './activity.component'; | |
6 | + | |
7 | +const tcb = new TestComponentBuilder(); | |
8 | + | |
9 | +const htmlTemplate: string = '<noosfero-activity [activity]="ctrl.activity"></noosfero-activity>'; | |
10 | + | |
11 | + | |
12 | +describe("Components", () => { | |
13 | + | |
14 | + describe("Noosfero Activity", () => { | |
15 | + | |
16 | + beforeEach(angular.mock.module("templates")); | |
17 | + | |
18 | + @Component({ | |
19 | + selector: 'test-container-component', | |
20 | + template: htmlTemplate, | |
21 | + directives: [ActivityComponent], | |
22 | + providers: provideFilters("truncateFilter", "stripTagsFilter", "translateFilter") | |
23 | + }) | |
24 | + class BlockContainerComponent { | |
25 | + activity = { name: "activity1", verb: "create_article" }; | |
26 | + } | |
27 | + | |
28 | + it("render the specific template for an activity verb", done => { | |
29 | + tcb.createAsync(BlockContainerComponent).then(fixture => { | |
30 | + let component: ActivityComponent = fixture.debugElement.componentViewChildren[0].componentInstance; | |
31 | + expect(component.getActivityTemplate()).toEqual('app/profile/activities/activity/create_article.html'); | |
32 | + expect(fixture.debugElement.queryAll(".activity.create_article").length).toEqual(1); | |
33 | + done(); | |
34 | + }); | |
35 | + }); | |
36 | + }); | |
37 | + | |
38 | +}); | ... | ... |
src/app/layout/blocks/activities/activity/activity.component.ts
0 → 100644
... | ... | @@ -0,0 +1,15 @@ |
1 | +import {Component, Input} from "ng-forward"; | |
2 | + | |
3 | +@Component({ | |
4 | + selector: "noosfero-activity", | |
5 | + templateUrl: 'app/profile/activities/activity/activity.html' | |
6 | +}) | |
7 | +export class ActivityComponent { | |
8 | + | |
9 | + @Input() activity: noosfero.Activity; | |
10 | + | |
11 | + getActivityTemplate() { | |
12 | + return 'app/profile/activities/activity/' + this.activity.verb + '.html'; | |
13 | + } | |
14 | + | |
15 | +} | ... | ... |
src/app/layout/blocks/activities/activity/add_member_in_community.html
0 → 100644
... | ... | @@ -0,0 +1,13 @@ |
1 | +<timeline-badge class="info"> | |
2 | + <i class="fa fa-user-plus"></i> | |
3 | +</timeline-badge> | |
4 | +<timeline-panel> | |
5 | + <timeline-heading> | |
6 | + <h4 class="timeline-title"> | |
7 | + <a ui-sref="main.profile.info({profile: ctrl.activity.user.identifier})"><strong ng-bind="ctrl.activity.user.name"></strong></a> | |
8 | + <span> {{"activities.add_member_in_community.description" | translate}}</span> | |
9 | + </h4> | |
10 | + <p><small class="text-muted"><i class="fa fa-clock-o"></i> <span am-time-ago="ctrl.activity.created_at | dateFormat"></span></small></p> | |
11 | + </timeline-heading> | |
12 | + <div class="timeline-body"></div> | |
13 | +</timeline-panel> | ... | ... |
src/app/layout/blocks/activities/activity/create_article.html
0 → 100644
... | ... | @@ -0,0 +1,26 @@ |
1 | +<timeline-badge class="success"> | |
2 | + <i class="fa fa-file-text"></i> | |
3 | +</timeline-badge> | |
4 | +<timeline-panel> | |
5 | + <timeline-heading> | |
6 | + <h4 class="timeline-title"> | |
7 | + <a ui-sref="main.profile.info({profile: ctrl.activity.user.identifier})"><strong ng-bind="ctrl.activity.user.name"></strong></a> | |
8 | + <span> {{"activities.create_article.description" | translate}} </span> | |
9 | + <a ui-sref="main.profile.info({profile: ctrl.activity.target.article.profile.identifier})"> | |
10 | + <strong ng-bind="ctrl.activity.target.article.profile.name"></strong></span> | |
11 | + </a> | |
12 | + </h4> | |
13 | + <p><small class="text-muted"><i class="fa fa-clock-o"></i> <span am-time-ago="ctrl.activity.created_at | dateFormat"></span></small></p> | |
14 | + </timeline-heading> | |
15 | + <div class="timeline-body"> | |
16 | + <div class="article"> | |
17 | + <div class="title"> | |
18 | + <a ui-sref="main.profile.page({profile: ctrl.activity.target.article.profile.identifier, page: ctrl.activity.target.article.path})" | |
19 | + ng-bind="ctrl.activity.target.article.title"></a> | |
20 | + </div> | |
21 | + <div class="lead small"> | |
22 | + <div ng-bind-html="ctrl.activity.target.article.body | stripTags | truncate: 100 : '...': true"></div> | |
23 | + </div> | |
24 | + </div> | |
25 | + </div> | |
26 | +</timeline-panel> | ... | ... |
src/app/layout/blocks/activities/activity/new_friendship.html
0 → 100644
... | ... | @@ -0,0 +1,18 @@ |
1 | +<timeline-badge class="info"> | |
2 | + <i class="fa fa-user-plus"></i> | |
3 | +</timeline-badge> | |
4 | +<timeline-panel> | |
5 | + <timeline-heading> | |
6 | + <h4 class="timeline-title"> | |
7 | + <a ui-sref="main.profile.info({profile: ctrl.activity.user.identifier})"><strong ng-bind="ctrl.activity.user.name"></strong></a> | |
8 | + <span> {{"activities.new_friendship.description" | translate:{friends: ctrl.activity.params.friend_name.length}:"messageformat" }} </span> | |
9 | + <span class="comma-separated"> | |
10 | + <a class="separated-item" ui-sref="main.profile.info({profile: ctrl.activity.params.friend_url[$index].profile})" ng-repeat="friend in ctrl.activity.params.friend_name"> | |
11 | + <strong ng-bind="friend"></strong> | |
12 | + </a> | |
13 | + </span> | |
14 | + </h4> | |
15 | + <p><small class="text-muted"><i class="fa fa-clock-o"></i> <span am-time-ago="ctrl.activity.created_at | dateFormat"></span></small></p> | |
16 | + </timeline-heading> | |
17 | + <div class="timeline-body"></div> | |
18 | +</timeline-panel> | ... | ... |
src/app/main/main.component.ts
... | ... | @@ -16,7 +16,7 @@ import {RecentDocumentsBlockComponent} from "../layout/blocks/recent-documents/r |
16 | 16 | import {ProfileImageBlockComponent} from "../layout/blocks/profile-image/profile-image-block.component"; |
17 | 17 | import {RawHTMLBlockComponent} from "../layout/blocks/raw-html/raw-html-block.component"; |
18 | 18 | import {StatisticsBlockComponent} from "../layout/blocks/statistics/statistics-block.component"; |
19 | - | |
19 | +import {ActivitiesBlockComponent} from "../layout/blocks/activities/activities-block.component"; | |
20 | 20 | import {MembersBlockComponent} from "../layout/blocks/members/members-block.component"; |
21 | 21 | import {CommunitiesBlockComponent} from "../layout/blocks/communities/communities-block.component"; |
22 | 22 | ... | ... |