diff --git a/docIndex.md b/docIndex.md index 99c2426f7e..ac04adc0a9 100644 --- a/docIndex.md +++ b/docIndex.md @@ -350,7 +350,8 @@ for more information about installing and using the source code. - [*Log service](ng2-components/ng2-alfresco-core/src/services/log.service.ts) - [*Nodes api service](ng2-components/ng2-alfresco-core/src/services/nodes-api.service.ts) - [*Page title service](ng2-components/ng2-alfresco-core/src/services/page-title.service.ts) -- [*People api service](ng2-components/ng2-alfresco-core/src/services/people-api.service.ts) +- [*People content api service](ng2-components/ng2-alfresco-core/src/services/people-content.service.ts) +- [*People process api service](ng2-components/ng2-alfresco-core/src/services/people-process.service.ts) - [*Search api service](ng2-components/ng2-alfresco-core/src/services/search-api.service.ts) - [*Search service](ng2-components/ng2-alfresco-core/src/services/search.service.ts) - [*Shared links api service](ng2-components/ng2-alfresco-core/src/services/shared-links-api.service.ts) diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/core/group-user.model.spec.ts b/ng2-components/ng2-activiti-form/src/components/widgets/core/group-user.model.spec.ts deleted file mode 100644 index 6c78b24266..0000000000 --- a/ng2-components/ng2-activiti-form/src/components/widgets/core/group-user.model.spec.ts +++ /dev/null @@ -1,39 +0,0 @@ -/*! - * @license - * Copyright 2016 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { GroupUserModel } from './group-user.model'; - -describe('GroupUserModel', () => { - - it('should init with json', () => { - let json = { - company: '', - email: '', - firstName: '', - id: '', - lastName: '' - }; - - let model = new GroupUserModel(json); - expect(model.company).toBe(json.company); - expect(model.email).toBe(json.email); - expect(model.firstName).toBe(json.firstName); - expect(model.id).toBe(json.id); - expect(model.lastName).toBe(json.lastName); - }); - -}); diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/people/people.widget.html b/ng2-components/ng2-activiti-form/src/components/widgets/people/people.widget.html index a1ba4654a9..310e2b4321 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/people/people.widget.html +++ b/ng2-components/ng2-activiti-form/src/components/widgets/people/people.widget.html @@ -23,10 +23,9 @@
{{getInitialUserName(user.firstName, user.lastName)}}
-
+
+ [src]="peopleProcessService.getUserImage(user)"/>
{{getDisplayName(user)}}
diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/people/people.widget.spec.ts b/ng2-components/ng2-activiti-form/src/components/widgets/people/people.widget.spec.ts index 1cb4ba3146..9947efd5b4 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/people/people.widget.spec.ts +++ b/ng2-components/ng2-activiti-form/src/components/widgets/people/people.widget.spec.ts @@ -16,14 +16,13 @@ */ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { CoreModule } from 'ng2-alfresco-core'; +import { CoreModule, LightUserRepresentation } from 'ng2-alfresco-core'; import { Observable } from 'rxjs/Rx'; import { ActivitiAlfrescoContentService } from '../../../services/activiti-alfresco.service'; import { FormService } from '../../../services/form.service'; import { MaterialModule } from '../../material.module'; import { FormFieldModel } from '../core/form-field.model'; import { FormModel } from '../core/form.model'; -import { GroupUserModel } from '../core/group-user.model'; import { ErrorWidgetComponent } from '../error/error.component'; import { EcmModelService } from './../../../services/ecm-model.service'; import { PeopleWidgetComponent } from './people.widget'; @@ -68,7 +67,7 @@ describe('PeopleWidgetComponent', () => { }); it('should return full name for a given model', () => { - let model = new GroupUserModel({ + let model = new LightUserRepresentation({ firstName: 'John', lastName: 'Doe' }); @@ -76,17 +75,17 @@ describe('PeopleWidgetComponent', () => { }); it('should skip first name for display name', () => { - let model = new GroupUserModel({firstName: null, lastName: 'Doe'}); + let model = new LightUserRepresentation({firstName: null, lastName: 'Doe'}); expect(widget.getDisplayName(model)).toBe('Doe'); }); it('should skip last name for display name', () => { - let model = new GroupUserModel({firstName: 'John', lastName: null}); + let model = new LightUserRepresentation({firstName: 'John', lastName: null}); expect(widget.getDisplayName(model)).toBe('John'); }); it('should init value from the field', () => { - widget.field.value = new GroupUserModel({ + widget.field.value = new LightUserRepresentation({ firstName: 'John', lastName: 'Doe' }); @@ -109,7 +108,7 @@ describe('PeopleWidgetComponent', () => { }); it('should update values on item click', () => { - let item = new GroupUserModel({firstName: 'John', lastName: 'Doe'}); + let item = new LightUserRepresentation({firstName: 'John', lastName: 'Doe'}); widget.onItemClick(item, null); expect(widget.field.value).toBe(item); @@ -213,8 +212,8 @@ describe('PeopleWidgetComponent', () => { it('should flush value and update field', () => { widget.users = [ - new GroupUserModel({firstName: 'Tony', lastName: 'Stark'}), - new GroupUserModel({firstName: 'John', lastName: 'Doe'}) + new LightUserRepresentation({firstName: 'Tony', lastName: 'Stark'}), + new LightUserRepresentation({firstName: 'John', lastName: 'Doe'}) ]; widget.value = 'John Doe'; widget.flushValue(); @@ -225,8 +224,8 @@ describe('PeopleWidgetComponent', () => { it('should be case insensitive when flushing field', () => { widget.users = [ - new GroupUserModel({firstName: 'Tony', lastName: 'Stark'}), - new GroupUserModel({firstName: 'John', lastName: 'Doe'}) + new LightUserRepresentation({firstName: 'Tony', lastName: 'Stark'}), + new LightUserRepresentation({firstName: 'John', lastName: 'Doe'}) ]; widget.value = 'TONY sTaRk'; widget.flushValue(); diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/people/people.widget.ts b/ng2-components/ng2-activiti-form/src/components/widgets/people/people.widget.ts index 9c8dba1550..a20f67300b 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/people/people.widget.ts +++ b/ng2-components/ng2-activiti-form/src/components/widgets/people/people.widget.ts @@ -20,8 +20,8 @@ import { ENTER, ESCAPE } from '@angular/cdk/keycodes'; import { Component, OnInit, ViewChild, ViewEncapsulation } from '@angular/core'; import { MdAutocompleteTrigger } from '@angular/material'; +import { LightUserRepresentation, PeopleProcessService } from 'ng2-alfresco-core'; import { FormService } from '../../../services/form.service'; -import { GroupUserModel } from '../core/group-user.model'; import { GroupModel } from '../core/group.model'; import { baseHost , WidgetComponent } from './../widget.component'; @@ -40,16 +40,16 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit { minTermLength: number = 1; value: string; oldValue: string; - users: GroupUserModel[] = []; + users: LightUserRepresentation[] = []; groupId: string; - constructor(public formService: FormService) { + constructor(public formService: FormService, public peopleProcessService: PeopleProcessService) { super(formService); } ngOnInit() { if (this.field) { - let user: GroupUserModel = this.field.value; + let user: LightUserRepresentation = this.field.value; if (user) { this.value = this.getDisplayName(user); } @@ -75,17 +75,11 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit { searchUsers() { this.formService.getWorkflowUsers(this.value, this.groupId) - .subscribe((result: GroupUserModel[]) => { + .subscribe((result: LightUserRepresentation[]) => { this.users = result || []; }); } - onErrorImageLoad(user) { - if (user.userImage) { - user.userImage = null; - } - } - flushValue() { let option = this.users.find(item => { let fullName = this.getDisplayName(item).toLocaleLowerCase(); @@ -103,7 +97,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit { this.field.updateForm(); } - getDisplayName(model: GroupUserModel) { + getDisplayName(model: LightUserRepresentation) { if (model) { let displayName = `${model.firstName || ''} ${model.lastName || ''}`; return displayName.trim(); @@ -112,7 +106,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit { return ''; } - onItemClick(item: GroupUserModel, event: Event) { + onItemClick(item: LightUserRepresentation, event: Event) { if (item) { this.field.value = item; this.value = this.getDisplayName(item); @@ -122,7 +116,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit { } } - onItemSelect(item: GroupUserModel) { + onItemSelect(item: LightUserRepresentation) { if (item) { this.field.value = item; this.value = this.getDisplayName(item); diff --git a/ng2-components/ng2-activiti-form/src/services/form.service.ts b/ng2-components/ng2-activiti-form/src/services/form.service.ts index c47061dbdc..ff19922cab 100644 --- a/ng2-components/ng2-activiti-form/src/services/form.service.ts +++ b/ng2-components/ng2-activiti-form/src/services/form.service.ts @@ -16,11 +16,10 @@ */ import { Injectable } from '@angular/core'; -import { AlfrescoApiService, LogService } from 'ng2-alfresco-core'; +import { AlfrescoApiService, LightUserRepresentation, LogService } from 'ng2-alfresco-core'; import { Observable, Subject } from 'rxjs/Rx'; import { FormDefinitionModel } from '../models/form-definition.model'; import { ContentLinkModel } from './../components/widgets/core/content-link.model'; -import { GroupUserModel } from './../components/widgets/core/group-user.model'; import { GroupModel } from './../components/widgets/core/group.model'; import { FormModel, FormOutcomeEvent, FormOutcomeModel, FormValues } from './../components/widgets/core/index'; import { @@ -376,13 +375,13 @@ export class FormService { return this.apiService.getInstance().activiti.userApi.getUserProfilePictureUrl(userId); } - getWorkflowUsers(filter: string, groupId?: string): Observable { + getWorkflowUsers(filter: string, groupId?: string): Observable { let option: any = {filter: filter}; if (groupId) { option.groupId = groupId; } return Observable.fromPromise(this.usersWorkflowApi.getUsers(option)) - .switchMap((response: any) => response.data || []) + .switchMap((response: any) => response.data || []) .map((user: any) => { user.userImage = this.getUserProfileImageApi(user.id); return Observable.of(user); diff --git a/ng2-components/ng2-activiti-processlist/src/assets/process.service.mock.ts b/ng2-components/ng2-activiti-processlist/src/assets/process.service.mock.ts index 11ec2369d3..2f197bec99 100644 --- a/ng2-components/ng2-activiti-processlist/src/assets/process.service.mock.ts +++ b/ng2-components/ng2-activiti-processlist/src/assets/process.service.mock.ts @@ -15,14 +15,10 @@ * limitations under the License. */ -import { - AppDefinitionRepresentationModel, - Comment, - TaskDetailsModel, - User -} from 'ng2-activiti-tasklist'; +import { AppDefinitionRepresentationModel, Comment, TaskDetailsModel } from 'ng2-activiti-tasklist'; import { FilterProcessRepresentationModel } from '../models/filter-process.model'; import { ProcessDefinitionRepresentation } from '../models/process-definition.model'; +import { LightUserRepresentation } from 'ng2-alfresco-core'; export let fakeFilters = { size: 1, total: 1, start: 0, @@ -80,7 +76,7 @@ export let fakeTaskList = { })] }; -export let fakeComment = new Comment(1, 'Test', '2016-11-10T03:37:30.010+0000', new User({ +export let fakeComment = new Comment(1, 'Test', '2016-11-10T03:37:30.010+0000', new LightUserRepresentation({ id: 13, firstName: 'Wilbur', lastName: 'Adams', diff --git a/ng2-components/ng2-activiti-processlist/src/components/process-comments.component.spec.ts b/ng2-components/ng2-activiti-processlist/src/components/process-comments.component.spec.ts index b453b69673..612636aded 100644 --- a/ng2-components/ng2-activiti-processlist/src/components/process-comments.component.spec.ts +++ b/ng2-components/ng2-activiti-processlist/src/components/process-comments.component.spec.ts @@ -23,10 +23,9 @@ import { Observable } from 'rxjs/Rx'; import { CommentListComponent, CommentsComponent, - PeopleService, TaskListService } from 'ng2-activiti-tasklist'; -import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core'; +import { AlfrescoTranslationService, CoreModule, PeopleProcessService } from 'ng2-alfresco-core'; import { DataTableModule } from 'ng2-alfresco-datatable'; import { TranslationMock } from './../assets/translation.service.mock'; @@ -57,7 +56,7 @@ describe('ActivitiProcessInstanceComments', () => { { provide: AlfrescoTranslationService, useClass: TranslationMock }, { provide: TaskListService, useClass: ProcessService }, DatePipe, - PeopleService + PeopleProcessService ] }).compileComponents(); })); diff --git a/ng2-components/ng2-activiti-processlist/src/services/process.service.ts b/ng2-components/ng2-activiti-processlist/src/services/process.service.ts index 9107596f96..4c9fa4b0bb 100644 --- a/ng2-components/ng2-activiti-processlist/src/services/process.service.ts +++ b/ng2-components/ng2-activiti-processlist/src/services/process.service.ts @@ -20,9 +20,8 @@ import { RestVariable } from 'alfresco-js-api'; import { Comment, TaskDetailsModel, - TaskListService, - User } from 'ng2-activiti-tasklist'; -import { AlfrescoApiService, LogService } from 'ng2-alfresco-core'; + TaskListService } from 'ng2-activiti-tasklist'; +import { AlfrescoApiService, LightUserRepresentation, LogService } from 'ng2-alfresco-core'; import { Observable } from 'rxjs/Observable'; import { FilterProcessRepresentationModel } from '../models/filter-process.model'; import { ProcessDefinitionRepresentation } from '../models/process-definition.model'; @@ -234,7 +233,7 @@ export class ProcessService extends TaskListService { .map((response: any) => { let comments: Comment[] = []; response.data.forEach((comment) => { - let user = new User({ + let user = new LightUserRepresentation({ id: comment.createdBy.id, email: comment.createdBy.email, firstName: comment.createdBy.firstName, diff --git a/ng2-components/ng2-activiti-tasklist/index.ts b/ng2-components/ng2-activiti-tasklist/index.ts index b88f55c39d..68e4131de5 100644 --- a/ng2-components/ng2-activiti-tasklist/index.ts +++ b/ng2-components/ng2-activiti-tasklist/index.ts @@ -23,7 +23,6 @@ import { ActivitiFormModule } from 'ng2-activiti-form'; import { CoreModule, TRANSLATION_PROVIDER } from 'ng2-alfresco-core'; import { DataTableModule } from 'ng2-alfresco-datatable'; import { MaterialModule } from './src/components/material.module'; -import { PeopleService } from './src/services/people.service'; import { ProcessUploadService } from './src/services/process-upload.service'; import { TaskListService } from './src/services/tasklist.service'; @@ -62,7 +61,6 @@ export {PeopleListComponent } from './src/components/people-list.component'; export {CommentListComponent } from './src/components/comment-list.component'; export { TaskListService } from './src/services/tasklist.service'; -export { PeopleService } from './src/services/people.service'; export { ProcessUploadService } from './src/services/process-upload.service'; // Old Deprecated export @@ -79,7 +77,6 @@ import {TaskDetailsComponent as ActivitiTaskDetails } from './src/components/tas import {TaskFiltersComponent as ActivitiFilters } from './src/components/task-filters.component'; import {TaskHeaderComponent as ActivitiTaskHeader } from './src/components/task-header.component'; import {TaskListComponent as ActivitiTaskList } from './src/components/tasklist.component'; -import {PeopleService as ActivitiPeopleService } from './src/services/people.service'; import {TaskListService as ActivitiTaskListService } from './src/services/tasklist.service'; export {AppsListComponent as ActivitiApps} from './src/components/apps-list.component'; export {ChecklistComponent as ActivitiChecklist} from './src/components/checklist.component'; @@ -94,13 +91,11 @@ export {TaskDetailsComponent as ActivitiTaskDetails } from './src/components/tas export {TaskFiltersComponent as ActivitiFilters } from './src/components/task-filters.component'; export {TaskHeaderComponent as ActivitiTaskHeader} from './src/components/task-header.component'; export {TaskListComponent as ActivitiTaskList } from './src/components/tasklist.component'; -export {PeopleService as ActivitiPeopleService } from './src/services/people.service'; export {TaskListService as ActivitiTaskListService } from './src/services/tasklist.service'; export * from './src/models/comment.model'; export * from './src/models/filter.model'; export * from './src/models/icon.model'; -export * from './src/models/user.model'; export * from './src/models/task-details.model'; export * from './src/models/task-details.event'; export * from './src/models/user-event.model'; @@ -144,12 +139,10 @@ export const ACTIVITI_TASKLIST_DIRECTIVES: any[] = [ export const ACTIVITI_TASKLIST_PROVIDERS: any[] = [ TaskListService, - PeopleService, ProcessUploadService, // Old Deprecated export - ActivitiTaskListService, - ActivitiPeopleService + ActivitiTaskListService ]; @NgModule({ diff --git a/ng2-components/ng2-activiti-tasklist/src/components/comment-list.component.html b/ng2-components/ng2-activiti-tasklist/src/components/comment-list.component.html index c7ec14ce51..c2adbbea58 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/comment-list.component.html +++ b/ng2-components/ng2-activiti-tasklist/src/components/comment-list.component.html @@ -8,12 +8,11 @@
+ *ngIf="!entry.row.obj.createdBy.pictureId" class="adf-comment-user-icon"> {{getUserShortName(entry.row.obj.createdBy)}}
- +
diff --git a/ng2-components/ng2-activiti-tasklist/src/components/comment-list.component.spec.ts b/ng2-components/ng2-activiti-tasklist/src/components/comment-list.component.spec.ts index c16340dc48..b134afaa15 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/comment-list.component.spec.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/comment-list.component.spec.ts @@ -18,16 +18,16 @@ import { DatePipe } from '@angular/common'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { AppConfigService, CoreModule, TranslationService } from 'ng2-alfresco-core'; +import { LightUserRepresentation } from 'ng2-alfresco-core'; import { DataRowEvent, DataTableModule, ObjectDataRow } from 'ng2-alfresco-datatable'; import { AppConfigServiceMock } from '../assets/app-config.service.mock'; import { TranslationMock } from '../assets/translation.service.mock'; import { Comment } from '../models/comment.model'; -import { User } from '../models/user.model'; import { CommentListComponent } from './comment-list.component'; declare let jasmine: any; -const testUser: User = new User({ +const testUser: LightUserRepresentation = new LightUserRepresentation({ id: '1', firstName: 'Test', lastName: 'User', @@ -54,8 +54,8 @@ describe('CommentListComponent', () => { ], providers: [ DatePipe, - { provide: AppConfigService, useClass: AppConfigServiceMock }, - { provide: TranslationService, useClass: TranslationMock } + {provide: AppConfigService, useClass: AppConfigServiceMock}, + {provide: TranslationService, useClass: TranslationMock} ] }).compileComponents().then(() => { diff --git a/ng2-components/ng2-activiti-tasklist/src/components/comment-list.component.ts b/ng2-components/ng2-activiti-tasklist/src/components/comment-list.component.ts index 5da9f588c3..040f7ffeb1 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/comment-list.component.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/comment-list.component.ts @@ -17,8 +17,8 @@ import { DatePipe } from '@angular/common'; import { Component, EventEmitter, Input, Output } from '@angular/core'; +import { LightUserRepresentation, PeopleProcessService } from 'ng2-alfresco-core'; import { Comment } from '../models/comment.model'; -import { User } from '../models/user.model'; @Component({ selector: 'adf-comment-list', @@ -36,7 +36,7 @@ export class CommentListComponent { selectedComment: Comment; - constructor(private datePipe: DatePipe) { + constructor(private datePipe: DatePipe, public peopleProcessService: PeopleProcessService) { } selectComment(event: any): void { @@ -44,7 +44,7 @@ export class CommentListComponent { this.clickRow.emit(this.selectedComment); } - getUserShortName(user: User): string { + getUserShortName(user: LightUserRepresentation): string { let shortName = ''; if (user) { if (user.firstName) { @@ -78,10 +78,4 @@ export class CommentListComponent { return this.comments && this.comments.length && true; } - onErrorImageLoad(user: User) { - if (user.userImage) { - user.userImage = null; - } - } - } diff --git a/ng2-components/ng2-activiti-tasklist/src/components/comments.component.spec.ts b/ng2-components/ng2-activiti-tasklist/src/components/comments.component.spec.ts index 1a571c62c2..164f5b18ac 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/comments.component.spec.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/comments.component.spec.ts @@ -26,8 +26,8 @@ import { TranslationMock } from '../assets/translation.service.mock'; import { DatePipe } from '@angular/common'; import { MdInputModule } from '@angular/material'; +import { PeopleProcessService } from 'ng2-alfresco-core'; import { DataTableModule } from 'ng2-alfresco-datatable'; -import { PeopleService } from '../services/people.service'; import { TaskListService } from './../services/tasklist.service'; import { CommentListComponent } from './comment-list.component'; import { CommentsComponent } from './comments.component'; @@ -56,7 +56,7 @@ describe('CommentsComponent', () => { providers: [ TaskListService, DatePipe, - PeopleService, + PeopleProcessService, { provide: TranslationService, useClass: TranslationMock }, { provide: AppConfigService, useClass: AppConfigServiceMock } ] diff --git a/ng2-components/ng2-activiti-tasklist/src/components/comments.component.ts b/ng2-components/ng2-activiti-tasklist/src/components/comments.component.ts index 76142d9a8e..443b0dc760 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/comments.component.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/comments.component.ts @@ -19,7 +19,6 @@ import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from import { Observable, Observer } from 'rxjs/Rx'; import { Comment } from '../models/comment.model'; -import { PeopleService } from '../services/people.service'; import { TaskListService } from '../services/tasklist.service'; @Component({ @@ -52,7 +51,7 @@ export class CommentsComponent implements OnChanges { * @param translate Translation service * @param activitiTaskList Task service */ - constructor(private activitiTaskList: TaskListService, private peopleService: PeopleService) { + constructor(private activitiTaskList: TaskListService) { this.comment$ = new Observable(observer => this.commentObserver = observer).share(); this.comment$.subscribe((comment: Comment) => { this.comments.push(comment); @@ -81,7 +80,6 @@ export class CommentsComponent implements OnChanges { return date1 > date2 ? -1 : date1 < date2 ? 1 : 0; }); res.forEach((comment) => { - comment.createdBy.userImage = this.peopleService.getUserImage(comment.createdBy); this.commentObserver.next(comment); }); }, @@ -102,7 +100,6 @@ export class CommentsComponent implements OnChanges { this.activitiTaskList.addComment(this.taskId, this.message) .subscribe( (res: Comment) => { - res.createdBy.userImage = this.peopleService.getUserImage(res.createdBy); this.comments.unshift(res); this.message = ''; this.beingAdded = false; diff --git a/ng2-components/ng2-activiti-tasklist/src/components/people-list.component.spec.ts b/ng2-components/ng2-activiti-tasklist/src/components/people-list.component.spec.ts index d61a23946b..a6645343b8 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/people-list.component.spec.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/people-list.component.spec.ts @@ -17,16 +17,16 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { AppConfigService, CoreModule, TranslationService } from 'ng2-alfresco-core'; +import { LightUserRepresentation } from 'ng2-alfresco-core'; import { DataRowActionEvent, DataRowEvent, DataTableModule, ObjectDataRow } from 'ng2-alfresco-datatable'; import { AppConfigServiceMock } from '../assets/app-config.service.mock'; import { TranslationMock } from '../assets/translation.service.mock'; import { UserEventModel } from '../models/user-event.model'; -import { User } from '../models/user.model'; import { PeopleListComponent } from './people-list.component'; declare let jasmine: any; -const fakeUser: User = new User({ +const fakeUser: LightUserRepresentation = new LightUserRepresentation({ id: '1', firstName: 'fake-name', lastName: 'fake-last', diff --git a/ng2-components/ng2-activiti-tasklist/src/components/people-list.component.ts b/ng2-components/ng2-activiti-tasklist/src/components/people-list.component.ts index 2072ccc165..201f473d22 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/people-list.component.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/people-list.component.ts @@ -17,9 +17,9 @@ import { AfterContentInit, AfterViewInit, Component, ContentChild, EventEmitter, Input, Output, ViewChild } from '@angular/core'; import { DataColumnListComponent } from 'ng2-alfresco-core'; +import { LightUserRepresentation } from 'ng2-alfresco-core'; import { DataTableComponent } from 'ng2-alfresco-datatable'; import { UserEventModel } from '../models/user-event.model'; -import { User } from '../models/user.model'; declare let componentHandler: any; @@ -37,18 +37,18 @@ export class PeopleListComponent implements AfterViewInit, AfterContentInit { peopleDataTable: DataTableComponent; @Input() - users: User[]; + users: LightUserRepresentation[]; @Input() actions: boolean = false; @Output() - clickRow: EventEmitter = new EventEmitter(); + clickRow: EventEmitter = new EventEmitter(); @Output() clickAction: EventEmitter = new EventEmitter(); - user: User; + user: LightUserRepresentation; ngAfterContentInit() { this.peopleDataTable.columnList = this.columnList; diff --git a/ng2-components/ng2-activiti-tasklist/src/components/people-search.component.html b/ng2-components/ng2-activiti-tasklist/src/components/people-search.component.html index 3b48259e9d..9590002e90 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/people-search.component.html +++ b/ng2-components/ng2-activiti-tasklist/src/components/people-search.component.html @@ -11,12 +11,11 @@ -
+
{{getInitialUserName(entry.row.obj.firstName, entry.row.obj.lastName)}}
- +
diff --git a/ng2-components/ng2-activiti-tasklist/src/components/people-search.component.spec.ts b/ng2-components/ng2-activiti-tasklist/src/components/people-search.component.spec.ts index 1ddfd94b5f..c28a5e5767 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/people-search.component.spec.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/people-search.component.spec.ts @@ -18,24 +18,24 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { MdButtonModule, MdInputModule } from '@angular/material'; import { AppConfigService, CoreModule, TranslationService } from 'ng2-alfresco-core'; +import { LightUserRepresentation } from 'ng2-alfresco-core'; import { DataTableModule } from 'ng2-alfresco-datatable'; import { Observable } from 'rxjs/Observable'; import { AppConfigServiceMock } from '../assets/app-config.service.mock'; import { TranslationMock } from '../assets/translation.service.mock'; -import { User } from '../models/user.model'; import { PeopleListComponent } from './people-list.component'; import { PeopleSearchComponent } from './people-search.component'; declare let jasmine: any; -const fakeUser: User = new User({ +const fakeUser: LightUserRepresentation = new LightUserRepresentation({ id: '1', firstName: 'fake-name', lastName: 'fake-last', email: 'fake@mail.com' }); -const fakeSecondUser: User = new User({ +const fakeSecondUser: LightUserRepresentation = new LightUserRepresentation({ id: '2', firstName: 'fake-involve-name', lastName: 'fake-involve-last', diff --git a/ng2-components/ng2-activiti-tasklist/src/components/people-search.component.ts b/ng2-components/ng2-activiti-tasklist/src/components/people-search.component.ts index 2443ff32be..af4499aede 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/people-search.component.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/people-search.component.ts @@ -17,8 +17,9 @@ import { Component, Directive, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from '@angular/core'; import { FormControl } from '@angular/forms'; +import { LightUserRepresentation } from 'ng2-alfresco-core'; +import { PeopleProcessService } from 'ng2-alfresco-core'; import { Observable } from 'rxjs/Observable'; -import { User } from '../models/user.model'; @Component({ selector: 'adf-people-search, activiti-people-search', @@ -33,24 +34,24 @@ import { User } from '../models/user.model'; export class PeopleSearchComponent implements OnInit { @Input() - results: Observable; + results: Observable; @Output() searchPeople: EventEmitter = new EventEmitter(); @Output() - success: EventEmitter = new EventEmitter(); + success: EventEmitter = new EventEmitter(); @Output() closeSearch = new EventEmitter(); searchUser: FormControl = new FormControl(); - users: User[] = []; + users: LightUserRepresentation[] = []; - selectedUser: User; + selectedUser: LightUserRepresentation; - constructor() { + constructor(peopleProcessService: PeopleProcessService) { this.searchUser .valueChanges .debounceTime(200) @@ -69,7 +70,7 @@ export class PeopleSearchComponent implements OnInit { }); } - onRowClick(user: User) { + onRowClick(user: LightUserRepresentation) { this.selectedUser = user; } @@ -108,12 +109,6 @@ export class PeopleSearchComponent implements OnInit { hasUsers() { return (this.users && this.users.length > 0); } - - onErrorImageLoad(user: User) { - if (user.userImage) { - user.userImage = null; - } - } } @Directive({ selector: 'people-search-title' }) export class PeopleSearchTitleDirective { } diff --git a/ng2-components/ng2-activiti-tasklist/src/components/people.component.html b/ng2-components/ng2-activiti-tasklist/src/components/people.component.html index 57eb5c6f90..2346633714 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/people.component.html +++ b/ng2-components/ng2-activiti-tasklist/src/components/people.component.html @@ -29,12 +29,11 @@ -
+
{{getInitialUserName(entry.row.obj.firstName, entry.row.obj.lastName)}}
- +
diff --git a/ng2-components/ng2-activiti-tasklist/src/components/people.component.spec.ts b/ng2-components/ng2-activiti-tasklist/src/components/people.component.spec.ts index 8eb7ab9ca8..a72f0b5c0e 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/people.component.spec.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/people.component.spec.ts @@ -19,25 +19,25 @@ import { NO_ERRORS_SCHEMA } from '@angular/core'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { MdButtonModule, MdInputModule } from '@angular/material'; import { AppConfigService, CoreModule, LogService, TranslationService } from 'ng2-alfresco-core'; +import { LightUserRepresentation } from 'ng2-alfresco-core'; +import { PeopleProcessService } from 'ng2-alfresco-core'; import { DataTableModule } from 'ng2-alfresco-datatable'; import { AppConfigServiceMock } from '../assets/app-config.service.mock'; import { TranslationMock } from '../assets/translation.service.mock'; -import { User } from '../models/user.model'; -import { PeopleService } from '../services/people.service'; import { PeopleListComponent } from './people-list.component'; import { PeopleSearchComponent } from './people-search.component'; import { PeopleComponent } from './people.component'; declare let jasmine: any; -const fakeUser: User = new User({ +const fakeUser: LightUserRepresentation = new LightUserRepresentation({ id: 'fake-id', firstName: 'fake-name', lastName: 'fake-last', email: 'fake@mail.com' }); -const fakeSecondUser: User = new User({ +const fakeSecondUser: LightUserRepresentation = new LightUserRepresentation({ id: 'fake-involve-id', firstName: 'fake-involve-name', lastName: 'fake-involve-last', @@ -67,7 +67,7 @@ describe('PeopleComponent', () => { PeopleComponent ], providers: [ - PeopleService, + PeopleProcessService, { provide: TranslationService, useClass: TranslationMock }, { provide: AppConfigService, useClass: AppConfigServiceMock } ], diff --git a/ng2-components/ng2-activiti-tasklist/src/components/people.component.ts b/ng2-components/ng2-activiti-tasklist/src/components/people.component.ts index 4f97bfb243..153992be0b 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/people.component.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/people.component.ts @@ -17,13 +17,11 @@ import { AfterViewInit, Component, Input, OnInit, ViewChild } from '@angular/core'; import { LogService } from 'ng2-alfresco-core'; +import { LightUserRepresentation, PeopleProcessService } from 'ng2-alfresco-core'; import { Observable, Observer } from 'rxjs/Rx'; import { UserEventModel } from '../models/user-event.model'; -import { User } from '../models/user.model'; import { PeopleSearchComponent } from './people-search.component'; -import { PeopleService } from '../services/people.service'; - declare let componentHandler: any; declare var require: any; @@ -38,7 +36,7 @@ export class PeopleComponent implements OnInit, AfterViewInit { iconImageUrl: string = require('../assets/images/user.jpg'); @Input() - people: User[] = []; + people: LightUserRepresentation[] = []; @Input() taskId: string = ''; @@ -51,25 +49,14 @@ export class PeopleComponent implements OnInit, AfterViewInit { showAssignment: boolean = false; - private peopleSearchObserver: Observer; - peopleSearch$: Observable; + private peopleSearchObserver: Observer; + peopleSearch$: Observable; - /** - * Constructor - * @param translate - * @param people service - */ - constructor(private peopleService: PeopleService, - private logService: LogService) { - this.peopleSearch$ = new Observable(observer => this.peopleSearchObserver = observer).share(); + constructor(private logService: LogService, public peopleProcessService: PeopleProcessService) { + this.peopleSearch$ = new Observable(observer => this.peopleSearchObserver = observer).share(); } ngOnInit() { - if (this.people && this.people.length > 0) { - this.people.forEach((person) => { - person.userImage = this.peopleService.getUserImage(person); - }); - } } ngAfterViewInit() { @@ -99,21 +86,21 @@ export class PeopleComponent implements OnInit, AfterViewInit { } searchUser(searchedWord: string) { - this.peopleService.getWorkflowUsersWithImages(this.taskId, searchedWord) + this.peopleProcessService.getWorkflowUsers(this.taskId, searchedWord) .subscribe((users) => { this.peopleSearchObserver.next(users); }, error => this.logService.error(error)); } - involveUser(user: User) { - this.peopleService.involveUserWithTask(this.taskId, user.id.toString()) + involveUser(user: LightUserRepresentation) { + this.peopleProcessService.involveUserWithTask(this.taskId, user.id.toString()) .subscribe(() => { this.people = [...this.people, user]; }, error => this.logService.error('Impossible to involve user with task')); } - removeInvolvedUser(user: User) { - this.peopleService.removeInvolvedUser(this.taskId, user.id.toString()) + removeInvolvedUser(user: LightUserRepresentation) { + this.peopleProcessService.removeInvolvedUser(this.taskId, user.id.toString()) .subscribe(() => { this.people = this.people.filter((involvedUser) => { return involvedUser.id !== user.id; @@ -154,10 +141,4 @@ export class PeopleComponent implements OnInit, AfterViewInit { onCloseSearch() { this.showAssignment = false; } - - onErrorImageLoad(user: User) { - if (user.userImage) { - user.userImage = null; - } - } } diff --git a/ng2-components/ng2-activiti-tasklist/src/components/start-task.component.spec.ts b/ng2-components/ng2-activiti-tasklist/src/components/start-task.component.spec.ts index 1e0cfa3e8d..608443ac84 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/start-task.component.spec.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/start-task.component.spec.ts @@ -17,12 +17,11 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { MdButtonModule, MdDatepickerModule, MdGridListModule, MdIconModule, MdInputModule, MdNativeDateModule, MdSelectModule } from '@angular/material'; -import { AppConfigService, CoreModule, TranslationService } from 'ng2-alfresco-core'; +import { AppConfigService, CoreModule, PeopleProcessService, TranslationService } from 'ng2-alfresco-core'; import { Observable } from 'rxjs/Rx'; import { AppConfigServiceMock } from '../assets/app-config.service.mock'; import { TranslationMock } from '../assets/translation.service.mock'; import { StartTaskModel } from '../models/start-task.model'; -import { PeopleService } from '../services/people.service'; import { TaskListService } from '../services/tasklist.service'; import { startTaskMock } from './../assets/start-task.mock'; import { StartTaskComponent } from './start-task.component'; @@ -32,7 +31,7 @@ describe('StartTaskComponent', () => { let component: StartTaskComponent; let fixture: ComponentFixture; let service: TaskListService; - let peopleService: PeopleService; + let peopleService: PeopleProcessService; let element: HTMLElement; let getFormlistSpy: jasmine.Spy; let getWorkflowUsersSpy: jasmine.Spy; @@ -67,7 +66,7 @@ describe('StartTaskComponent', () => { ], providers: [ TaskListService, - PeopleService, + PeopleProcessService, { provide: AppConfigService, useClass: AppConfigServiceMock }, { provide: TranslationService, useClass: TranslationMock } ] @@ -78,7 +77,7 @@ describe('StartTaskComponent', () => { element = fixture.nativeElement; service = fixture.debugElement.injector.get(TaskListService); - peopleService = fixture.debugElement.injector.get(PeopleService); + peopleService = fixture.debugElement.injector.get(PeopleProcessService); getFormlistSpy = spyOn(service, 'getFormList').and.returnValue(Observable.of(fakeForms)); getWorkflowUsersSpy = spyOn(peopleService, 'getWorkflowUsers').and.returnValue(Observable.of([ { diff --git a/ng2-components/ng2-activiti-tasklist/src/components/start-task.component.ts b/ng2-components/ng2-activiti-tasklist/src/components/start-task.component.ts index 8260d1120c..2f92279b8a 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/start-task.component.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/start-task.component.ts @@ -18,14 +18,12 @@ import { Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from '@angular/core'; import { DateAdapter, MD_DATE_FORMATS } from '@angular/material'; import * as moment from 'moment'; -import { MOMENT_DATE_FORMATS, MomentDateAdapter } from 'ng2-alfresco-core'; -import { LogService } from 'ng2-alfresco-core'; +import { LightUserRepresentation, LogService, MOMENT_DATE_FORMATS, + MomentDateAdapter, PeopleProcessService } from 'ng2-alfresco-core'; import { Observable } from 'rxjs/Rx'; import { Form } from '../models/form.model'; import { StartTaskModel } from '../models/start-task.model'; import { TaskDetailsModel } from '../models/task-details.model'; -import { User } from '../models/user.model'; -import { PeopleService } from '../services/people.service'; import { TaskListService } from './../services/tasklist.service'; @Component({ @@ -53,7 +51,7 @@ export class StartTaskComponent implements OnInit { @Output() error: EventEmitter = new EventEmitter(); - people: User[] = []; + people: LightUserRepresentation[] = []; startTaskmodel: StartTaskModel = new StartTaskModel(); @@ -74,7 +72,7 @@ export class StartTaskComponent implements OnInit { * @param taskService */ constructor(private taskService: TaskListService, - private peopleService: PeopleService, + private peopleService: PeopleProcessService, private logService: LogService) { } @@ -143,7 +141,7 @@ export class StartTaskComponent implements OnInit { }); } - public isUserNameEmpty(user: any): boolean { + public isUserNameEmpty(user: LightUserRepresentation): boolean { return !user || (this.isEmpty(user.firstName) && this.isEmpty(user.lastName)); } diff --git a/ng2-components/ng2-activiti-tasklist/src/components/task-details.component.spec.ts b/ng2-components/ng2-activiti-tasklist/src/components/task-details.component.spec.ts index 36a4e1be27..890d382b15 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/task-details.component.spec.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/task-details.component.spec.ts @@ -24,19 +24,19 @@ import { Observable } from 'rxjs/Rx'; import { ActivitiFormModule, FormModel, FormOutcomeEvent, FormOutcomeModel, FormService } from 'ng2-activiti-form'; import { AppConfigService, CoreModule, LogService, TranslationService } from 'ng2-alfresco-core'; +import { LightUserRepresentation } from 'ng2-alfresco-core'; +import { PeopleProcessService } from 'ng2-alfresco-core'; import { AppConfigServiceMock } from '../assets/app-config.service.mock'; import { TranslationMock } from '../assets/translation.service.mock'; import { TaskDetailsModel } from '../models/task-details.model'; -import { User } from '../models/user.model'; import { noDataMock, taskDetailsMock, taskFormMock, tasksMock } from './../assets/task-details.mock'; -import { PeopleService } from './../services/people.service'; import { TaskListService } from './../services/tasklist.service'; import { PeopleSearchComponent } from './people-search.component'; import { TaskDetailsComponent } from './task-details.component'; declare let jasmine: any; -const fakeUser: User = new User({ +const fakeUser: LightUserRepresentation = new LightUserRepresentation({ id: 'fake-id', firstName: 'fake-name', lastName: 'fake-last', @@ -72,7 +72,7 @@ describe('TaskDetailsComponent', () => { ], providers: [ TaskListService, - PeopleService, + PeopleProcessService, { provide: TranslationService, useClass: TranslationMock }, { provide: AppConfigService, useClass: AppConfigServiceMock } ], diff --git a/ng2-components/ng2-activiti-tasklist/src/components/task-details.component.ts b/ng2-components/ng2-activiti-tasklist/src/components/task-details.component.ts index 6a4cc94734..78f1a1735e 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/task-details.component.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/task-details.component.ts @@ -28,11 +28,11 @@ import { Component, import { MdDialog, MdDialogRef } from '@angular/material'; import { ContentLinkModel, FormFieldValidator, FormModel, FormOutcomeEvent } from 'ng2-activiti-form'; import { AlfrescoAuthenticationService, CardViewUpdateService, ClickNotification, LogService, UpdateNotification } from 'ng2-alfresco-core'; +import { LightUserRepresentation } from 'ng2-alfresco-core'; +import { PeopleProcessService } from 'ng2-alfresco-core'; import { Observable, Observer } from 'rxjs/Rx'; import { TaskQueryRequestRepresentationModel } from '../models/filter.model'; import { TaskDetailsModel } from '../models/task-details.model'; -import { User } from '../models/user.model'; -import { PeopleService } from './../services/people.service'; import { TaskListService } from './../services/tasklist.service'; declare var require: any; @@ -131,24 +131,24 @@ export class TaskDetailsComponent implements OnInit, OnChanges { taskDetails: TaskDetailsModel; taskFormName: string = null; - taskPeople: User[] = []; + taskPeople: LightUserRepresentation[] = []; noTaskDetailsTemplateComponent: TemplateRef; showAssignee: boolean = false; - private peopleSearchObserver: Observer; + private peopleSearchObserver: Observer; public errorDialogRef: MdDialogRef>; - peopleSearch$: Observable; + peopleSearch$: Observable; constructor(private activitiTaskList: TaskListService, private authService: AlfrescoAuthenticationService, - private peopleService: PeopleService, + private peopleProcessService: PeopleProcessService, private logService: LogService, private cardViewUpdateService: CardViewUpdateService, private dialog: MdDialog) { - this.peopleSearch$ = new Observable(observer => this.peopleSearchObserver = observer).share(); + this.peopleSearch$ = new Observable(observer => this.peopleSearchObserver = observer).share(); } ngOnInit() { @@ -234,7 +234,7 @@ export class TaskDetailsComponent implements OnInit, OnChanges { this.readOnlyForm = this.readOnlyForm ? this.readOnlyForm : !!(endDate && !isNaN(endDate.getTime())); if (this.taskDetails && this.taskDetails.involvedPeople) { this.taskDetails.involvedPeople.forEach((user) => { - this.taskPeople.push(new User(user)); + this.taskPeople.push(new LightUserRepresentation(user)); }); } }); @@ -336,7 +336,7 @@ export class TaskDetailsComponent implements OnInit, OnChanges { } searchUser(searchedWord: string) { - this.peopleService.getWorkflowUsers(null, searchedWord) + this.peopleProcessService.getWorkflowUsers(null, searchedWord) .subscribe((users) => { users = users.filter((user) => user.id !== this.taskDetails.assignee.id); this.peopleSearchObserver.next(users); @@ -347,7 +347,7 @@ export class TaskDetailsComponent implements OnInit, OnChanges { this.showAssignee = false; } - assignTaskToUser(selectedUser: User) { + assignTaskToUser(selectedUser: LightUserRepresentation) { this.activitiTaskList.assignTask(this.taskDetails.id, selectedUser).subscribe( (res: any) => { this.logService.info('Task Assigned to ' + selectedUser.email); diff --git a/ng2-components/ng2-activiti-tasklist/src/components/task-header.component.spec.ts b/ng2-components/ng2-activiti-tasklist/src/components/task-header.component.spec.ts index 9c852c7656..14404397f2 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/task-header.component.spec.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/task-header.component.spec.ts @@ -23,6 +23,7 @@ import { Observable } from 'rxjs/Rx'; import { AppConfigServiceMock } from '../assets/app-config.service.mock'; import { TranslationMock } from '../assets/translation.service.mock'; +import { LightUserRepresentation } from '../../../ng2-alfresco-core/src/models/user-process.model'; import { TaskDetailsModel } from '../models/task-details.model'; import { taskDetailsMock } from './../assets/task-details.mock'; import { TaskListService } from './../services/tasklist.service'; @@ -138,7 +139,7 @@ describe('TaskHeaderComponent', () => { describe('Unclaim', () => { - const batman = { id : 1, email: 'bruce.wayne@gotham.com', firstName: 'Bruce', lastName: 'Wayne', userImage: 'batman.jpg' }; + const batman = new LightUserRepresentation({ id : 1, email: 'bruce.wayne@gotham.com', firstName: 'Bruce', lastName: 'Wayne', userImage: 'batman.jpg' }); let taskListService; beforeEach(() => { diff --git a/ng2-components/ng2-activiti-tasklist/src/models/comment.model.ts b/ng2-components/ng2-activiti-tasklist/src/models/comment.model.ts index ba7ab40c86..f41afafd09 100644 --- a/ng2-components/ng2-activiti-tasklist/src/models/comment.model.ts +++ b/ng2-components/ng2-activiti-tasklist/src/models/comment.model.ts @@ -22,15 +22,15 @@ * * @returns {Comment} . */ -import { User } from './user.model'; +import { LightUserRepresentation } from 'ng2-alfresco-core'; export class Comment { id: number; message: string; created: string; - createdBy: User; + createdBy: LightUserRepresentation; - constructor(id: number, message: string, created: string, createdBy: User) { + constructor(id: number, message: string, created: string, createdBy: LightUserRepresentation) { this.id = id; this.message = message; this.created = created; diff --git a/ng2-components/ng2-activiti-tasklist/src/models/start-task.model.ts b/ng2-components/ng2-activiti-tasklist/src/models/start-task.model.ts index b4f808e872..0e6f0b897d 100644 --- a/ng2-components/ng2-activiti-tasklist/src/models/start-task.model.ts +++ b/ng2-components/ng2-activiti-tasklist/src/models/start-task.model.ts @@ -22,13 +22,13 @@ * * @returns {StartTaskModel} . */ -import { User } from './user.model'; +import { LightUserRepresentation } from 'ng2-alfresco-core'; export class StartTaskModel { name: string; description: string; - assignee: User; + assignee: LightUserRepresentation; dueDate: any; formKey: any; category: string; @@ -36,7 +36,7 @@ export class StartTaskModel { constructor(obj?: any) { this.name = obj && obj.name || null; this.description = obj && obj.description || null; - this.assignee = obj && obj.assignee ? new User(obj.assignee) : null; + this.assignee = obj && obj.assignee ? new LightUserRepresentation(obj.assignee) : null; this.dueDate = obj && obj.dueDate || null; this.formKey = obj && obj.formKey || null; this.category = obj && obj.category || null; diff --git a/ng2-components/ng2-activiti-tasklist/src/models/task-details.model.ts b/ng2-components/ng2-activiti-tasklist/src/models/task-details.model.ts index 329a56d68e..a2c36bacc2 100644 --- a/ng2-components/ng2-activiti-tasklist/src/models/task-details.model.ts +++ b/ng2-components/ng2-activiti-tasklist/src/models/task-details.model.ts @@ -22,12 +22,12 @@ * * @returns {TaskDetailsModel} . */ -import { User } from './user.model'; +import { LightUserRepresentation } from 'ng2-alfresco-core'; export class TaskDetailsModel { id: string; name: string; - assignee: User; + assignee: LightUserRepresentation; priority: number; adhocTaskCanBeReassigned: number; category: string; @@ -42,7 +42,7 @@ export class TaskDetailsModel { managerOfCandidateGroup: boolean; memberOfCandidateGroup: boolean; memberOfCandidateUsers: boolean; - involvedPeople: User []; + involvedPeople: LightUserRepresentation []; parentTaskId: string; parentTaskName: string; processDefinitionCategory: string; @@ -62,7 +62,7 @@ export class TaskDetailsModel { this.id = obj.id || null; this.name = obj.name || null; this.priority = obj.priority; - this.assignee = obj.assignee ? new User(obj.assignee) : null; + this.assignee = obj.assignee ? new LightUserRepresentation(obj.assignee) : null; this.adhocTaskCanBeReassigned = obj.adhocTaskCanBeReassigned; this.category = obj.category || null; this.created = obj.created || null; diff --git a/ng2-components/ng2-activiti-tasklist/src/services/tasklist.service.spec.ts b/ng2-components/ng2-activiti-tasklist/src/services/tasklist.service.spec.ts index 954ab9bb5b..f8403e5d72 100644 --- a/ng2-components/ng2-activiti-tasklist/src/services/tasklist.service.spec.ts +++ b/ng2-components/ng2-activiti-tasklist/src/services/tasklist.service.spec.ts @@ -17,6 +17,7 @@ import { async, TestBed } from '@angular/core/testing'; import { AppConfigService, CoreModule, TranslationService } from 'ng2-alfresco-core'; +import { LightUserRepresentation } from 'ng2-alfresco-core'; import { Observable } from 'rxjs/Rx'; import { AppConfigServiceMock } from '../assets/app-config.service.mock'; import { @@ -43,7 +44,6 @@ import { TranslationMock } from '../assets/translation.service.mock'; import { Comment } from '../models/comment.model'; import { FilterRepresentationModel, TaskQueryRequestRepresentationModel } from '../models/filter.model'; import { TaskDetailsModel } from '../models/task-details.model'; -import { User } from '../models/user.model'; import { TaskListService } from './tasklist.service'; declare let jasmine: any; @@ -679,7 +679,7 @@ describe('Activiti TaskList Service', () => { expect(res.category).toEqual('3'); expect(res.created).not.toEqual(''); expect(res.adhocTaskCanBeReassigned).toBe(true); - expect(res.assignee).toEqual(new User(fakeUser2)); + expect(res.assignee).toEqual(new LightUserRepresentation(fakeUser2)); expect(res.involvedPeople).toEqual([fakeUser1]); done(); } @@ -712,7 +712,7 @@ describe('Activiti TaskList Service', () => { expect(res.category).toEqual('3'); expect(res.created).not.toEqual(''); expect(res.adhocTaskCanBeReassigned).toBe(true); - expect(res.assignee).toEqual(new User(fakeUser2)); + expect(res.assignee).toEqual(new LightUserRepresentation(fakeUser2)); expect(res.involvedPeople).toEqual([fakeUser1]); done(); } diff --git a/ng2-components/ng2-activiti-tasklist/src/services/tasklist.service.ts b/ng2-components/ng2-activiti-tasklist/src/services/tasklist.service.ts index d160f14bf5..468deab911 100644 --- a/ng2-components/ng2-activiti-tasklist/src/services/tasklist.service.ts +++ b/ng2-components/ng2-activiti-tasklist/src/services/tasklist.service.ts @@ -17,6 +17,7 @@ import { Injectable } from '@angular/core'; import { AlfrescoApiService, LogService } from 'ng2-alfresco-core'; +import { LightUserRepresentation } from 'ng2-alfresco-core'; import { Observable, Subject } from 'rxjs/Rx'; import { Comment } from '../models/comment.model'; import { @@ -26,7 +27,6 @@ import { import { Form } from '../models/form.model'; import { TaskDetailsModel } from '../models/task-details.model'; import { TaskListModel } from '../models/task-list.model'; -import { User } from '../models/user.model'; @Injectable() export class TaskListService { @@ -231,7 +231,7 @@ export class TaskListService { .map((response: any) => { let comments: Comment[] = []; response.data.forEach((comment) => { - let user = new User(comment.createdBy); + let user = new LightUserRepresentation(comment.createdBy); comments.push(new Comment(comment.id, comment.message, comment.created, user)); }); return comments; diff --git a/ng2-components/ng2-alfresco-core/index.ts b/ng2-components/ng2-alfresco-core/index.ts index 2d95f99943..3d5e2a0791 100644 --- a/ng2-components/ng2-alfresco-core/index.ts +++ b/ng2-components/ng2-alfresco-core/index.ts @@ -61,7 +61,8 @@ import { DiscoveryApiService } from './src/services/discovery-api.service'; import { FavoritesApiService } from './src/services/favorites-api.service'; import { HighlightTransformService } from './src/services/highlight-transform.service'; import { NodesApiService } from './src/services/nodes-api.service'; -import { PeopleApiService } from './src/services/people-api.service'; +import { PeopleContentService } from './src/services/people-content.service'; +import { PeopleProcessService } from './src/services/people-process.service'; import { SearchApiService } from './src/services/search-api.service'; import { SearchService } from './src/services/search.service'; import { SharedLinksApiService } from './src/services/shared-links-api.service'; @@ -103,7 +104,8 @@ export { HighlightTransformService, HightlightTransformResult } from './src/serv export { DeletedNodesApiService } from './src/services/deleted-nodes-api.service'; export { FavoritesApiService } from './src/services/favorites-api.service'; export { NodesApiService } from './src/services/nodes-api.service'; -export { PeopleApiService } from './src/services/people-api.service'; +export { PeopleContentService } from './src/services/people-content.service'; +export { PeopleProcessService } from './src/services/people-process.service'; export { SearchApiService } from './src/services/search-api.service'; export { SharedLinksApiService } from './src/services/shared-links-api.service'; export { SitesApiService } from './src/services/sites-api.service'; @@ -156,6 +158,7 @@ export * from './src/models/file.model'; export * from './src/models/permissions.enum'; export * from './src/models/site.model'; export * from './src/models/product-version.model'; +export * from './src/models/user-process.model'; // Old deprecated import import { AuthenticationService as AlfrescoAuthenticationService } from './src/services/authentication.service'; @@ -190,13 +193,14 @@ export function providers() { DeletedNodesApiService, FavoritesApiService, NodesApiService, - PeopleApiService, + PeopleContentService, SearchApiService, SharedLinksApiService, SitesApiService, DiscoveryApiService, HighlightTransformService, - MomentDateAdapter + MomentDateAdapter, + PeopleProcessService ]; } diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/core/group-user.model.ts b/ng2-components/ng2-alfresco-core/src/assets/app-config.service.mock.ts similarity index 55% rename from ng2-components/ng2-activiti-form/src/components/widgets/core/group-user.model.ts rename to ng2-components/ng2-alfresco-core/src/assets/app-config.service.mock.ts index c48482fa11..c15002972a 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/core/group-user.model.ts +++ b/ng2-components/ng2-alfresco-core/src/assets/app-config.service.mock.ts @@ -15,25 +15,16 @@ * limitations under the License. */ - /* tslint:disable:component-selector */ +import { Injectable } from '@angular/core'; -export class GroupUserModel { +@Injectable() +export class AppConfigServiceMock { - company: string; - email: string; - firstName: string; - id: string; - lastName: string; - userImage: string; + constructor() { } + + /** @override */ + get(key: string) { } + + load(resource: string, values?: {}) { } - constructor(json?: any) { - if (json) { - this.company = json.company; - this.email = json.email; - this.firstName = json.firstName; - this.id = json.id; - this.lastName = json.lastName; - this.userImage = json.userImage; - } - } } diff --git a/ng2-components/ng2-activiti-tasklist/src/models/user.model.ts b/ng2-components/ng2-alfresco-core/src/models/user-process.model.ts similarity index 84% rename from ng2-components/ng2-activiti-tasklist/src/models/user.model.ts rename to ng2-components/ng2-alfresco-core/src/models/user-process.model.ts index 34b0e73f3f..f53d73a08c 100644 --- a/ng2-components/ng2-activiti-tasklist/src/models/user.model.ts +++ b/ng2-components/ng2-alfresco-core/src/models/user-process.model.ts @@ -16,19 +16,15 @@ */ /** - * - * This object represent the user. - * - * - * @returns {User} . + * This object represent the process service user.* */ -export class User { +export class LightUserRepresentation { id: number; email: string; firstName: string; lastName: string; - userImage: string = null; + pictureId: number = null; constructor(obj?: any) { if (obj) { @@ -36,6 +32,8 @@ export class User { this.email = obj.email || null; this.firstName = obj.firstName || null; this.lastName = obj.lastName || null; + this.pictureId = obj.pictureId || null; } } + } diff --git a/ng2-components/ng2-alfresco-core/src/services/auth-guard-ecm.service.spec.ts b/ng2-components/ng2-alfresco-core/src/services/auth-guard-ecm.service.spec.ts index 27cf7e9a84..a6b5feead1 100644 --- a/ng2-components/ng2-alfresco-core/src/services/auth-guard-ecm.service.spec.ts +++ b/ng2-components/ng2-alfresco-core/src/services/auth-guard-ecm.service.spec.ts @@ -17,8 +17,7 @@ import { async, inject, TestBed } from '@angular/core/testing'; import { Router } from '@angular/router'; -import { AlfrescoApiService } from 'ng2-alfresco-core'; - +import { AlfrescoApiService } from './alfresco-api.service'; import { AuthGuardEcm } from './auth-guard-ecm.service'; class RouterProvider { diff --git a/ng2-components/ng2-alfresco-core/src/services/people-api.service.spec.ts b/ng2-components/ng2-alfresco-core/src/services/people-content.service.spec.ts similarity index 89% rename from ng2-components/ng2-alfresco-core/src/services/people-api.service.spec.ts rename to ng2-components/ng2-alfresco-core/src/services/people-content.service.spec.ts index 38e2e9556d..231c965d3d 100644 --- a/ng2-components/ng2-alfresco-core/src/services/people-api.service.spec.ts +++ b/ng2-components/ng2-alfresco-core/src/services/people-content.service.spec.ts @@ -17,9 +17,9 @@ import { async, inject, TestBed } from '@angular/core/testing'; import { AlfrescoApiService } from './alfresco-api.service'; -import { PeopleApiService } from './people-api.service'; +import { PeopleContentService } from './people-content.service'; -class PeopleApiServiceTest { +class PeopleContentServiceTest { service: any = null; setup: any = { rejectGetPerson: false @@ -38,11 +38,11 @@ class PeopleApiServiceTest { TestBed.configureTestingModule({ providers: [ alfrescoApiServiceProvider, - PeopleApiService + PeopleContentService ] }); - inject([ PeopleApiService ], (service) => { + inject([ PeopleContentService ], (service) => { this.service = service; })(); } @@ -81,7 +81,7 @@ class PeopleApiServiceTest { describe('PeopleAPI', () => { describe('Get persons', () => { it('calls method by an id', async(() => { - const test = new PeopleApiServiceTest(); + const test = new PeopleContentServiceTest(); test.service.getPerson('person-1').subscribe(() => { expect(test.peopleApiGetPersonArguments[0]) @@ -90,7 +90,7 @@ describe('PeopleAPI', () => { })); it('calls method with "-me-"', async(() => { - const test = new PeopleApiServiceTest(); + const test = new PeopleContentServiceTest(); test.service.getCurrentPerson().subscribe(() => { expect(test.peopleApiGetPersonArguments[0]) @@ -99,7 +99,7 @@ describe('PeopleAPI', () => { })); it('handles the error when it fails', async(() => { - const test = new PeopleApiServiceTest({ + const test = new PeopleContentServiceTest({ rejectGetPerson: true }); diff --git a/ng2-components/ng2-alfresco-core/src/services/people-api.service.ts b/ng2-components/ng2-alfresco-core/src/services/people-content.service.ts similarity index 97% rename from ng2-components/ng2-alfresco-core/src/services/people-api.service.ts rename to ng2-components/ng2-alfresco-core/src/services/people-content.service.ts index 89bd9d95b3..cb985c1ba1 100644 --- a/ng2-components/ng2-alfresco-core/src/services/people-api.service.ts +++ b/ng2-components/ng2-alfresco-core/src/services/people-content.service.ts @@ -20,7 +20,7 @@ import { Observable } from 'rxjs/Rx'; import { AlfrescoApiService } from './alfresco-api.service'; @Injectable() -export class PeopleApiService { +export class PeopleContentService { constructor(private apiService: AlfrescoApiService) {} diff --git a/ng2-components/ng2-activiti-tasklist/src/services/people.service.spec.ts b/ng2-components/ng2-alfresco-core/src/services/people-process.service.spec.ts similarity index 80% rename from ng2-components/ng2-activiti-tasklist/src/services/people.service.spec.ts rename to ng2-components/ng2-alfresco-core/src/services/people-process.service.spec.ts index c97e242c9d..c599124605 100644 --- a/ng2-components/ng2-activiti-tasklist/src/services/people.service.spec.ts +++ b/ng2-components/ng2-alfresco-core/src/services/people-process.service.spec.ts @@ -16,44 +16,47 @@ */ import { TestBed } from '@angular/core/testing'; -import { AppConfigService, CoreModule } from 'ng2-alfresco-core'; import { AppConfigServiceMock } from '../assets/app-config.service.mock'; -import { User } from '../models/user.model'; -import { PeopleService } from './people.service'; +import { LightUserRepresentation } from '../models/user-process.model'; +import { AlfrescoApiService } from './alfresco-api.service'; +import { AppConfigService } from './app-config.service'; +import { LogService } from './log.service'; +import { PeopleProcessService } from './people-process.service'; +import { StorageService } from './storage.service'; declare let jasmine: any; -const firstInvolvedUser: User = new User({ +const firstInvolvedUser: LightUserRepresentation = new LightUserRepresentation({ id: '1', email: 'fake-user1@fake.com', firstName: 'fakeName1', lastName: 'fakeLast1' }); -const secondInvolvedUser: User = new User({ +const secondInvolvedUser: LightUserRepresentation = new LightUserRepresentation({ id: '2', email: 'fake-user2@fake.com', firstName: 'fakeName2', lastName: 'fakeLast2' }); -const fakeInvolveUserList: User[] = [firstInvolvedUser, secondInvolvedUser]; +const fakeInvolveUserList: LightUserRepresentation[] = [firstInvolvedUser, secondInvolvedUser]; -describe('PeopleService', () => { +describe('PeopleProcessService', () => { - let service: PeopleService; + let service: PeopleProcessService; beforeEach(() => { TestBed.configureTestingModule({ - imports: [ - CoreModule - ], providers: [ - PeopleService, + PeopleProcessService, + AlfrescoApiService, + StorageService, + LogService, { provide: AppConfigService, useClass: AppConfigServiceMock } ] }); - service = TestBed.get(PeopleService); + service = TestBed.get(PeopleProcessService); }); describe('when user is logged in', () => { @@ -68,7 +71,7 @@ describe('PeopleService', () => { it('should be able to retrieve people to involve in the task', (done) => { service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe( - (users: User[]) => { + (users: LightUserRepresentation[]) => { expect(users).toBeDefined(); expect(users.length).toBe(2); expect(users[0].id).toEqual('1'); @@ -85,12 +88,12 @@ describe('PeopleService', () => { }); it('should be able to get people images for people retrieved', (done) => { - service.getWorkflowUsersWithImages('fake-task-id', 'fake-filter').subscribe( - (users: User[]) => { + service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe( + (users: LightUserRepresentation[]) => { expect(users).toBeDefined(); expect(users.length).toBe(2); - expect(users[0].userImage).toContain('/users/' + users[0].id + '/picture'); - expect(users[1].userImage).toContain('/users/' + users[1].id + '/picture'); + expect(service.getUserImage(users[0])).toContain('/users/' + users[0].id + '/picture'); + expect(service.getUserImage(users[1])).toContain('/users/' + users[1].id + '/picture'); done(); }); jasmine.Ajax.requests.mostRecent().respondWith({ @@ -100,16 +103,6 @@ describe('PeopleService', () => { }); }); - it('should be able to return user with image url', (done) => { - service.addImageToUser(firstInvolvedUser).subscribe( - (user: User) => { - expect(user).toBeDefined(); - expect(user.userImage).toContain('/users/' + user.id + '/picture'); - expect(user.id).toBe('1'); - done(); - }); - }); - it('should return user image url', () => { let url = service.getUserImage(firstInvolvedUser); @@ -118,7 +111,7 @@ describe('PeopleService', () => { it('should return empty list when there are no users to involve', (done) => { service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe( - (users: User[]) => { + (users: LightUserRepresentation[]) => { expect(users).toBeDefined(); expect(users.length).toBe(0); done(); diff --git a/ng2-components/ng2-activiti-tasklist/src/services/people.service.ts b/ng2-components/ng2-alfresco-core/src/services/people-process.service.ts similarity index 74% rename from ng2-components/ng2-activiti-tasklist/src/services/people.service.ts rename to ng2-components/ng2-alfresco-core/src/services/people-process.service.ts index b3b8e32c05..735d396062 100644 --- a/ng2-components/ng2-activiti-tasklist/src/services/people.service.ts +++ b/ng2-components/ng2-alfresco-core/src/services/people-process.service.ts @@ -17,49 +17,36 @@ import { Injectable } from '@angular/core'; import { Response } from '@angular/http'; -import { AlfrescoApiService, LogService } from 'ng2-alfresco-core'; import { Observable } from 'rxjs/Rx'; -import { User } from '../models/user.model'; +import { LightUserRepresentation } from '../models/user-process.model'; +import { AlfrescoApiService } from './alfresco-api.service'; +import { LogService } from './log.service'; @Injectable() -export class PeopleService { +export class PeopleProcessService { constructor(private alfrescoJsApi: AlfrescoApiService, private logService: LogService) { } - getWorkflowUsers(taskId?: string, searchWord?: string): Observable { + getWorkflowUsers(taskId?: string, searchWord?: string): Observable { let option = { excludeTaskId: taskId, filter: searchWord }; return Observable.fromPromise(this.getWorkflowUserApi(option)) - .map((response: any) => response.data || []) + .map((response: any) => response.data || []) .catch(err => this.handleError(err)); } - getWorkflowUsersWithImages(taskId?: string, searchWord?: string): Observable { - let option = { excludeTaskId: taskId, filter: searchWord }; - return Observable.fromPromise(this.getWorkflowUserApi(option)) - .switchMap((response: any) => response.data || []) - .map((user: User) => this.addImageToUser(user)) - .combineAll() - .catch(err => this.handleError(err)); - } - - getUserImage(user: User): string { + getUserImage(user: LightUserRepresentation): string { return this.getUserProfileImageApi(user.id + ''); } - addImageToUser(user: User): Observable { - user.userImage = this.getUserImage(user); - return Observable.of(user); - } - - involveUserWithTask(taskId: string, idToInvolve: string): Observable { + involveUserWithTask(taskId: string, idToInvolve: string): Observable { let node = {userId: idToInvolve}; return Observable.fromPromise(this.involveUserToTaskApi(taskId, node)) .catch(err => this.handleError(err)); } - removeInvolvedUser(taskId: string, idToRemove: string): Observable { + removeInvolvedUser(taskId: string, idToRemove: string): Observable { let node = {userId: idToRemove}; return Observable.fromPromise(this.removeInvolvedUserFromTaskApi(taskId, node)) .catch(err => this.handleError(err));