diff --git a/src/app/layout/blocks/activities/activities-block.component.spec.ts b/src/app/layout/blocks/activities/activities-block.component.spec.ts new file mode 100644 index 0000000..e8c2c28 --- /dev/null +++ b/src/app/layout/blocks/activities/activities-block.component.spec.ts @@ -0,0 +1,36 @@ +import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; +import {Pipe, Input, provide, Component} from 'ng-forward'; +import {provideFilters} from '../../../../spec/helpers'; + +import {ActivitiesBlockComponent} from './activities-block.component'; + +const tcb = new TestComponentBuilder(); + +const htmlTemplate: string = ''; + + +describe("Components", () => { + + describe("Noosfero Activities", () => { + + beforeEach(angular.mock.module("templates")); + + @Component({ + selector: 'test-container-component', + template: htmlTemplate, + directives: [ActivitiesBlockComponent], + providers: provideFilters("truncateFilter", "stripTagsFilter", "translateFilter") + }) + class BlockContainerComponent { + activities = [{ name: "activity1", verb: "create_article" }, { name: "activity2", verb: "create_article" }]; + } + + it("render a noosfero activity tag for each activity", done => { + tcb.createAsync(BlockContainerComponent).then(fixture => { + expect(fixture.debugElement.queryAll("noosfero-activity").length).toEqual(2); + done(); + }); + }); + }); + +}); diff --git a/src/app/layout/blocks/activities/activities-block.component.ts b/src/app/layout/blocks/activities/activities-block.component.ts new file mode 100644 index 0000000..068475e --- /dev/null +++ b/src/app/layout/blocks/activities/activities-block.component.ts @@ -0,0 +1,36 @@ +import {Input, Inject, Component} from "ng-forward"; +import {ActivityComponent} from "./activity/activity.component"; +import {ProfileService} from "../../../../lib/ng-noosfero-api/http/profile.service"; + +/** + * @ngdoc controller + * @name NoosferoActivities + * @description + * The controller responsible to retreive profile activities. + */ + +@Component({ + selector: "noosfero-activities", + templateUrl: 'app/layout/blocks/activities/activities.html', + directives: [ActivityComponent] +}) + +@Inject(ProfileService) +export class ActivitiesBlockComponent { + + @Input() block: noosfero.Block; + @Input() owner: noosfero.Profile; + + activities: any; + + ngOnInit() { + let limit: number = ((this.block && this.block.settings) ? this.block.settings.limit : null) || 5; + return this.profileService.getActivities(this.owner.id) + .then((response: restangular.IResponse) => { + this.activities = response.data.activities; + }); + } + + constructor(private profileService: ProfileService) { } + +} diff --git a/src/app/layout/blocks/activities/activities-block.html b/src/app/layout/blocks/activities/activities-block.html new file mode 100644 index 0000000..f99e3e3 --- /dev/null +++ b/src/app/layout/blocks/activities/activities-block.html @@ -0,0 +1,5 @@ + + + + + diff --git a/src/app/layout/blocks/activities/activities-block.scss b/src/app/layout/blocks/activities/activities-block.scss new file mode 100644 index 0000000..88982c9 --- /dev/null +++ b/src/app/layout/blocks/activities/activities-block.scss @@ -0,0 +1,11 @@ +.comma-separated { + .separated-item { + &:after { + content: ", "; + margin-left: -3px; + } + &:last-child:after { + content: ""; + } + } +} diff --git a/src/app/layout/blocks/activities/activity/activity.component.spec.ts b/src/app/layout/blocks/activities/activity/activity.component.spec.ts new file mode 100644 index 0000000..3e1afbc --- /dev/null +++ b/src/app/layout/blocks/activities/activity/activity.component.spec.ts @@ -0,0 +1,38 @@ +import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; +import {Pipe, Input, provide, Component} from 'ng-forward'; +import {provideFilters} from '../../../../../spec/helpers'; + +import {ActivityComponent} from './activity.component'; + +const tcb = new TestComponentBuilder(); + +const htmlTemplate: string = ''; + + +describe("Components", () => { + + describe("Noosfero Activity", () => { + + beforeEach(angular.mock.module("templates")); + + @Component({ + selector: 'test-container-component', + template: htmlTemplate, + directives: [ActivityComponent], + providers: provideFilters("truncateFilter", "stripTagsFilter", "translateFilter") + }) + class BlockContainerComponent { + activity = { name: "activity1", verb: "create_article" }; + } + + it("render the specific template for an activity verb", done => { + tcb.createAsync(BlockContainerComponent).then(fixture => { + let component: ActivityComponent = fixture.debugElement.componentViewChildren[0].componentInstance; + expect(component.getActivityTemplate()).toEqual('app/profile/activities/activity/create_article.html'); + expect(fixture.debugElement.queryAll(".activity.create_article").length).toEqual(1); + done(); + }); + }); + }); + +}); diff --git a/src/app/layout/blocks/activities/activity/activity.component.ts b/src/app/layout/blocks/activities/activity/activity.component.ts new file mode 100644 index 0000000..6ec700e --- /dev/null +++ b/src/app/layout/blocks/activities/activity/activity.component.ts @@ -0,0 +1,15 @@ +import {Component, Input} from "ng-forward"; + +@Component({ + selector: "noosfero-activity", + templateUrl: 'app/profile/activities/activity/activity.html' +}) +export class ActivityComponent { + + @Input() activity: noosfero.Activity; + + getActivityTemplate() { + return 'app/profile/activities/activity/' + this.activity.verb + '.html'; + } + +} diff --git a/src/app/layout/blocks/activities/activity/activity.html b/src/app/layout/blocks/activities/activity/activity.html new file mode 100644 index 0000000..0bcc9b7 --- /dev/null +++ b/src/app/layout/blocks/activities/activity/activity.html @@ -0,0 +1,3 @@ +
+ +
diff --git a/src/app/layout/blocks/activities/activity/add_member_in_community.html b/src/app/layout/blocks/activities/activity/add_member_in_community.html new file mode 100644 index 0000000..b97512f --- /dev/null +++ b/src/app/layout/blocks/activities/activity/add_member_in_community.html @@ -0,0 +1,13 @@ + + + + + +

