Commit 41eb8af1e2952abe13039ed2970dfaa4d74fd5c7
1 parent
d948a68c
Add component to list tasks
Showing
17 changed files
with
198 additions
and
60 deletions
Show diff stats
src/app/main/main.component.ts
@@ -47,6 +47,7 @@ import { PermissionDirective } from "../shared/components/permission/permission. | @@ -47,6 +47,7 @@ import { PermissionDirective } from "../shared/components/permission/permission. | ||
47 | import { SearchComponent } from "../search/search.component"; | 47 | import { SearchComponent } from "../search/search.component"; |
48 | import { SearchFormComponent } from "../search/search-form/search-form.component"; | 48 | import { SearchFormComponent } from "../search/search-form/search-form.component"; |
49 | import { TasksMenuComponent } from "../task/tasks-menu/tasks-menu.component"; | 49 | import { TasksMenuComponent } from "../task/tasks-menu/tasks-menu.component"; |
50 | +import { TaskListComponent } from "../task/task-list/task-list.component"; | ||
50 | 51 | ||
51 | /** | 52 | /** |
52 | * @ngdoc controller | 53 | * @ngdoc controller |
@@ -109,7 +110,7 @@ export class EnvironmentContent { | @@ -109,7 +110,7 @@ export class EnvironmentContent { | ||
109 | MembersBlockComponent, NoosferoTemplate, DateFormat, RawHTMLBlockComponent, StatisticsBlockComponent, | 110 | MembersBlockComponent, NoosferoTemplate, DateFormat, RawHTMLBlockComponent, StatisticsBlockComponent, |
110 | LoginBlockComponent, CustomContentComponent, PermissionDirective, SearchFormComponent, SearchComponent, | 111 | LoginBlockComponent, CustomContentComponent, PermissionDirective, SearchFormComponent, SearchComponent, |
111 | PersonTagsPluginInterestsBlockComponent, TagsBlockComponent, RecentActivitiesPluginActivitiesBlockComponent, BlockComponent, | 112 | PersonTagsPluginInterestsBlockComponent, TagsBlockComponent, RecentActivitiesPluginActivitiesBlockComponent, BlockComponent, |
112 | - TasksMenuComponent | 113 | + TasksMenuComponent, TaskListComponent |
113 | ].concat(plugins.mainComponents).concat(plugins.hotspots), | 114 | ].concat(plugins.mainComponents).concat(plugins.hotspots), |
114 | providers: [AuthService, SessionService, NotificationService, BodyStateClassesService, | 115 | providers: [AuthService, SessionService, NotificationService, BodyStateClassesService, |
115 | "ngAnimate", "ngCookies", "ngStorage", "ngTouch", | 116 | "ngAnimate", "ngCookies", "ngStorage", "ngTouch", |
src/app/profile/profile.component.ts
1 | -import {StateConfig, Component, Inject, provide} from 'ng-forward'; | ||
2 | -import {ProfileInfoComponent} from './info/profile-info.component'; | ||
3 | -import {ProfileHomeComponent} from './profile-home.component'; | ||
4 | -import {BasicEditorComponent} from '../article/cms/basic-editor/basic-editor.component'; | ||
5 | -import {CmsComponent} from '../article/cms/cms.component'; | ||
6 | -import {ContentViewerComponent} from "../article/content-viewer/content-viewer.component"; | ||
7 | -import {ContentViewerActionsComponent} from "../article/content-viewer/content-viewer-actions.component"; | ||
8 | -import {ActivitiesComponent} from "./activities/activities.component"; | ||
9 | -import {ProfileService} from "../../lib/ng-noosfero-api/http/profile.service"; | ||
10 | -import {NotificationService} from "../shared/services/notification.service"; | ||
11 | -import {MyProfileComponent} from "./myprofile.component"; | ||
12 | -import {ProfileActionsComponent} from "./profile-actions.component"; | ||
13 | -import {ConfigBarComponent} from "./config-bar.component"; | 1 | +import { StateConfig, Component, Inject, provide } from 'ng-forward'; |
2 | +import { ProfileInfoComponent } from './info/profile-info.component'; | ||
3 | +import { ProfileHomeComponent } from './profile-home.component'; | ||
4 | +import { BasicEditorComponent } from '../article/cms/basic-editor/basic-editor.component'; | ||
5 | +import { CmsComponent } from '../article/cms/cms.component'; | ||
6 | +import { ContentViewerComponent } from "../article/content-viewer/content-viewer.component"; | ||
7 | +import { ContentViewerActionsComponent } from "../article/content-viewer/content-viewer-actions.component"; | ||
8 | +import { ActivitiesComponent } from "./activities/activities.component"; | ||
9 | +import { ProfileService } from "../../lib/ng-noosfero-api/http/profile.service"; | ||
10 | +import { NotificationService } from "../shared/services/notification.service"; | ||
11 | +import { MyProfileComponent } from "./myprofile.component"; | ||
12 | +import { ProfileActionsComponent } from "./profile-actions.component"; | ||
13 | +import { ConfigBarComponent } from "./config-bar.component"; | ||
14 | +import { TasksComponent } from "../task/tasks/tasks.component"; | ||
15 | + | ||
14 | /** | 16 | /** |
15 | * @ngdoc controller | 17 | * @ngdoc controller |
16 | * @name profile.Profile | 18 | * @name profile.Profile |
@@ -92,6 +94,18 @@ import {ConfigBarComponent} from "./config-bar.component"; | @@ -92,6 +94,18 @@ import {ConfigBarComponent} from "./config-bar.component"; | ||
92 | } | 94 | } |
93 | }, | 95 | }, |
94 | { | 96 | { |
97 | + name: 'main.profile.tasks', | ||
98 | + url: "^/myprofile/:profile/tasks", | ||
99 | + component: TasksComponent, | ||
100 | + views: { | ||
101 | + "mainBlockContent": { | ||
102 | + templateUrl: "app/task/tasks/tasks.html", | ||
103 | + controller: TasksComponent, | ||
104 | + controllerAs: "vm" | ||
105 | + } | ||
106 | + } | ||
107 | + }, | ||
108 | + { | ||
95 | name: 'main.profile.home', | 109 | name: 'main.profile.home', |
96 | url: "", | 110 | url: "", |
97 | component: ProfileHomeComponent, | 111 | component: ProfileHomeComponent, |
@@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
1 | +import { Component, Input } from "ng-forward"; | ||
2 | + | ||
3 | +@Component({ | ||
4 | + selector: "task-list", | ||
5 | + templateUrl: "app/task/task-list/task-list.html", | ||
6 | +}) | ||
7 | +export class TaskListComponent { | ||
8 | + | ||
9 | + @Input() tasks: noosfero.Task[]; | ||
10 | + | ||
11 | + private taskTemplates = ["AddFriend", "AddMember", "CreateCommunity"]; | ||
12 | + | ||
13 | + getTaskTemplate(task: noosfero.Task) { | ||
14 | + if (this.taskTemplates.indexOf(task.type) >= 0) { | ||
15 | + return 'app/task/types/' + task.type + '.html'; | ||
16 | + } else { | ||
17 | + return 'app/task/types/default.html'; | ||
18 | + } | ||
19 | + } | ||
20 | +} |
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +<ul class="task-list"> | ||
2 | + <li class="task-group" ng-repeat="(target, tasks) in ctrl.tasks | groupBy: 'target.name'"> | ||
3 | + <div class="task-target"> | ||
4 | + <noosfero-profile-image ng-if="tasks[0].target.type" [profile]="tasks[0].target"></noosfero-profile-image> | ||
5 | + <div class="target-name">{{target}}</div> | ||
6 | + </div> | ||
7 | + <div class="task-body" ng-repeat="task in tasks | orderBy: 'created_at':true"> | ||
8 | + <div class="task"> | ||
9 | + <ng-include src="ctrl.getTaskTemplate(task)"></ng-include> | ||
10 | + </div> | ||
11 | + <span class="time"> | ||
12 | + <span class="bullet-separator">•</span> <span am-time-ago="task.created_at | dateFormat"></span> | ||
13 | + </span> | ||
14 | + </div> | ||
15 | + </li> | ||
16 | +</ul> |
@@ -0,0 +1,47 @@ | @@ -0,0 +1,47 @@ | ||
1 | +.task-list { | ||
2 | + width: 100%; | ||
3 | + padding: 0; | ||
4 | + list-style-type: none; | ||
5 | + .task-group { | ||
6 | + border-top: 1px solid #f3f3f3; | ||
7 | + padding: 4px 16px 8px 16px; | ||
8 | + } | ||
9 | + .task-target { | ||
10 | + margin-top: 12px; | ||
11 | + .profile-image { | ||
12 | + color: #2c3e50; | ||
13 | + font-size: 25px; | ||
14 | + width: 25px; | ||
15 | + display: inline-block; | ||
16 | + @extend .img-rounded; | ||
17 | + } | ||
18 | + .target-name { | ||
19 | + display: inline-block; | ||
20 | + margin-left: 10px; | ||
21 | + font-size: 18px; | ||
22 | + font-weight: bold; | ||
23 | + } | ||
24 | + } | ||
25 | + .task-body { | ||
26 | + margin-left: 35px; | ||
27 | + padding: 3px; | ||
28 | + .task { | ||
29 | + display: inline-block; | ||
30 | + .task-icon { | ||
31 | + font-size: 18px; | ||
32 | + color: #e84e40; | ||
33 | + } | ||
34 | + .requestor, .target { | ||
35 | + font-style: italic; | ||
36 | + } | ||
37 | + } | ||
38 | + .time { | ||
39 | + color: #c1c1c1; | ||
40 | + font-size: 12px; | ||
41 | + .bullet-separator { | ||
42 | + font-size: 10px; | ||
43 | + color: #d1d1d1; | ||
44 | + } | ||
45 | + } | ||
46 | + } | ||
47 | +} |
src/app/task/tasks-menu/tasks-menu.component.ts
1 | import { Component, Inject } from "ng-forward"; | 1 | import { Component, Inject } from "ng-forward"; |
2 | import { TaskService } from "../../../lib/ng-noosfero-api/http/task.service"; | 2 | import { TaskService } from "../../../lib/ng-noosfero-api/http/task.service"; |
3 | +import { SessionService } from "./../../login"; | ||
3 | 4 | ||
4 | @Component({ | 5 | @Component({ |
5 | selector: "tasks-menu", | 6 | selector: "tasks-menu", |
6 | templateUrl: "app/task/tasks-menu/tasks-menu.html" | 7 | templateUrl: "app/task/tasks-menu/tasks-menu.html" |
7 | }) | 8 | }) |
8 | -@Inject(TaskService) | 9 | +@Inject(TaskService, SessionService) |
9 | export class TasksMenuComponent { | 10 | export class TasksMenuComponent { |
10 | 11 | ||
11 | tasks: noosfero.Task[]; | 12 | tasks: noosfero.Task[]; |
12 | total: number; | 13 | total: number; |
13 | perPage: 5; | 14 | perPage: 5; |
15 | + person: noosfero.Person; | ||
14 | 16 | ||
15 | - constructor(private taskService: TaskService) { } | 17 | + constructor(private taskService: TaskService, private session: SessionService) { } |
16 | 18 | ||
17 | ngOnInit() { | 19 | ngOnInit() { |
20 | + this.person = this.session.currentUser() ? this.session.currentUser().person : null; | ||
18 | this.taskService.getAllPending({ per_page: this.perPage }).then((result: noosfero.RestResult) => { | 21 | this.taskService.getAllPending({ per_page: this.perPage }).then((result: noosfero.RestResult) => { |
19 | this.total = result.headers('total'); | 22 | this.total = result.headers('total'); |
20 | this.tasks = result.data; | 23 | this.tasks = result.data; |
src/app/task/tasks-menu/tasks-menu.html
1 | -<li class="btn-nav tasks-menu" uib-dropdown ng-show="ctrl.total > 0"> | 1 | +<li class="btn-nav tasks-menu" uib-dropdown ng-show="ctrl.total > 0" ng-if="ctrl.total"> |
2 | <a href="#" uib-dropdown-toggle> | 2 | <a href="#" uib-dropdown-toggle> |
3 | <i class="fa fa-bell-o fa-fw fa-2x"></i> | 3 | <i class="fa fa-bell-o fa-fw fa-2x"></i> |
4 | <span class="badge">{{ctrl.total}}</span> | 4 | <span class="badge">{{ctrl.total}}</span> |
5 | </a> | 5 | </a> |
6 | - <ul class="dropdown-menu task-list" uib-dropdown-menu> | ||
7 | - <li ng-repeat="(target, tasks) in ctrl.tasks | groupBy: 'target.name'"> | ||
8 | - {{target}} | ||
9 | - <a href="#" ng-repeat="task in tasks | orderBy: 'created_at':true" class="task"> | ||
10 | - {{task.type}} | ||
11 | - {{task.requestor.name}} | ||
12 | - {{task.target.name}} | ||
13 | - <span class="time"> | ||
14 | - <span class="bullet-separator">•</span> <span am-time-ago="task.created_at | dateFormat"></span> | ||
15 | - </span> | ||
16 | - </a> | ||
17 | - </li> | ||
18 | - <a href="#" class="all-tasks btn btn-default btn-xs">{{"tasks.menu.all" | translate}}</a> | ||
19 | - </ul> | 6 | + <div class="dropdown-menu task-panel" uib-dropdown-menu> |
7 | + <div class="task-menu-header">{{"tasks.menu.header" | translate:{tasks: ctrl.total}:"messageformat"}}</div> | ||
8 | + <task-list [tasks]="ctrl.tasks"></task-list> | ||
9 | + <a ui-sref="main.profile.tasks({profile: ctrl.person.identifier})" class="all-tasks btn btn-default btn-xs">{{"tasks.menu.all" | translate}}</a> | ||
10 | + </div> | ||
20 | </li> | 11 | </li> |
src/app/task/tasks-menu/tasks-menu.scss
1 | -.tasks-menu { | ||
2 | - position: relative; | ||
3 | - margin-right: 0; | ||
4 | - .badge { | ||
5 | - position: absolute; | ||
6 | - top: 1px; | ||
7 | - right: 8px; | ||
8 | - border-radius: 6px; | ||
9 | - } | ||
10 | - i { | ||
11 | - color: #FFF; | ||
12 | - } | ||
13 | - .task-list { | ||
14 | - width: 500px; | ||
15 | - padding: 16px 16px 8px 16px; | ||
16 | - .task { | ||
17 | - .time { | ||
18 | - color: #c1c1c1; | ||
19 | - font-size: 12px; | ||
20 | - .bullet-separator { | ||
21 | - font-size: 10px; | ||
22 | - color: #d1d1d1; | ||
23 | - } | ||
24 | - } | 1 | +tasks-menu { |
2 | + .tasks-menu { | ||
3 | + position: relative; | ||
4 | + margin-right: 0; | ||
5 | + .badge { | ||
6 | + position: absolute; | ||
7 | + top: 1px; | ||
8 | + right: 8px; | ||
9 | + border-radius: 6px; | ||
10 | + background-color: #e84e40; | ||
11 | + color: #fff; | ||
25 | } | 12 | } |
26 | .all-tasks { | 13 | .all-tasks { |
27 | text-align: center; | 14 | text-align: center; |
28 | - width: 100%; | ||
29 | - display: inline-block; | 15 | + width: 97%; |
16 | + display: block; | ||
17 | + margin-left: auto; | ||
18 | + margin-right: auto; | ||
19 | + } | ||
20 | + .task-panel { | ||
21 | + width: 550px; | ||
22 | + padding-top: 0; | ||
23 | + } | ||
24 | + .task-menu-header { | ||
25 | + text-align: center; | ||
26 | + padding: 7px; | ||
27 | + font-weight: bold; | ||
30 | } | 28 | } |
31 | } | 29 | } |
32 | } | 30 | } |
@@ -0,0 +1,30 @@ | @@ -0,0 +1,30 @@ | ||
1 | +import { Component, Inject, provide } from "ng-forward"; | ||
2 | +import { TaskService } from "../../../lib/ng-noosfero-api/http/task.service"; | ||
3 | + | ||
4 | +@Component({ | ||
5 | + selector: "tasks-component", | ||
6 | + templateUrl: "app/task/tasks/tasks.html", | ||
7 | + providers: [ | ||
8 | + provide('taskService', { useClass: TaskService }) | ||
9 | + ] | ||
10 | +}) | ||
11 | +@Inject(TaskService) | ||
12 | +export class TasksComponent { | ||
13 | + | ||
14 | + tasks: noosfero.Task[]; | ||
15 | + total: number; | ||
16 | + currentPage: number; | ||
17 | + perPage: 5; | ||
18 | + | ||
19 | + constructor(private taskService: TaskService) { | ||
20 | + this.loadPage(); | ||
21 | + } | ||
22 | + | ||
23 | + loadPage() { | ||
24 | + this.taskService.getAllPending({ page: this.currentPage, per_page: this.perPage }).then((result: noosfero.RestResult) => { | ||
25 | + this.total = result.headers('total'); | ||
26 | + this.tasks = result.data; | ||
27 | + }); | ||
28 | + } | ||
29 | + | ||
30 | +} |
@@ -0,0 +1,8 @@ | @@ -0,0 +1,8 @@ | ||
1 | +<h3>Tarefas</h3> | ||
2 | + | ||
3 | +<task-list [tasks]="vm.tasks"></task-list> | ||
4 | + | ||
5 | +<uib-pagination ng-model="vm.currentPage" total-items="vm.total" class="pagination-sm center-block" | ||
6 | + boundary-links="true" items-per-page="vm.perPage" ng-change="vm.loadPage()" | ||
7 | + first-text="«" last-text="»" previous-text="‹" next-text="›"> | ||
8 | +</uib-pagination> |
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | +<!-- not implemented yet --> |
src/languages/en.json
@@ -98,5 +98,6 @@ | @@ -98,5 +98,6 @@ | ||
98 | "block.edition.display_user.logged": "Logged", | 98 | "block.edition.display_user.logged": "Logged", |
99 | "block.edition.display_user.not_logged": "Not logged", | 99 | "block.edition.display_user.not_logged": "Not logged", |
100 | "block.edition.language.label": "Show for:", | 100 | "block.edition.language.label": "Show for:", |
101 | - "tasks.menu.all": "All tasks" | 101 | + "tasks.menu.all": "See all tasks", |
102 | + "tasks.menu.header": "You have {tasks, plural, one{one pending task} other{# pending tasks}}" | ||
102 | } | 103 | } |
src/languages/pt.json
@@ -98,5 +98,6 @@ | @@ -98,5 +98,6 @@ | ||
98 | "block.edition.display_user.logged": "Logados", | 98 | "block.edition.display_user.logged": "Logados", |
99 | "block.edition.display_user.not_logged": "Não logados", | 99 | "block.edition.display_user.not_logged": "Não logados", |
100 | "block.edition.language.label": "Exibir para:", | 100 | "block.edition.language.label": "Exibir para:", |
101 | - "tasks.menu.all": "Todas as tarefas" | 101 | + "tasks.menu.all": "Veja todas as tarefas", |
102 | + "tasks.menu.header": "Você tem {tasks, plural, one{uma tarefa pendente} other{# tarefas pendentes}}" | ||
102 | } | 103 | } |
src/lib/ng-noosfero-api/http/task.service.ts
@@ -21,6 +21,7 @@ export class TaskService extends RestangularService<noosfero.Task> { | @@ -21,6 +21,7 @@ export class TaskService extends RestangularService<noosfero.Task> { | ||
21 | } | 21 | } |
22 | 22 | ||
23 | getAllPending(params: any) { | 23 | getAllPending(params: any) { |
24 | - return this.list(null, { all_pending: true }); | 24 | + params['all_pending'] = true; |
25 | + return this.list(null, params); | ||
25 | } | 26 | } |
26 | } | 27 | } |