+ + {{"activities.add_member_in_community.description" | translate}} +

+

+
+
+
diff --git a/src/app/layout/blocks/activities/activity/create_article.html b/src/app/layout/blocks/activities/activity/create_article.html new file mode 100644 index 0000000..791ef13 --- /dev/null +++ b/src/app/layout/blocks/activities/activity/create_article.html @@ -0,0 +1,26 @@ + + + + + +

+ + {{"activities.create_article.description" | translate}} + + + +

+

+
+
+
+
+ +
+
+
+
+
+
+
diff --git a/src/app/layout/blocks/activities/activity/index.ts b/src/app/layout/blocks/activities/activity/index.ts new file mode 100644 index 0000000..4342b8e --- /dev/null +++ b/src/app/layout/blocks/activities/activity/index.ts @@ -0,0 +1,2 @@ +/* Module Index Entry - generated using the script npm run generate-index */ +export * from "./activity.component"; diff --git a/src/app/layout/blocks/activities/activity/new_friendship.html b/src/app/layout/blocks/activities/activity/new_friendship.html new file mode 100644 index 0000000..c19d66d --- /dev/null +++ b/src/app/layout/blocks/activities/activity/new_friendship.html @@ -0,0 +1,18 @@ + + + + + +

+ + {{"activities.new_friendship.description" | translate:{friends: ctrl.activity.params.friend_name.length}:"messageformat" }} + + + + + +

+

+
+
+
diff --git a/src/app/layout/blocks/activities/index.ts b/src/app/layout/blocks/activities/index.ts new file mode 100644 index 0000000..5d41761 --- /dev/null +++ b/src/app/layout/blocks/activities/index.ts @@ -0,0 +1,2 @@ +/* Module Index Entry - generated using the script npm run generate-index */ +export * from "./activities-block.component"; diff --git a/src/app/main/main.component.ts b/src/app/main/main.component.ts index 9519618..0840830 100644 --- a/src/app/main/main.component.ts +++ b/src/app/main/main.component.ts @@ -16,7 +16,7 @@ import {RecentDocumentsBlockComponent} from "../layout/blocks/recent-documents/r import {ProfileImageBlockComponent} from "../layout/blocks/profile-image/profile-image-block.component"; import {RawHTMLBlockComponent} from "../layout/blocks/raw-html/raw-html-block.component"; import {StatisticsBlockComponent} from "../layout/blocks/statistics/statistics-block.component"; - +import {ActivitiesBlockComponent} from "../layout/blocks/activities/activities-block.component"; import {MembersBlockComponent} from "../layout/blocks/members/members-block.component"; import {CommunitiesBlockComponent} from "../layout/blocks/communities/communities-block.component"; -- libgit2 0.21.2