mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
fix user model process service and image loading (#2431)
This commit is contained in:
@@ -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)
|
- [*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)
|
- [*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)
|
- [*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 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)
|
- [*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)
|
- [*Shared links api service](ng2-components/ng2-alfresco-core/src/services/shared-links-api.service.ts)
|
||||||
|
@@ -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: '<company>',
|
|
||||||
email: '<email>',
|
|
||||||
firstName: '<firstName>',
|
|
||||||
id: '<id>',
|
|
||||||
lastName: '<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);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
@@ -23,10 +23,9 @@
|
|||||||
<div class="adf-people-widget-pic">
|
<div class="adf-people-widget-pic">
|
||||||
{{getInitialUserName(user.firstName, user.lastName)}}
|
{{getInitialUserName(user.firstName, user.lastName)}}
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="user.userImage" class="adf-people-widget-image-row">
|
<div *ngIf="user.pictureId" class="adf-people-widget-image-row">
|
||||||
<img id="adf-people-widget-pic-{{i}}" class="adf-people-widget-image"
|
<img id="adf-people-widget-pic-{{i}}" class="adf-people-widget-image"
|
||||||
[src]="user.userImage"
|
[src]="peopleProcessService.getUserImage(user)"/>
|
||||||
(error)="onErrorImageLoad(user)"/>
|
|
||||||
</div>
|
</div>
|
||||||
<span class="adf-people-label-name">{{getDisplayName(user)}}</span>
|
<span class="adf-people-label-name">{{getDisplayName(user)}}</span>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -16,14 +16,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
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 { Observable } from 'rxjs/Rx';
|
||||||
import { ActivitiAlfrescoContentService } from '../../../services/activiti-alfresco.service';
|
import { ActivitiAlfrescoContentService } from '../../../services/activiti-alfresco.service';
|
||||||
import { FormService } from '../../../services/form.service';
|
import { FormService } from '../../../services/form.service';
|
||||||
import { MaterialModule } from '../../material.module';
|
import { MaterialModule } from '../../material.module';
|
||||||
import { FormFieldModel } from '../core/form-field.model';
|
import { FormFieldModel } from '../core/form-field.model';
|
||||||
import { FormModel } from '../core/form.model';
|
import { FormModel } from '../core/form.model';
|
||||||
import { GroupUserModel } from '../core/group-user.model';
|
|
||||||
import { ErrorWidgetComponent } from '../error/error.component';
|
import { ErrorWidgetComponent } from '../error/error.component';
|
||||||
import { EcmModelService } from './../../../services/ecm-model.service';
|
import { EcmModelService } from './../../../services/ecm-model.service';
|
||||||
import { PeopleWidgetComponent } from './people.widget';
|
import { PeopleWidgetComponent } from './people.widget';
|
||||||
@@ -68,7 +67,7 @@ describe('PeopleWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return full name for a given model', () => {
|
it('should return full name for a given model', () => {
|
||||||
let model = new GroupUserModel({
|
let model = new LightUserRepresentation({
|
||||||
firstName: 'John',
|
firstName: 'John',
|
||||||
lastName: 'Doe'
|
lastName: 'Doe'
|
||||||
});
|
});
|
||||||
@@ -76,17 +75,17 @@ describe('PeopleWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should skip first name for display name', () => {
|
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');
|
expect(widget.getDisplayName(model)).toBe('Doe');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should skip last name for display name', () => {
|
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');
|
expect(widget.getDisplayName(model)).toBe('John');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should init value from the field', () => {
|
it('should init value from the field', () => {
|
||||||
widget.field.value = new GroupUserModel({
|
widget.field.value = new LightUserRepresentation({
|
||||||
firstName: 'John',
|
firstName: 'John',
|
||||||
lastName: 'Doe'
|
lastName: 'Doe'
|
||||||
});
|
});
|
||||||
@@ -109,7 +108,7 @@ describe('PeopleWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should update values on item click', () => {
|
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);
|
widget.onItemClick(item, null);
|
||||||
expect(widget.field.value).toBe(item);
|
expect(widget.field.value).toBe(item);
|
||||||
@@ -213,8 +212,8 @@ describe('PeopleWidgetComponent', () => {
|
|||||||
|
|
||||||
it('should flush value and update field', () => {
|
it('should flush value and update field', () => {
|
||||||
widget.users = [
|
widget.users = [
|
||||||
new GroupUserModel({firstName: 'Tony', lastName: 'Stark'}),
|
new LightUserRepresentation({firstName: 'Tony', lastName: 'Stark'}),
|
||||||
new GroupUserModel({firstName: 'John', lastName: 'Doe'})
|
new LightUserRepresentation({firstName: 'John', lastName: 'Doe'})
|
||||||
];
|
];
|
||||||
widget.value = 'John Doe';
|
widget.value = 'John Doe';
|
||||||
widget.flushValue();
|
widget.flushValue();
|
||||||
@@ -225,8 +224,8 @@ describe('PeopleWidgetComponent', () => {
|
|||||||
|
|
||||||
it('should be case insensitive when flushing field', () => {
|
it('should be case insensitive when flushing field', () => {
|
||||||
widget.users = [
|
widget.users = [
|
||||||
new GroupUserModel({firstName: 'Tony', lastName: 'Stark'}),
|
new LightUserRepresentation({firstName: 'Tony', lastName: 'Stark'}),
|
||||||
new GroupUserModel({firstName: 'John', lastName: 'Doe'})
|
new LightUserRepresentation({firstName: 'John', lastName: 'Doe'})
|
||||||
];
|
];
|
||||||
widget.value = 'TONY sTaRk';
|
widget.value = 'TONY sTaRk';
|
||||||
widget.flushValue();
|
widget.flushValue();
|
||||||
|
@@ -20,8 +20,8 @@
|
|||||||
import { ENTER, ESCAPE } from '@angular/cdk/keycodes';
|
import { ENTER, ESCAPE } from '@angular/cdk/keycodes';
|
||||||
import { Component, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
|
import { Component, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
|
||||||
import { MdAutocompleteTrigger } from '@angular/material';
|
import { MdAutocompleteTrigger } from '@angular/material';
|
||||||
|
import { LightUserRepresentation, PeopleProcessService } from 'ng2-alfresco-core';
|
||||||
import { FormService } from '../../../services/form.service';
|
import { FormService } from '../../../services/form.service';
|
||||||
import { GroupUserModel } from '../core/group-user.model';
|
|
||||||
import { GroupModel } from '../core/group.model';
|
import { GroupModel } from '../core/group.model';
|
||||||
import { baseHost , WidgetComponent } from './../widget.component';
|
import { baseHost , WidgetComponent } from './../widget.component';
|
||||||
|
|
||||||
@@ -40,16 +40,16 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
|
|||||||
minTermLength: number = 1;
|
minTermLength: number = 1;
|
||||||
value: string;
|
value: string;
|
||||||
oldValue: string;
|
oldValue: string;
|
||||||
users: GroupUserModel[] = [];
|
users: LightUserRepresentation[] = [];
|
||||||
groupId: string;
|
groupId: string;
|
||||||
|
|
||||||
constructor(public formService: FormService) {
|
constructor(public formService: FormService, public peopleProcessService: PeopleProcessService) {
|
||||||
super(formService);
|
super(formService);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.field) {
|
if (this.field) {
|
||||||
let user: GroupUserModel = this.field.value;
|
let user: LightUserRepresentation = this.field.value;
|
||||||
if (user) {
|
if (user) {
|
||||||
this.value = this.getDisplayName(user);
|
this.value = this.getDisplayName(user);
|
||||||
}
|
}
|
||||||
@@ -75,17 +75,11 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
|
|||||||
|
|
||||||
searchUsers() {
|
searchUsers() {
|
||||||
this.formService.getWorkflowUsers(this.value, this.groupId)
|
this.formService.getWorkflowUsers(this.value, this.groupId)
|
||||||
.subscribe((result: GroupUserModel[]) => {
|
.subscribe((result: LightUserRepresentation[]) => {
|
||||||
this.users = result || [];
|
this.users = result || [];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onErrorImageLoad(user) {
|
|
||||||
if (user.userImage) {
|
|
||||||
user.userImage = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
flushValue() {
|
flushValue() {
|
||||||
let option = this.users.find(item => {
|
let option = this.users.find(item => {
|
||||||
let fullName = this.getDisplayName(item).toLocaleLowerCase();
|
let fullName = this.getDisplayName(item).toLocaleLowerCase();
|
||||||
@@ -103,7 +97,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
|
|||||||
this.field.updateForm();
|
this.field.updateForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
getDisplayName(model: GroupUserModel) {
|
getDisplayName(model: LightUserRepresentation) {
|
||||||
if (model) {
|
if (model) {
|
||||||
let displayName = `${model.firstName || ''} ${model.lastName || ''}`;
|
let displayName = `${model.firstName || ''} ${model.lastName || ''}`;
|
||||||
return displayName.trim();
|
return displayName.trim();
|
||||||
@@ -112,7 +106,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
onItemClick(item: GroupUserModel, event: Event) {
|
onItemClick(item: LightUserRepresentation, event: Event) {
|
||||||
if (item) {
|
if (item) {
|
||||||
this.field.value = item;
|
this.field.value = item;
|
||||||
this.value = this.getDisplayName(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) {
|
if (item) {
|
||||||
this.field.value = item;
|
this.field.value = item;
|
||||||
this.value = this.getDisplayName(item);
|
this.value = this.getDisplayName(item);
|
||||||
|
@@ -16,11 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
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 { Observable, Subject } from 'rxjs/Rx';
|
||||||
import { FormDefinitionModel } from '../models/form-definition.model';
|
import { FormDefinitionModel } from '../models/form-definition.model';
|
||||||
import { ContentLinkModel } from './../components/widgets/core/content-link.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 { GroupModel } from './../components/widgets/core/group.model';
|
||||||
import { FormModel, FormOutcomeEvent, FormOutcomeModel, FormValues } from './../components/widgets/core/index';
|
import { FormModel, FormOutcomeEvent, FormOutcomeModel, FormValues } from './../components/widgets/core/index';
|
||||||
import {
|
import {
|
||||||
@@ -376,13 +375,13 @@ export class FormService {
|
|||||||
return this.apiService.getInstance().activiti.userApi.getUserProfilePictureUrl(userId);
|
return this.apiService.getInstance().activiti.userApi.getUserProfilePictureUrl(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
getWorkflowUsers(filter: string, groupId?: string): Observable<GroupUserModel[]> {
|
getWorkflowUsers(filter: string, groupId?: string): Observable<LightUserRepresentation[]> {
|
||||||
let option: any = {filter: filter};
|
let option: any = {filter: filter};
|
||||||
if (groupId) {
|
if (groupId) {
|
||||||
option.groupId = groupId;
|
option.groupId = groupId;
|
||||||
}
|
}
|
||||||
return Observable.fromPromise(this.usersWorkflowApi.getUsers(option))
|
return Observable.fromPromise(this.usersWorkflowApi.getUsers(option))
|
||||||
.switchMap((response: any) => <GroupUserModel[]> response.data || [])
|
.switchMap((response: any) => <LightUserRepresentation[]> response.data || [])
|
||||||
.map((user: any) => {
|
.map((user: any) => {
|
||||||
user.userImage = this.getUserProfileImageApi(user.id);
|
user.userImage = this.getUserProfileImageApi(user.id);
|
||||||
return Observable.of(user);
|
return Observable.of(user);
|
||||||
|
@@ -15,14 +15,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { AppDefinitionRepresentationModel, Comment, TaskDetailsModel } from 'ng2-activiti-tasklist';
|
||||||
AppDefinitionRepresentationModel,
|
|
||||||
Comment,
|
|
||||||
TaskDetailsModel,
|
|
||||||
User
|
|
||||||
} from 'ng2-activiti-tasklist';
|
|
||||||
import { FilterProcessRepresentationModel } from '../models/filter-process.model';
|
import { FilterProcessRepresentationModel } from '../models/filter-process.model';
|
||||||
import { ProcessDefinitionRepresentation } from '../models/process-definition.model';
|
import { ProcessDefinitionRepresentation } from '../models/process-definition.model';
|
||||||
|
import { LightUserRepresentation } from 'ng2-alfresco-core';
|
||||||
|
|
||||||
export let fakeFilters = {
|
export let fakeFilters = {
|
||||||
size: 1, total: 1, start: 0,
|
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,
|
id: 13,
|
||||||
firstName: 'Wilbur',
|
firstName: 'Wilbur',
|
||||||
lastName: 'Adams',
|
lastName: 'Adams',
|
||||||
|
@@ -23,10 +23,9 @@ import { Observable } from 'rxjs/Rx';
|
|||||||
import {
|
import {
|
||||||
CommentListComponent,
|
CommentListComponent,
|
||||||
CommentsComponent,
|
CommentsComponent,
|
||||||
PeopleService,
|
|
||||||
TaskListService
|
TaskListService
|
||||||
} from 'ng2-activiti-tasklist';
|
} 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 { DataTableModule } from 'ng2-alfresco-datatable';
|
||||||
|
|
||||||
import { TranslationMock } from './../assets/translation.service.mock';
|
import { TranslationMock } from './../assets/translation.service.mock';
|
||||||
@@ -57,7 +56,7 @@ describe('ActivitiProcessInstanceComments', () => {
|
|||||||
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
|
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
|
||||||
{ provide: TaskListService, useClass: ProcessService },
|
{ provide: TaskListService, useClass: ProcessService },
|
||||||
DatePipe,
|
DatePipe,
|
||||||
PeopleService
|
PeopleProcessService
|
||||||
]
|
]
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
}));
|
}));
|
||||||
|
@@ -20,9 +20,8 @@ import { RestVariable } from 'alfresco-js-api';
|
|||||||
import {
|
import {
|
||||||
Comment,
|
Comment,
|
||||||
TaskDetailsModel,
|
TaskDetailsModel,
|
||||||
TaskListService,
|
TaskListService } from 'ng2-activiti-tasklist';
|
||||||
User } from 'ng2-activiti-tasklist';
|
import { AlfrescoApiService, LightUserRepresentation, LogService } from 'ng2-alfresco-core';
|
||||||
import { AlfrescoApiService, LogService } from 'ng2-alfresco-core';
|
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { FilterProcessRepresentationModel } from '../models/filter-process.model';
|
import { FilterProcessRepresentationModel } from '../models/filter-process.model';
|
||||||
import { ProcessDefinitionRepresentation } from '../models/process-definition.model';
|
import { ProcessDefinitionRepresentation } from '../models/process-definition.model';
|
||||||
@@ -234,7 +233,7 @@ export class ProcessService extends TaskListService {
|
|||||||
.map((response: any) => {
|
.map((response: any) => {
|
||||||
let comments: Comment[] = [];
|
let comments: Comment[] = [];
|
||||||
response.data.forEach((comment) => {
|
response.data.forEach((comment) => {
|
||||||
let user = new User({
|
let user = new LightUserRepresentation({
|
||||||
id: comment.createdBy.id,
|
id: comment.createdBy.id,
|
||||||
email: comment.createdBy.email,
|
email: comment.createdBy.email,
|
||||||
firstName: comment.createdBy.firstName,
|
firstName: comment.createdBy.firstName,
|
||||||
|
@@ -23,7 +23,6 @@ import { ActivitiFormModule } from 'ng2-activiti-form';
|
|||||||
import { CoreModule, TRANSLATION_PROVIDER } from 'ng2-alfresco-core';
|
import { CoreModule, TRANSLATION_PROVIDER } from 'ng2-alfresco-core';
|
||||||
import { DataTableModule } from 'ng2-alfresco-datatable';
|
import { DataTableModule } from 'ng2-alfresco-datatable';
|
||||||
import { MaterialModule } from './src/components/material.module';
|
import { MaterialModule } from './src/components/material.module';
|
||||||
import { PeopleService } from './src/services/people.service';
|
|
||||||
import { ProcessUploadService } from './src/services/process-upload.service';
|
import { ProcessUploadService } from './src/services/process-upload.service';
|
||||||
import { TaskListService } from './src/services/tasklist.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 {CommentListComponent } from './src/components/comment-list.component';
|
||||||
|
|
||||||
export { TaskListService } from './src/services/tasklist.service';
|
export { TaskListService } from './src/services/tasklist.service';
|
||||||
export { PeopleService } from './src/services/people.service';
|
|
||||||
export { ProcessUploadService } from './src/services/process-upload.service';
|
export { ProcessUploadService } from './src/services/process-upload.service';
|
||||||
|
|
||||||
// Old Deprecated export
|
// 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 {TaskFiltersComponent as ActivitiFilters } from './src/components/task-filters.component';
|
||||||
import {TaskHeaderComponent as ActivitiTaskHeader } from './src/components/task-header.component';
|
import {TaskHeaderComponent as ActivitiTaskHeader } from './src/components/task-header.component';
|
||||||
import {TaskListComponent as ActivitiTaskList } from './src/components/tasklist.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';
|
import {TaskListService as ActivitiTaskListService } from './src/services/tasklist.service';
|
||||||
export {AppsListComponent as ActivitiApps} from './src/components/apps-list.component';
|
export {AppsListComponent as ActivitiApps} from './src/components/apps-list.component';
|
||||||
export {ChecklistComponent as ActivitiChecklist} from './src/components/checklist.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 {TaskFiltersComponent as ActivitiFilters } from './src/components/task-filters.component';
|
||||||
export {TaskHeaderComponent as ActivitiTaskHeader} from './src/components/task-header.component';
|
export {TaskHeaderComponent as ActivitiTaskHeader} from './src/components/task-header.component';
|
||||||
export {TaskListComponent as ActivitiTaskList } from './src/components/tasklist.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 {TaskListService as ActivitiTaskListService } from './src/services/tasklist.service';
|
||||||
|
|
||||||
export * from './src/models/comment.model';
|
export * from './src/models/comment.model';
|
||||||
export * from './src/models/filter.model';
|
export * from './src/models/filter.model';
|
||||||
export * from './src/models/icon.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.model';
|
||||||
export * from './src/models/task-details.event';
|
export * from './src/models/task-details.event';
|
||||||
export * from './src/models/user-event.model';
|
export * from './src/models/user-event.model';
|
||||||
@@ -144,12 +139,10 @@ export const ACTIVITI_TASKLIST_DIRECTIVES: any[] = [
|
|||||||
|
|
||||||
export const ACTIVITI_TASKLIST_PROVIDERS: any[] = [
|
export const ACTIVITI_TASKLIST_PROVIDERS: any[] = [
|
||||||
TaskListService,
|
TaskListService,
|
||||||
PeopleService,
|
|
||||||
ProcessUploadService,
|
ProcessUploadService,
|
||||||
|
|
||||||
// Old Deprecated export
|
// Old Deprecated export
|
||||||
ActivitiTaskListService,
|
ActivitiTaskListService
|
||||||
ActivitiPeopleService
|
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@@ -8,12 +8,11 @@
|
|||||||
<div id="comment-user-icon"
|
<div id="comment-user-icon"
|
||||||
class="adf-comment-img-container">
|
class="adf-comment-img-container">
|
||||||
<div
|
<div
|
||||||
*ngIf="!entry.row.obj.createdBy.userImage" class="adf-comment-user-icon">
|
*ngIf="!entry.row.obj.createdBy.pictureId" class="adf-comment-user-icon">
|
||||||
{{getUserShortName(entry.row.obj.createdBy)}}</div>
|
{{getUserShortName(entry.row.obj.createdBy)}}</div>
|
||||||
<div>
|
<div>
|
||||||
<img *ngIf="entry.row.obj.createdBy.userImage" class="adf-people-img"
|
<img *ngIf="entry.row.obj.createdBy.pictureId" class="adf-people-img"
|
||||||
[src]="entry.row.obj.createdBy.userImage"
|
[src]="peopleProcessService.getUserImage(entry.row.obj.createdBy)"/>
|
||||||
(error)="onErrorImageLoad(entry.row.obj.createdBy)"/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
@@ -18,16 +18,16 @@
|
|||||||
import { DatePipe } from '@angular/common';
|
import { DatePipe } from '@angular/common';
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { AppConfigService, CoreModule, TranslationService } from 'ng2-alfresco-core';
|
import { AppConfigService, CoreModule, TranslationService } from 'ng2-alfresco-core';
|
||||||
|
import { LightUserRepresentation } from 'ng2-alfresco-core';
|
||||||
import { DataRowEvent, DataTableModule, ObjectDataRow } from 'ng2-alfresco-datatable';
|
import { DataRowEvent, DataTableModule, ObjectDataRow } from 'ng2-alfresco-datatable';
|
||||||
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
|
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
|
||||||
import { TranslationMock } from '../assets/translation.service.mock';
|
import { TranslationMock } from '../assets/translation.service.mock';
|
||||||
import { Comment } from '../models/comment.model';
|
import { Comment } from '../models/comment.model';
|
||||||
import { User } from '../models/user.model';
|
|
||||||
import { CommentListComponent } from './comment-list.component';
|
import { CommentListComponent } from './comment-list.component';
|
||||||
|
|
||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
|
|
||||||
const testUser: User = new User({
|
const testUser: LightUserRepresentation = new LightUserRepresentation({
|
||||||
id: '1',
|
id: '1',
|
||||||
firstName: 'Test',
|
firstName: 'Test',
|
||||||
lastName: 'User',
|
lastName: 'User',
|
||||||
@@ -54,8 +54,8 @@ describe('CommentListComponent', () => {
|
|||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
DatePipe,
|
DatePipe,
|
||||||
{ provide: AppConfigService, useClass: AppConfigServiceMock },
|
{provide: AppConfigService, useClass: AppConfigServiceMock},
|
||||||
{ provide: TranslationService, useClass: TranslationMock }
|
{provide: TranslationService, useClass: TranslationMock}
|
||||||
]
|
]
|
||||||
}).compileComponents().then(() => {
|
}).compileComponents().then(() => {
|
||||||
|
|
||||||
|
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
import { DatePipe } from '@angular/common';
|
import { DatePipe } from '@angular/common';
|
||||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||||
|
import { LightUserRepresentation, PeopleProcessService } from 'ng2-alfresco-core';
|
||||||
import { Comment } from '../models/comment.model';
|
import { Comment } from '../models/comment.model';
|
||||||
import { User } from '../models/user.model';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-comment-list',
|
selector: 'adf-comment-list',
|
||||||
@@ -36,7 +36,7 @@ export class CommentListComponent {
|
|||||||
|
|
||||||
selectedComment: Comment;
|
selectedComment: Comment;
|
||||||
|
|
||||||
constructor(private datePipe: DatePipe) {
|
constructor(private datePipe: DatePipe, public peopleProcessService: PeopleProcessService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
selectComment(event: any): void {
|
selectComment(event: any): void {
|
||||||
@@ -44,7 +44,7 @@ export class CommentListComponent {
|
|||||||
this.clickRow.emit(this.selectedComment);
|
this.clickRow.emit(this.selectedComment);
|
||||||
}
|
}
|
||||||
|
|
||||||
getUserShortName(user: User): string {
|
getUserShortName(user: LightUserRepresentation): string {
|
||||||
let shortName = '';
|
let shortName = '';
|
||||||
if (user) {
|
if (user) {
|
||||||
if (user.firstName) {
|
if (user.firstName) {
|
||||||
@@ -78,10 +78,4 @@ export class CommentListComponent {
|
|||||||
return this.comments && this.comments.length && true;
|
return this.comments && this.comments.length && true;
|
||||||
}
|
}
|
||||||
|
|
||||||
onErrorImageLoad(user: User) {
|
|
||||||
if (user.userImage) {
|
|
||||||
user.userImage = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -26,8 +26,8 @@ import { TranslationMock } from '../assets/translation.service.mock';
|
|||||||
|
|
||||||
import { DatePipe } from '@angular/common';
|
import { DatePipe } from '@angular/common';
|
||||||
import { MdInputModule } from '@angular/material';
|
import { MdInputModule } from '@angular/material';
|
||||||
|
import { PeopleProcessService } from 'ng2-alfresco-core';
|
||||||
import { DataTableModule } from 'ng2-alfresco-datatable';
|
import { DataTableModule } from 'ng2-alfresco-datatable';
|
||||||
import { PeopleService } from '../services/people.service';
|
|
||||||
import { TaskListService } from './../services/tasklist.service';
|
import { TaskListService } from './../services/tasklist.service';
|
||||||
import { CommentListComponent } from './comment-list.component';
|
import { CommentListComponent } from './comment-list.component';
|
||||||
import { CommentsComponent } from './comments.component';
|
import { CommentsComponent } from './comments.component';
|
||||||
@@ -56,7 +56,7 @@ describe('CommentsComponent', () => {
|
|||||||
providers: [
|
providers: [
|
||||||
TaskListService,
|
TaskListService,
|
||||||
DatePipe,
|
DatePipe,
|
||||||
PeopleService,
|
PeopleProcessService,
|
||||||
{ provide: TranslationService, useClass: TranslationMock },
|
{ provide: TranslationService, useClass: TranslationMock },
|
||||||
{ provide: AppConfigService, useClass: AppConfigServiceMock }
|
{ provide: AppConfigService, useClass: AppConfigServiceMock }
|
||||||
]
|
]
|
||||||
|
@@ -19,7 +19,6 @@ import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from
|
|||||||
import { Observable, Observer } from 'rxjs/Rx';
|
import { Observable, Observer } from 'rxjs/Rx';
|
||||||
|
|
||||||
import { Comment } from '../models/comment.model';
|
import { Comment } from '../models/comment.model';
|
||||||
import { PeopleService } from '../services/people.service';
|
|
||||||
import { TaskListService } from '../services/tasklist.service';
|
import { TaskListService } from '../services/tasklist.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -52,7 +51,7 @@ export class CommentsComponent implements OnChanges {
|
|||||||
* @param translate Translation service
|
* @param translate Translation service
|
||||||
* @param activitiTaskList Task service
|
* @param activitiTaskList Task service
|
||||||
*/
|
*/
|
||||||
constructor(private activitiTaskList: TaskListService, private peopleService: PeopleService) {
|
constructor(private activitiTaskList: TaskListService) {
|
||||||
this.comment$ = new Observable<Comment>(observer => this.commentObserver = observer).share();
|
this.comment$ = new Observable<Comment>(observer => this.commentObserver = observer).share();
|
||||||
this.comment$.subscribe((comment: Comment) => {
|
this.comment$.subscribe((comment: Comment) => {
|
||||||
this.comments.push(comment);
|
this.comments.push(comment);
|
||||||
@@ -81,7 +80,6 @@ export class CommentsComponent implements OnChanges {
|
|||||||
return date1 > date2 ? -1 : date1 < date2 ? 1 : 0;
|
return date1 > date2 ? -1 : date1 < date2 ? 1 : 0;
|
||||||
});
|
});
|
||||||
res.forEach((comment) => {
|
res.forEach((comment) => {
|
||||||
comment.createdBy.userImage = this.peopleService.getUserImage(comment.createdBy);
|
|
||||||
this.commentObserver.next(comment);
|
this.commentObserver.next(comment);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -102,7 +100,6 @@ export class CommentsComponent implements OnChanges {
|
|||||||
this.activitiTaskList.addComment(this.taskId, this.message)
|
this.activitiTaskList.addComment(this.taskId, this.message)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
(res: Comment) => {
|
(res: Comment) => {
|
||||||
res.createdBy.userImage = this.peopleService.getUserImage(res.createdBy);
|
|
||||||
this.comments.unshift(res);
|
this.comments.unshift(res);
|
||||||
this.message = '';
|
this.message = '';
|
||||||
this.beingAdded = false;
|
this.beingAdded = false;
|
||||||
|
@@ -17,16 +17,16 @@
|
|||||||
|
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { AppConfigService, CoreModule, TranslationService } from 'ng2-alfresco-core';
|
import { AppConfigService, CoreModule, TranslationService } from 'ng2-alfresco-core';
|
||||||
|
import { LightUserRepresentation } from 'ng2-alfresco-core';
|
||||||
import { DataRowActionEvent, DataRowEvent, DataTableModule, ObjectDataRow } from 'ng2-alfresco-datatable';
|
import { DataRowActionEvent, DataRowEvent, DataTableModule, ObjectDataRow } from 'ng2-alfresco-datatable';
|
||||||
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
|
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
|
||||||
import { TranslationMock } from '../assets/translation.service.mock';
|
import { TranslationMock } from '../assets/translation.service.mock';
|
||||||
import { UserEventModel } from '../models/user-event.model';
|
import { UserEventModel } from '../models/user-event.model';
|
||||||
import { User } from '../models/user.model';
|
|
||||||
import { PeopleListComponent } from './people-list.component';
|
import { PeopleListComponent } from './people-list.component';
|
||||||
|
|
||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
|
|
||||||
const fakeUser: User = new User({
|
const fakeUser: LightUserRepresentation = new LightUserRepresentation({
|
||||||
id: '1',
|
id: '1',
|
||||||
firstName: 'fake-name',
|
firstName: 'fake-name',
|
||||||
lastName: 'fake-last',
|
lastName: 'fake-last',
|
||||||
|
@@ -17,9 +17,9 @@
|
|||||||
|
|
||||||
import { AfterContentInit, AfterViewInit, Component, ContentChild, EventEmitter, Input, Output, ViewChild } from '@angular/core';
|
import { AfterContentInit, AfterViewInit, Component, ContentChild, EventEmitter, Input, Output, ViewChild } from '@angular/core';
|
||||||
import { DataColumnListComponent } from 'ng2-alfresco-core';
|
import { DataColumnListComponent } from 'ng2-alfresco-core';
|
||||||
|
import { LightUserRepresentation } from 'ng2-alfresco-core';
|
||||||
import { DataTableComponent } from 'ng2-alfresco-datatable';
|
import { DataTableComponent } from 'ng2-alfresco-datatable';
|
||||||
import { UserEventModel } from '../models/user-event.model';
|
import { UserEventModel } from '../models/user-event.model';
|
||||||
import { User } from '../models/user.model';
|
|
||||||
|
|
||||||
declare let componentHandler: any;
|
declare let componentHandler: any;
|
||||||
|
|
||||||
@@ -37,18 +37,18 @@ export class PeopleListComponent implements AfterViewInit, AfterContentInit {
|
|||||||
peopleDataTable: DataTableComponent;
|
peopleDataTable: DataTableComponent;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
users: User[];
|
users: LightUserRepresentation[];
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
actions: boolean = false;
|
actions: boolean = false;
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
clickRow: EventEmitter<User> = new EventEmitter<User>();
|
clickRow: EventEmitter<LightUserRepresentation> = new EventEmitter<LightUserRepresentation>();
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
clickAction: EventEmitter<UserEventModel> = new EventEmitter<UserEventModel>();
|
clickAction: EventEmitter<UserEventModel> = new EventEmitter<UserEventModel>();
|
||||||
|
|
||||||
user: User;
|
user: LightUserRepresentation;
|
||||||
|
|
||||||
ngAfterContentInit() {
|
ngAfterContentInit() {
|
||||||
this.peopleDataTable.columnList = this.columnList;
|
this.peopleDataTable.columnList = this.columnList;
|
||||||
|
@@ -11,12 +11,11 @@
|
|||||||
<data-columns>
|
<data-columns>
|
||||||
<data-column key="firstName">
|
<data-column key="firstName">
|
||||||
<ng-template let-entry="$implicit">
|
<ng-template let-entry="$implicit">
|
||||||
<div *ngIf="!entry.row.obj.userImage" class="people-pic">
|
<div *ngIf="!entry.row.obj.pictureId" class="people-pic">
|
||||||
{{getInitialUserName(entry.row.obj.firstName, entry.row.obj.lastName)}}</div>
|
{{getInitialUserName(entry.row.obj.firstName, entry.row.obj.lastName)}}</div>
|
||||||
<div>
|
<div>
|
||||||
<img *ngIf="entry.row.obj.userImage" class="people-img"
|
<img *ngIf="entry.row.obj.pictureId" class="people-img"
|
||||||
[src]="entry.row.obj.userImage"
|
[src]="peopleProcessService.getUserImage(entry.row.obj)"/>
|
||||||
(error)="onErrorImageLoad(entry.row.obj)"/>
|
|
||||||
</div>
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</data-column>
|
</data-column>
|
||||||
|
@@ -18,24 +18,24 @@
|
|||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { MdButtonModule, MdInputModule } from '@angular/material';
|
import { MdButtonModule, MdInputModule } from '@angular/material';
|
||||||
import { AppConfigService, CoreModule, TranslationService } from 'ng2-alfresco-core';
|
import { AppConfigService, CoreModule, TranslationService } from 'ng2-alfresco-core';
|
||||||
|
import { LightUserRepresentation } from 'ng2-alfresco-core';
|
||||||
import { DataTableModule } from 'ng2-alfresco-datatable';
|
import { DataTableModule } from 'ng2-alfresco-datatable';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
|
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
|
||||||
import { TranslationMock } from '../assets/translation.service.mock';
|
import { TranslationMock } from '../assets/translation.service.mock';
|
||||||
import { User } from '../models/user.model';
|
|
||||||
import { PeopleListComponent } from './people-list.component';
|
import { PeopleListComponent } from './people-list.component';
|
||||||
import { PeopleSearchComponent } from './people-search.component';
|
import { PeopleSearchComponent } from './people-search.component';
|
||||||
|
|
||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
|
|
||||||
const fakeUser: User = new User({
|
const fakeUser: LightUserRepresentation = new LightUserRepresentation({
|
||||||
id: '1',
|
id: '1',
|
||||||
firstName: 'fake-name',
|
firstName: 'fake-name',
|
||||||
lastName: 'fake-last',
|
lastName: 'fake-last',
|
||||||
email: 'fake@mail.com'
|
email: 'fake@mail.com'
|
||||||
});
|
});
|
||||||
|
|
||||||
const fakeSecondUser: User = new User({
|
const fakeSecondUser: LightUserRepresentation = new LightUserRepresentation({
|
||||||
id: '2',
|
id: '2',
|
||||||
firstName: 'fake-involve-name',
|
firstName: 'fake-involve-name',
|
||||||
lastName: 'fake-involve-last',
|
lastName: 'fake-involve-last',
|
||||||
|
@@ -17,8 +17,9 @@
|
|||||||
|
|
||||||
import { Component, Directive, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
import { Component, Directive, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
||||||
import { FormControl } from '@angular/forms';
|
import { FormControl } from '@angular/forms';
|
||||||
|
import { LightUserRepresentation } from 'ng2-alfresco-core';
|
||||||
|
import { PeopleProcessService } from 'ng2-alfresco-core';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { User } from '../models/user.model';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-people-search, activiti-people-search',
|
selector: 'adf-people-search, activiti-people-search',
|
||||||
@@ -33,24 +34,24 @@ import { User } from '../models/user.model';
|
|||||||
export class PeopleSearchComponent implements OnInit {
|
export class PeopleSearchComponent implements OnInit {
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
results: Observable<User[]>;
|
results: Observable<LightUserRepresentation[]>;
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
searchPeople: EventEmitter<any> = new EventEmitter();
|
searchPeople: EventEmitter<any> = new EventEmitter();
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
success: EventEmitter<User> = new EventEmitter<User>();
|
success: EventEmitter<LightUserRepresentation> = new EventEmitter<LightUserRepresentation>();
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
closeSearch = new EventEmitter();
|
closeSearch = new EventEmitter();
|
||||||
|
|
||||||
searchUser: FormControl = new FormControl();
|
searchUser: FormControl = new FormControl();
|
||||||
|
|
||||||
users: User[] = [];
|
users: LightUserRepresentation[] = [];
|
||||||
|
|
||||||
selectedUser: User;
|
selectedUser: LightUserRepresentation;
|
||||||
|
|
||||||
constructor() {
|
constructor(peopleProcessService: PeopleProcessService) {
|
||||||
this.searchUser
|
this.searchUser
|
||||||
.valueChanges
|
.valueChanges
|
||||||
.debounceTime(200)
|
.debounceTime(200)
|
||||||
@@ -69,7 +70,7 @@ export class PeopleSearchComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onRowClick(user: User) {
|
onRowClick(user: LightUserRepresentation) {
|
||||||
this.selectedUser = user;
|
this.selectedUser = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,12 +109,6 @@ export class PeopleSearchComponent implements OnInit {
|
|||||||
hasUsers() {
|
hasUsers() {
|
||||||
return (this.users && this.users.length > 0);
|
return (this.users && this.users.length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
onErrorImageLoad(user: User) {
|
|
||||||
if (user.userImage) {
|
|
||||||
user.userImage = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Directive({ selector: 'people-search-title' }) export class PeopleSearchTitleDirective { }
|
@Directive({ selector: 'people-search-title' }) export class PeopleSearchTitleDirective { }
|
||||||
|
@@ -29,12 +29,11 @@
|
|||||||
<data-columns>
|
<data-columns>
|
||||||
<data-column key="firstName">
|
<data-column key="firstName">
|
||||||
<ng-template let-entry="$implicit">
|
<ng-template let-entry="$implicit">
|
||||||
<div *ngIf="!entry.row.obj.userImage" class="people-pic">
|
<div *ngIf="!entry.row.obj.pictureId" class="people-pic">
|
||||||
{{getInitialUserName(entry.row.obj.firstName, entry.row.obj.lastName)}}</div>
|
{{getInitialUserName(entry.row.obj.firstName, entry.row.obj.lastName)}}</div>
|
||||||
<div>
|
<div>
|
||||||
<img *ngIf="entry.row.obj.userImage" class="people-img"
|
<img *ngIf="entry.row.obj.pictureId" class="people-img"
|
||||||
[src]="entry.row.obj.userImage"
|
[src]="peopleProcessService.getUserImage(entry.row.obj)"/>
|
||||||
(error)="onErrorImageLoad(entry.row.obj)"/>
|
|
||||||
</div>
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</data-column>
|
</data-column>
|
||||||
|
@@ -19,25 +19,25 @@ import { NO_ERRORS_SCHEMA } from '@angular/core';
|
|||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { MdButtonModule, MdInputModule } from '@angular/material';
|
import { MdButtonModule, MdInputModule } from '@angular/material';
|
||||||
import { AppConfigService, CoreModule, LogService, TranslationService } from 'ng2-alfresco-core';
|
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 { DataTableModule } from 'ng2-alfresco-datatable';
|
||||||
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
|
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
|
||||||
import { TranslationMock } from '../assets/translation.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 { PeopleListComponent } from './people-list.component';
|
||||||
import { PeopleSearchComponent } from './people-search.component';
|
import { PeopleSearchComponent } from './people-search.component';
|
||||||
import { PeopleComponent } from './people.component';
|
import { PeopleComponent } from './people.component';
|
||||||
|
|
||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
|
|
||||||
const fakeUser: User = new User({
|
const fakeUser: LightUserRepresentation = new LightUserRepresentation({
|
||||||
id: 'fake-id',
|
id: 'fake-id',
|
||||||
firstName: 'fake-name',
|
firstName: 'fake-name',
|
||||||
lastName: 'fake-last',
|
lastName: 'fake-last',
|
||||||
email: 'fake@mail.com'
|
email: 'fake@mail.com'
|
||||||
});
|
});
|
||||||
|
|
||||||
const fakeSecondUser: User = new User({
|
const fakeSecondUser: LightUserRepresentation = new LightUserRepresentation({
|
||||||
id: 'fake-involve-id',
|
id: 'fake-involve-id',
|
||||||
firstName: 'fake-involve-name',
|
firstName: 'fake-involve-name',
|
||||||
lastName: 'fake-involve-last',
|
lastName: 'fake-involve-last',
|
||||||
@@ -67,7 +67,7 @@ describe('PeopleComponent', () => {
|
|||||||
PeopleComponent
|
PeopleComponent
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
PeopleService,
|
PeopleProcessService,
|
||||||
{ provide: TranslationService, useClass: TranslationMock },
|
{ provide: TranslationService, useClass: TranslationMock },
|
||||||
{ provide: AppConfigService, useClass: AppConfigServiceMock }
|
{ provide: AppConfigService, useClass: AppConfigServiceMock }
|
||||||
],
|
],
|
||||||
|
@@ -17,13 +17,11 @@
|
|||||||
|
|
||||||
import { AfterViewInit, Component, Input, OnInit, ViewChild } from '@angular/core';
|
import { AfterViewInit, Component, Input, OnInit, ViewChild } from '@angular/core';
|
||||||
import { LogService } from 'ng2-alfresco-core';
|
import { LogService } from 'ng2-alfresco-core';
|
||||||
|
import { LightUserRepresentation, PeopleProcessService } from 'ng2-alfresco-core';
|
||||||
import { Observable, Observer } from 'rxjs/Rx';
|
import { Observable, Observer } from 'rxjs/Rx';
|
||||||
import { UserEventModel } from '../models/user-event.model';
|
import { UserEventModel } from '../models/user-event.model';
|
||||||
import { User } from '../models/user.model';
|
|
||||||
import { PeopleSearchComponent } from './people-search.component';
|
import { PeopleSearchComponent } from './people-search.component';
|
||||||
|
|
||||||
import { PeopleService } from '../services/people.service';
|
|
||||||
|
|
||||||
declare let componentHandler: any;
|
declare let componentHandler: any;
|
||||||
declare var require: any;
|
declare var require: any;
|
||||||
|
|
||||||
@@ -38,7 +36,7 @@ export class PeopleComponent implements OnInit, AfterViewInit {
|
|||||||
iconImageUrl: string = require('../assets/images/user.jpg');
|
iconImageUrl: string = require('../assets/images/user.jpg');
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
people: User[] = [];
|
people: LightUserRepresentation[] = [];
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
taskId: string = '';
|
taskId: string = '';
|
||||||
@@ -51,25 +49,14 @@ export class PeopleComponent implements OnInit, AfterViewInit {
|
|||||||
|
|
||||||
showAssignment: boolean = false;
|
showAssignment: boolean = false;
|
||||||
|
|
||||||
private peopleSearchObserver: Observer<User[]>;
|
private peopleSearchObserver: Observer<LightUserRepresentation[]>;
|
||||||
peopleSearch$: Observable<User[]>;
|
peopleSearch$: Observable<LightUserRepresentation[]>;
|
||||||
|
|
||||||
/**
|
constructor(private logService: LogService, public peopleProcessService: PeopleProcessService) {
|
||||||
* Constructor
|
this.peopleSearch$ = new Observable<LightUserRepresentation[]>(observer => this.peopleSearchObserver = observer).share();
|
||||||
* @param translate
|
|
||||||
* @param people service
|
|
||||||
*/
|
|
||||||
constructor(private peopleService: PeopleService,
|
|
||||||
private logService: LogService) {
|
|
||||||
this.peopleSearch$ = new Observable<User[]>(observer => this.peopleSearchObserver = observer).share();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.people && this.people.length > 0) {
|
|
||||||
this.people.forEach((person) => {
|
|
||||||
person.userImage = this.peopleService.getUserImage(person);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
@@ -99,21 +86,21 @@ export class PeopleComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
searchUser(searchedWord: string) {
|
searchUser(searchedWord: string) {
|
||||||
this.peopleService.getWorkflowUsersWithImages(this.taskId, searchedWord)
|
this.peopleProcessService.getWorkflowUsers(this.taskId, searchedWord)
|
||||||
.subscribe((users) => {
|
.subscribe((users) => {
|
||||||
this.peopleSearchObserver.next(users);
|
this.peopleSearchObserver.next(users);
|
||||||
}, error => this.logService.error(error));
|
}, error => this.logService.error(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
involveUser(user: User) {
|
involveUser(user: LightUserRepresentation) {
|
||||||
this.peopleService.involveUserWithTask(this.taskId, user.id.toString())
|
this.peopleProcessService.involveUserWithTask(this.taskId, user.id.toString())
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.people = [...this.people, user];
|
this.people = [...this.people, user];
|
||||||
}, error => this.logService.error('Impossible to involve user with task'));
|
}, error => this.logService.error('Impossible to involve user with task'));
|
||||||
}
|
}
|
||||||
|
|
||||||
removeInvolvedUser(user: User) {
|
removeInvolvedUser(user: LightUserRepresentation) {
|
||||||
this.peopleService.removeInvolvedUser(this.taskId, user.id.toString())
|
this.peopleProcessService.removeInvolvedUser(this.taskId, user.id.toString())
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.people = this.people.filter((involvedUser) => {
|
this.people = this.people.filter((involvedUser) => {
|
||||||
return involvedUser.id !== user.id;
|
return involvedUser.id !== user.id;
|
||||||
@@ -154,10 +141,4 @@ export class PeopleComponent implements OnInit, AfterViewInit {
|
|||||||
onCloseSearch() {
|
onCloseSearch() {
|
||||||
this.showAssignment = false;
|
this.showAssignment = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
onErrorImageLoad(user: User) {
|
|
||||||
if (user.userImage) {
|
|
||||||
user.userImage = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -17,12 +17,11 @@
|
|||||||
|
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { MdButtonModule, MdDatepickerModule, MdGridListModule, MdIconModule, MdInputModule, MdNativeDateModule, MdSelectModule } from '@angular/material';
|
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 { Observable } from 'rxjs/Rx';
|
||||||
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
|
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
|
||||||
import { TranslationMock } from '../assets/translation.service.mock';
|
import { TranslationMock } from '../assets/translation.service.mock';
|
||||||
import { StartTaskModel } from '../models/start-task.model';
|
import { StartTaskModel } from '../models/start-task.model';
|
||||||
import { PeopleService } from '../services/people.service';
|
|
||||||
import { TaskListService } from '../services/tasklist.service';
|
import { TaskListService } from '../services/tasklist.service';
|
||||||
import { startTaskMock } from './../assets/start-task.mock';
|
import { startTaskMock } from './../assets/start-task.mock';
|
||||||
import { StartTaskComponent } from './start-task.component';
|
import { StartTaskComponent } from './start-task.component';
|
||||||
@@ -32,7 +31,7 @@ describe('StartTaskComponent', () => {
|
|||||||
let component: StartTaskComponent;
|
let component: StartTaskComponent;
|
||||||
let fixture: ComponentFixture<StartTaskComponent>;
|
let fixture: ComponentFixture<StartTaskComponent>;
|
||||||
let service: TaskListService;
|
let service: TaskListService;
|
||||||
let peopleService: PeopleService;
|
let peopleService: PeopleProcessService;
|
||||||
let element: HTMLElement;
|
let element: HTMLElement;
|
||||||
let getFormlistSpy: jasmine.Spy;
|
let getFormlistSpy: jasmine.Spy;
|
||||||
let getWorkflowUsersSpy: jasmine.Spy;
|
let getWorkflowUsersSpy: jasmine.Spy;
|
||||||
@@ -67,7 +66,7 @@ describe('StartTaskComponent', () => {
|
|||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
TaskListService,
|
TaskListService,
|
||||||
PeopleService,
|
PeopleProcessService,
|
||||||
{ provide: AppConfigService, useClass: AppConfigServiceMock },
|
{ provide: AppConfigService, useClass: AppConfigServiceMock },
|
||||||
{ provide: TranslationService, useClass: TranslationMock }
|
{ provide: TranslationService, useClass: TranslationMock }
|
||||||
]
|
]
|
||||||
@@ -78,7 +77,7 @@ describe('StartTaskComponent', () => {
|
|||||||
element = fixture.nativeElement;
|
element = fixture.nativeElement;
|
||||||
|
|
||||||
service = fixture.debugElement.injector.get(TaskListService);
|
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));
|
getFormlistSpy = spyOn(service, 'getFormList').and.returnValue(Observable.of(fakeForms));
|
||||||
getWorkflowUsersSpy = spyOn(peopleService, 'getWorkflowUsers').and.returnValue(Observable.of([
|
getWorkflowUsersSpy = spyOn(peopleService, 'getWorkflowUsers').and.returnValue(Observable.of([
|
||||||
{
|
{
|
||||||
|
@@ -18,14 +18,12 @@
|
|||||||
import { Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
import { Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
||||||
import { DateAdapter, MD_DATE_FORMATS } from '@angular/material';
|
import { DateAdapter, MD_DATE_FORMATS } from '@angular/material';
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
import { MOMENT_DATE_FORMATS, MomentDateAdapter } from 'ng2-alfresco-core';
|
import { LightUserRepresentation, LogService, MOMENT_DATE_FORMATS,
|
||||||
import { LogService } from 'ng2-alfresco-core';
|
MomentDateAdapter, PeopleProcessService } from 'ng2-alfresco-core';
|
||||||
import { Observable } from 'rxjs/Rx';
|
import { Observable } from 'rxjs/Rx';
|
||||||
import { Form } from '../models/form.model';
|
import { Form } from '../models/form.model';
|
||||||
import { StartTaskModel } from '../models/start-task.model';
|
import { StartTaskModel } from '../models/start-task.model';
|
||||||
import { TaskDetailsModel } from '../models/task-details.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';
|
import { TaskListService } from './../services/tasklist.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -53,7 +51,7 @@ export class StartTaskComponent implements OnInit {
|
|||||||
@Output()
|
@Output()
|
||||||
error: EventEmitter<any> = new EventEmitter<any>();
|
error: EventEmitter<any> = new EventEmitter<any>();
|
||||||
|
|
||||||
people: User[] = [];
|
people: LightUserRepresentation[] = [];
|
||||||
|
|
||||||
startTaskmodel: StartTaskModel = new StartTaskModel();
|
startTaskmodel: StartTaskModel = new StartTaskModel();
|
||||||
|
|
||||||
@@ -74,7 +72,7 @@ export class StartTaskComponent implements OnInit {
|
|||||||
* @param taskService
|
* @param taskService
|
||||||
*/
|
*/
|
||||||
constructor(private taskService: TaskListService,
|
constructor(private taskService: TaskListService,
|
||||||
private peopleService: PeopleService,
|
private peopleService: PeopleProcessService,
|
||||||
private logService: LogService) {
|
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));
|
return !user || (this.isEmpty(user.firstName) && this.isEmpty(user.lastName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,19 +24,19 @@ import { Observable } from 'rxjs/Rx';
|
|||||||
import { ActivitiFormModule, FormModel, FormOutcomeEvent, FormOutcomeModel, FormService } from 'ng2-activiti-form';
|
import { ActivitiFormModule, FormModel, FormOutcomeEvent, FormOutcomeModel, FormService } from 'ng2-activiti-form';
|
||||||
import { AppConfigService, CoreModule, LogService, TranslationService } from 'ng2-alfresco-core';
|
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 { AppConfigServiceMock } from '../assets/app-config.service.mock';
|
||||||
import { TranslationMock } from '../assets/translation.service.mock';
|
import { TranslationMock } from '../assets/translation.service.mock';
|
||||||
import { TaskDetailsModel } from '../models/task-details.model';
|
import { TaskDetailsModel } from '../models/task-details.model';
|
||||||
import { User } from '../models/user.model';
|
|
||||||
import { noDataMock, taskDetailsMock, taskFormMock, tasksMock } from './../assets/task-details.mock';
|
import { noDataMock, taskDetailsMock, taskFormMock, tasksMock } from './../assets/task-details.mock';
|
||||||
import { PeopleService } from './../services/people.service';
|
|
||||||
import { TaskListService } from './../services/tasklist.service';
|
import { TaskListService } from './../services/tasklist.service';
|
||||||
import { PeopleSearchComponent } from './people-search.component';
|
import { PeopleSearchComponent } from './people-search.component';
|
||||||
import { TaskDetailsComponent } from './task-details.component';
|
import { TaskDetailsComponent } from './task-details.component';
|
||||||
|
|
||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
|
|
||||||
const fakeUser: User = new User({
|
const fakeUser: LightUserRepresentation = new LightUserRepresentation({
|
||||||
id: 'fake-id',
|
id: 'fake-id',
|
||||||
firstName: 'fake-name',
|
firstName: 'fake-name',
|
||||||
lastName: 'fake-last',
|
lastName: 'fake-last',
|
||||||
@@ -72,7 +72,7 @@ describe('TaskDetailsComponent', () => {
|
|||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
TaskListService,
|
TaskListService,
|
||||||
PeopleService,
|
PeopleProcessService,
|
||||||
{ provide: TranslationService, useClass: TranslationMock },
|
{ provide: TranslationService, useClass: TranslationMock },
|
||||||
{ provide: AppConfigService, useClass: AppConfigServiceMock }
|
{ provide: AppConfigService, useClass: AppConfigServiceMock }
|
||||||
],
|
],
|
||||||
|
@@ -28,11 +28,11 @@ import { Component,
|
|||||||
import { MdDialog, MdDialogRef } from '@angular/material';
|
import { MdDialog, MdDialogRef } from '@angular/material';
|
||||||
import { ContentLinkModel, FormFieldValidator, FormModel, FormOutcomeEvent } from 'ng2-activiti-form';
|
import { ContentLinkModel, FormFieldValidator, FormModel, FormOutcomeEvent } from 'ng2-activiti-form';
|
||||||
import { AlfrescoAuthenticationService, CardViewUpdateService, ClickNotification, LogService, UpdateNotification } from 'ng2-alfresco-core';
|
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 { Observable, Observer } from 'rxjs/Rx';
|
||||||
import { TaskQueryRequestRepresentationModel } from '../models/filter.model';
|
import { TaskQueryRequestRepresentationModel } from '../models/filter.model';
|
||||||
import { TaskDetailsModel } from '../models/task-details.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';
|
import { TaskListService } from './../services/tasklist.service';
|
||||||
|
|
||||||
declare var require: any;
|
declare var require: any;
|
||||||
@@ -131,24 +131,24 @@ export class TaskDetailsComponent implements OnInit, OnChanges {
|
|||||||
taskDetails: TaskDetailsModel;
|
taskDetails: TaskDetailsModel;
|
||||||
taskFormName: string = null;
|
taskFormName: string = null;
|
||||||
|
|
||||||
taskPeople: User[] = [];
|
taskPeople: LightUserRepresentation[] = [];
|
||||||
|
|
||||||
noTaskDetailsTemplateComponent: TemplateRef<any>;
|
noTaskDetailsTemplateComponent: TemplateRef<any>;
|
||||||
|
|
||||||
showAssignee: boolean = false;
|
showAssignee: boolean = false;
|
||||||
|
|
||||||
private peopleSearchObserver: Observer<User[]>;
|
private peopleSearchObserver: Observer<LightUserRepresentation[]>;
|
||||||
public errorDialogRef: MdDialogRef<TemplateRef<any>>;
|
public errorDialogRef: MdDialogRef<TemplateRef<any>>;
|
||||||
|
|
||||||
peopleSearch$: Observable<User[]>;
|
peopleSearch$: Observable<LightUserRepresentation[]>;
|
||||||
|
|
||||||
constructor(private activitiTaskList: TaskListService,
|
constructor(private activitiTaskList: TaskListService,
|
||||||
private authService: AlfrescoAuthenticationService,
|
private authService: AlfrescoAuthenticationService,
|
||||||
private peopleService: PeopleService,
|
private peopleProcessService: PeopleProcessService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private cardViewUpdateService: CardViewUpdateService,
|
private cardViewUpdateService: CardViewUpdateService,
|
||||||
private dialog: MdDialog) {
|
private dialog: MdDialog) {
|
||||||
this.peopleSearch$ = new Observable<User[]>(observer => this.peopleSearchObserver = observer).share();
|
this.peopleSearch$ = new Observable<LightUserRepresentation[]>(observer => this.peopleSearchObserver = observer).share();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -234,7 +234,7 @@ export class TaskDetailsComponent implements OnInit, OnChanges {
|
|||||||
this.readOnlyForm = this.readOnlyForm ? this.readOnlyForm : !!(endDate && !isNaN(endDate.getTime()));
|
this.readOnlyForm = this.readOnlyForm ? this.readOnlyForm : !!(endDate && !isNaN(endDate.getTime()));
|
||||||
if (this.taskDetails && this.taskDetails.involvedPeople) {
|
if (this.taskDetails && this.taskDetails.involvedPeople) {
|
||||||
this.taskDetails.involvedPeople.forEach((user) => {
|
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) {
|
searchUser(searchedWord: string) {
|
||||||
this.peopleService.getWorkflowUsers(null, searchedWord)
|
this.peopleProcessService.getWorkflowUsers(null, searchedWord)
|
||||||
.subscribe((users) => {
|
.subscribe((users) => {
|
||||||
users = users.filter((user) => user.id !== this.taskDetails.assignee.id);
|
users = users.filter((user) => user.id !== this.taskDetails.assignee.id);
|
||||||
this.peopleSearchObserver.next(users);
|
this.peopleSearchObserver.next(users);
|
||||||
@@ -347,7 +347,7 @@ export class TaskDetailsComponent implements OnInit, OnChanges {
|
|||||||
this.showAssignee = false;
|
this.showAssignee = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
assignTaskToUser(selectedUser: User) {
|
assignTaskToUser(selectedUser: LightUserRepresentation) {
|
||||||
this.activitiTaskList.assignTask(this.taskDetails.id, selectedUser).subscribe(
|
this.activitiTaskList.assignTask(this.taskDetails.id, selectedUser).subscribe(
|
||||||
(res: any) => {
|
(res: any) => {
|
||||||
this.logService.info('Task Assigned to ' + selectedUser.email);
|
this.logService.info('Task Assigned to ' + selectedUser.email);
|
||||||
|
@@ -23,6 +23,7 @@ import { Observable } from 'rxjs/Rx';
|
|||||||
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
|
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
|
||||||
import { TranslationMock } from '../assets/translation.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 { TaskDetailsModel } from '../models/task-details.model';
|
||||||
import { taskDetailsMock } from './../assets/task-details.mock';
|
import { taskDetailsMock } from './../assets/task-details.mock';
|
||||||
import { TaskListService } from './../services/tasklist.service';
|
import { TaskListService } from './../services/tasklist.service';
|
||||||
@@ -138,7 +139,7 @@ describe('TaskHeaderComponent', () => {
|
|||||||
|
|
||||||
describe('Unclaim', () => {
|
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;
|
let taskListService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@@ -22,15 +22,15 @@
|
|||||||
*
|
*
|
||||||
* @returns {Comment} .
|
* @returns {Comment} .
|
||||||
*/
|
*/
|
||||||
import { User } from './user.model';
|
import { LightUserRepresentation } from 'ng2-alfresco-core';
|
||||||
|
|
||||||
export class Comment {
|
export class Comment {
|
||||||
id: number;
|
id: number;
|
||||||
message: string;
|
message: string;
|
||||||
created: 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.id = id;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.created = created;
|
this.created = created;
|
||||||
|
@@ -22,13 +22,13 @@
|
|||||||
*
|
*
|
||||||
* @returns {StartTaskModel} .
|
* @returns {StartTaskModel} .
|
||||||
*/
|
*/
|
||||||
import { User } from './user.model';
|
import { LightUserRepresentation } from 'ng2-alfresco-core';
|
||||||
|
|
||||||
export class StartTaskModel {
|
export class StartTaskModel {
|
||||||
|
|
||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
assignee: User;
|
assignee: LightUserRepresentation;
|
||||||
dueDate: any;
|
dueDate: any;
|
||||||
formKey: any;
|
formKey: any;
|
||||||
category: string;
|
category: string;
|
||||||
@@ -36,7 +36,7 @@ export class StartTaskModel {
|
|||||||
constructor(obj?: any) {
|
constructor(obj?: any) {
|
||||||
this.name = obj && obj.name || null;
|
this.name = obj && obj.name || null;
|
||||||
this.description = obj && obj.description || 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.dueDate = obj && obj.dueDate || null;
|
||||||
this.formKey = obj && obj.formKey || null;
|
this.formKey = obj && obj.formKey || null;
|
||||||
this.category = obj && obj.category || null;
|
this.category = obj && obj.category || null;
|
||||||
|
@@ -22,12 +22,12 @@
|
|||||||
*
|
*
|
||||||
* @returns {TaskDetailsModel} .
|
* @returns {TaskDetailsModel} .
|
||||||
*/
|
*/
|
||||||
import { User } from './user.model';
|
import { LightUserRepresentation } from 'ng2-alfresco-core';
|
||||||
|
|
||||||
export class TaskDetailsModel {
|
export class TaskDetailsModel {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
assignee: User;
|
assignee: LightUserRepresentation;
|
||||||
priority: number;
|
priority: number;
|
||||||
adhocTaskCanBeReassigned: number;
|
adhocTaskCanBeReassigned: number;
|
||||||
category: string;
|
category: string;
|
||||||
@@ -42,7 +42,7 @@ export class TaskDetailsModel {
|
|||||||
managerOfCandidateGroup: boolean;
|
managerOfCandidateGroup: boolean;
|
||||||
memberOfCandidateGroup: boolean;
|
memberOfCandidateGroup: boolean;
|
||||||
memberOfCandidateUsers: boolean;
|
memberOfCandidateUsers: boolean;
|
||||||
involvedPeople: User [];
|
involvedPeople: LightUserRepresentation [];
|
||||||
parentTaskId: string;
|
parentTaskId: string;
|
||||||
parentTaskName: string;
|
parentTaskName: string;
|
||||||
processDefinitionCategory: string;
|
processDefinitionCategory: string;
|
||||||
@@ -62,7 +62,7 @@ export class TaskDetailsModel {
|
|||||||
this.id = obj.id || null;
|
this.id = obj.id || null;
|
||||||
this.name = obj.name || null;
|
this.name = obj.name || null;
|
||||||
this.priority = obj.priority;
|
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.adhocTaskCanBeReassigned = obj.adhocTaskCanBeReassigned;
|
||||||
this.category = obj.category || null;
|
this.category = obj.category || null;
|
||||||
this.created = obj.created || null;
|
this.created = obj.created || null;
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
import { async, TestBed } from '@angular/core/testing';
|
import { async, TestBed } from '@angular/core/testing';
|
||||||
import { AppConfigService, CoreModule, TranslationService } from 'ng2-alfresco-core';
|
import { AppConfigService, CoreModule, TranslationService } from 'ng2-alfresco-core';
|
||||||
|
import { LightUserRepresentation } from 'ng2-alfresco-core';
|
||||||
import { Observable } from 'rxjs/Rx';
|
import { Observable } from 'rxjs/Rx';
|
||||||
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
|
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
|
||||||
import {
|
import {
|
||||||
@@ -43,7 +44,6 @@ import { TranslationMock } from '../assets/translation.service.mock';
|
|||||||
import { Comment } from '../models/comment.model';
|
import { Comment } from '../models/comment.model';
|
||||||
import { FilterRepresentationModel, TaskQueryRequestRepresentationModel } from '../models/filter.model';
|
import { FilterRepresentationModel, TaskQueryRequestRepresentationModel } from '../models/filter.model';
|
||||||
import { TaskDetailsModel } from '../models/task-details.model';
|
import { TaskDetailsModel } from '../models/task-details.model';
|
||||||
import { User } from '../models/user.model';
|
|
||||||
import { TaskListService } from './tasklist.service';
|
import { TaskListService } from './tasklist.service';
|
||||||
|
|
||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
@@ -679,7 +679,7 @@ describe('Activiti TaskList Service', () => {
|
|||||||
expect(res.category).toEqual('3');
|
expect(res.category).toEqual('3');
|
||||||
expect(res.created).not.toEqual('');
|
expect(res.created).not.toEqual('');
|
||||||
expect(res.adhocTaskCanBeReassigned).toBe(true);
|
expect(res.adhocTaskCanBeReassigned).toBe(true);
|
||||||
expect(res.assignee).toEqual(new User(fakeUser2));
|
expect(res.assignee).toEqual(new LightUserRepresentation(fakeUser2));
|
||||||
expect(res.involvedPeople).toEqual([fakeUser1]);
|
expect(res.involvedPeople).toEqual([fakeUser1]);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
@@ -712,7 +712,7 @@ describe('Activiti TaskList Service', () => {
|
|||||||
expect(res.category).toEqual('3');
|
expect(res.category).toEqual('3');
|
||||||
expect(res.created).not.toEqual('');
|
expect(res.created).not.toEqual('');
|
||||||
expect(res.adhocTaskCanBeReassigned).toBe(true);
|
expect(res.adhocTaskCanBeReassigned).toBe(true);
|
||||||
expect(res.assignee).toEqual(new User(fakeUser2));
|
expect(res.assignee).toEqual(new LightUserRepresentation(fakeUser2));
|
||||||
expect(res.involvedPeople).toEqual([fakeUser1]);
|
expect(res.involvedPeople).toEqual([fakeUser1]);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { AlfrescoApiService, LogService } from 'ng2-alfresco-core';
|
import { AlfrescoApiService, LogService } from 'ng2-alfresco-core';
|
||||||
|
import { LightUserRepresentation } from 'ng2-alfresco-core';
|
||||||
import { Observable, Subject } from 'rxjs/Rx';
|
import { Observable, Subject } from 'rxjs/Rx';
|
||||||
import { Comment } from '../models/comment.model';
|
import { Comment } from '../models/comment.model';
|
||||||
import {
|
import {
|
||||||
@@ -26,7 +27,6 @@ import {
|
|||||||
import { Form } from '../models/form.model';
|
import { Form } from '../models/form.model';
|
||||||
import { TaskDetailsModel } from '../models/task-details.model';
|
import { TaskDetailsModel } from '../models/task-details.model';
|
||||||
import { TaskListModel } from '../models/task-list.model';
|
import { TaskListModel } from '../models/task-list.model';
|
||||||
import { User } from '../models/user.model';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TaskListService {
|
export class TaskListService {
|
||||||
@@ -231,7 +231,7 @@ export class TaskListService {
|
|||||||
.map((response: any) => {
|
.map((response: any) => {
|
||||||
let comments: Comment[] = [];
|
let comments: Comment[] = [];
|
||||||
response.data.forEach((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));
|
comments.push(new Comment(comment.id, comment.message, comment.created, user));
|
||||||
});
|
});
|
||||||
return comments;
|
return comments;
|
||||||
|
@@ -61,7 +61,8 @@ import { DiscoveryApiService } from './src/services/discovery-api.service';
|
|||||||
import { FavoritesApiService } from './src/services/favorites-api.service';
|
import { FavoritesApiService } from './src/services/favorites-api.service';
|
||||||
import { HighlightTransformService } from './src/services/highlight-transform.service';
|
import { HighlightTransformService } from './src/services/highlight-transform.service';
|
||||||
import { NodesApiService } from './src/services/nodes-api.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 { SearchApiService } from './src/services/search-api.service';
|
||||||
import { SearchService } from './src/services/search.service';
|
import { SearchService } from './src/services/search.service';
|
||||||
import { SharedLinksApiService } from './src/services/shared-links-api.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 { DeletedNodesApiService } from './src/services/deleted-nodes-api.service';
|
||||||
export { FavoritesApiService } from './src/services/favorites-api.service';
|
export { FavoritesApiService } from './src/services/favorites-api.service';
|
||||||
export { NodesApiService } from './src/services/nodes-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 { SearchApiService } from './src/services/search-api.service';
|
||||||
export { SharedLinksApiService } from './src/services/shared-links-api.service';
|
export { SharedLinksApiService } from './src/services/shared-links-api.service';
|
||||||
export { SitesApiService } from './src/services/sites-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/permissions.enum';
|
||||||
export * from './src/models/site.model';
|
export * from './src/models/site.model';
|
||||||
export * from './src/models/product-version.model';
|
export * from './src/models/product-version.model';
|
||||||
|
export * from './src/models/user-process.model';
|
||||||
|
|
||||||
// Old deprecated import
|
// Old deprecated import
|
||||||
import { AuthenticationService as AlfrescoAuthenticationService } from './src/services/authentication.service';
|
import { AuthenticationService as AlfrescoAuthenticationService } from './src/services/authentication.service';
|
||||||
@@ -190,13 +193,14 @@ export function providers() {
|
|||||||
DeletedNodesApiService,
|
DeletedNodesApiService,
|
||||||
FavoritesApiService,
|
FavoritesApiService,
|
||||||
NodesApiService,
|
NodesApiService,
|
||||||
PeopleApiService,
|
PeopleContentService,
|
||||||
SearchApiService,
|
SearchApiService,
|
||||||
SharedLinksApiService,
|
SharedLinksApiService,
|
||||||
SitesApiService,
|
SitesApiService,
|
||||||
DiscoveryApiService,
|
DiscoveryApiService,
|
||||||
HighlightTransformService,
|
HighlightTransformService,
|
||||||
MomentDateAdapter
|
MomentDateAdapter,
|
||||||
|
PeopleProcessService
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,25 +15,16 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* tslint:disable:component-selector */
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
export class GroupUserModel {
|
@Injectable()
|
||||||
|
export class AppConfigServiceMock {
|
||||||
|
|
||||||
company: string;
|
constructor() { }
|
||||||
email: string;
|
|
||||||
firstName: string;
|
/** @override */
|
||||||
id: string;
|
get(key: string) { }
|
||||||
lastName: string;
|
|
||||||
userImage: 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@@ -16,19 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* This object represent the process service user.*
|
||||||
* This object represent the user.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @returns {User} .
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export class User {
|
export class LightUserRepresentation {
|
||||||
id: number;
|
id: number;
|
||||||
email: string;
|
email: string;
|
||||||
firstName: string;
|
firstName: string;
|
||||||
lastName: string;
|
lastName: string;
|
||||||
userImage: string = null;
|
pictureId: number = null;
|
||||||
|
|
||||||
constructor(obj?: any) {
|
constructor(obj?: any) {
|
||||||
if (obj) {
|
if (obj) {
|
||||||
@@ -36,6 +32,8 @@ export class User {
|
|||||||
this.email = obj.email || null;
|
this.email = obj.email || null;
|
||||||
this.firstName = obj.firstName || null;
|
this.firstName = obj.firstName || null;
|
||||||
this.lastName = obj.lastName || null;
|
this.lastName = obj.lastName || null;
|
||||||
|
this.pictureId = obj.pictureId || null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -17,8 +17,7 @@
|
|||||||
|
|
||||||
import { async, inject, TestBed } from '@angular/core/testing';
|
import { async, inject, TestBed } from '@angular/core/testing';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { AlfrescoApiService } from 'ng2-alfresco-core';
|
import { AlfrescoApiService } from './alfresco-api.service';
|
||||||
|
|
||||||
import { AuthGuardEcm } from './auth-guard-ecm.service';
|
import { AuthGuardEcm } from './auth-guard-ecm.service';
|
||||||
|
|
||||||
class RouterProvider {
|
class RouterProvider {
|
||||||
|
@@ -17,9 +17,9 @@
|
|||||||
|
|
||||||
import { async, inject, TestBed } from '@angular/core/testing';
|
import { async, inject, TestBed } from '@angular/core/testing';
|
||||||
import { AlfrescoApiService } from './alfresco-api.service';
|
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;
|
service: any = null;
|
||||||
setup: any = {
|
setup: any = {
|
||||||
rejectGetPerson: false
|
rejectGetPerson: false
|
||||||
@@ -38,11 +38,11 @@ class PeopleApiServiceTest {
|
|||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
providers: [
|
providers: [
|
||||||
alfrescoApiServiceProvider,
|
alfrescoApiServiceProvider,
|
||||||
PeopleApiService
|
PeopleContentService
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
inject([ PeopleApiService ], (service) => {
|
inject([ PeopleContentService ], (service) => {
|
||||||
this.service = service;
|
this.service = service;
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,7 @@ class PeopleApiServiceTest {
|
|||||||
describe('PeopleAPI', () => {
|
describe('PeopleAPI', () => {
|
||||||
describe('Get persons', () => {
|
describe('Get persons', () => {
|
||||||
it('calls method by an id', async(() => {
|
it('calls method by an id', async(() => {
|
||||||
const test = new PeopleApiServiceTest();
|
const test = new PeopleContentServiceTest();
|
||||||
|
|
||||||
test.service.getPerson('person-1').subscribe(() => {
|
test.service.getPerson('person-1').subscribe(() => {
|
||||||
expect(test.peopleApiGetPersonArguments[0])
|
expect(test.peopleApiGetPersonArguments[0])
|
||||||
@@ -90,7 +90,7 @@ describe('PeopleAPI', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('calls method with "-me-"', async(() => {
|
it('calls method with "-me-"', async(() => {
|
||||||
const test = new PeopleApiServiceTest();
|
const test = new PeopleContentServiceTest();
|
||||||
|
|
||||||
test.service.getCurrentPerson().subscribe(() => {
|
test.service.getCurrentPerson().subscribe(() => {
|
||||||
expect(test.peopleApiGetPersonArguments[0])
|
expect(test.peopleApiGetPersonArguments[0])
|
||||||
@@ -99,7 +99,7 @@ describe('PeopleAPI', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('handles the error when it fails', async(() => {
|
it('handles the error when it fails', async(() => {
|
||||||
const test = new PeopleApiServiceTest({
|
const test = new PeopleContentServiceTest({
|
||||||
rejectGetPerson: true
|
rejectGetPerson: true
|
||||||
});
|
});
|
||||||
|
|
@@ -20,7 +20,7 @@ import { Observable } from 'rxjs/Rx';
|
|||||||
import { AlfrescoApiService } from './alfresco-api.service';
|
import { AlfrescoApiService } from './alfresco-api.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PeopleApiService {
|
export class PeopleContentService {
|
||||||
|
|
||||||
constructor(private apiService: AlfrescoApiService) {}
|
constructor(private apiService: AlfrescoApiService) {}
|
||||||
|
|
@@ -16,44 +16,47 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { TestBed } from '@angular/core/testing';
|
||||||
import { AppConfigService, CoreModule } from 'ng2-alfresco-core';
|
|
||||||
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
|
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
|
||||||
import { User } from '../models/user.model';
|
import { LightUserRepresentation } from '../models/user-process.model';
|
||||||
import { PeopleService } from './people.service';
|
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;
|
declare let jasmine: any;
|
||||||
|
|
||||||
const firstInvolvedUser: User = new User({
|
const firstInvolvedUser: LightUserRepresentation = new LightUserRepresentation({
|
||||||
id: '1',
|
id: '1',
|
||||||
email: 'fake-user1@fake.com',
|
email: 'fake-user1@fake.com',
|
||||||
firstName: 'fakeName1',
|
firstName: 'fakeName1',
|
||||||
lastName: 'fakeLast1'
|
lastName: 'fakeLast1'
|
||||||
});
|
});
|
||||||
|
|
||||||
const secondInvolvedUser: User = new User({
|
const secondInvolvedUser: LightUserRepresentation = new LightUserRepresentation({
|
||||||
id: '2',
|
id: '2',
|
||||||
email: 'fake-user2@fake.com',
|
email: 'fake-user2@fake.com',
|
||||||
firstName: 'fakeName2',
|
firstName: 'fakeName2',
|
||||||
lastName: 'fakeLast2'
|
lastName: 'fakeLast2'
|
||||||
});
|
});
|
||||||
|
|
||||||
const fakeInvolveUserList: User[] = [firstInvolvedUser, secondInvolvedUser];
|
const fakeInvolveUserList: LightUserRepresentation[] = [firstInvolvedUser, secondInvolvedUser];
|
||||||
|
|
||||||
describe('PeopleService', () => {
|
describe('PeopleProcessService', () => {
|
||||||
|
|
||||||
let service: PeopleService;
|
let service: PeopleProcessService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
|
||||||
CoreModule
|
|
||||||
],
|
|
||||||
providers: [
|
providers: [
|
||||||
PeopleService,
|
PeopleProcessService,
|
||||||
|
AlfrescoApiService,
|
||||||
|
StorageService,
|
||||||
|
LogService,
|
||||||
{ provide: AppConfigService, useClass: AppConfigServiceMock }
|
{ provide: AppConfigService, useClass: AppConfigServiceMock }
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
service = TestBed.get(PeopleService);
|
service = TestBed.get(PeopleProcessService);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when user is logged in', () => {
|
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) => {
|
it('should be able to retrieve people to involve in the task', (done) => {
|
||||||
service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe(
|
service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe(
|
||||||
(users: User[]) => {
|
(users: LightUserRepresentation[]) => {
|
||||||
expect(users).toBeDefined();
|
expect(users).toBeDefined();
|
||||||
expect(users.length).toBe(2);
|
expect(users.length).toBe(2);
|
||||||
expect(users[0].id).toEqual('1');
|
expect(users[0].id).toEqual('1');
|
||||||
@@ -85,12 +88,12 @@ describe('PeopleService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to get people images for people retrieved', (done) => {
|
it('should be able to get people images for people retrieved', (done) => {
|
||||||
service.getWorkflowUsersWithImages('fake-task-id', 'fake-filter').subscribe(
|
service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe(
|
||||||
(users: User[]) => {
|
(users: LightUserRepresentation[]) => {
|
||||||
expect(users).toBeDefined();
|
expect(users).toBeDefined();
|
||||||
expect(users.length).toBe(2);
|
expect(users.length).toBe(2);
|
||||||
expect(users[0].userImage).toContain('/users/' + users[0].id + '/picture');
|
expect(service.getUserImage(users[0])).toContain('/users/' + users[0].id + '/picture');
|
||||||
expect(users[1].userImage).toContain('/users/' + users[1].id + '/picture');
|
expect(service.getUserImage(users[1])).toContain('/users/' + users[1].id + '/picture');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
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', () => {
|
it('should return user image url', () => {
|
||||||
let url = service.getUserImage(firstInvolvedUser);
|
let url = service.getUserImage(firstInvolvedUser);
|
||||||
|
|
||||||
@@ -118,7 +111,7 @@ describe('PeopleService', () => {
|
|||||||
|
|
||||||
it('should return empty list when there are no users to involve', (done) => {
|
it('should return empty list when there are no users to involve', (done) => {
|
||||||
service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe(
|
service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe(
|
||||||
(users: User[]) => {
|
(users: LightUserRepresentation[]) => {
|
||||||
expect(users).toBeDefined();
|
expect(users).toBeDefined();
|
||||||
expect(users.length).toBe(0);
|
expect(users.length).toBe(0);
|
||||||
done();
|
done();
|
@@ -17,49 +17,36 @@
|
|||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Response } from '@angular/http';
|
import { Response } from '@angular/http';
|
||||||
import { AlfrescoApiService, LogService } from 'ng2-alfresco-core';
|
|
||||||
import { Observable } from 'rxjs/Rx';
|
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()
|
@Injectable()
|
||||||
export class PeopleService {
|
export class PeopleProcessService {
|
||||||
|
|
||||||
constructor(private alfrescoJsApi: AlfrescoApiService,
|
constructor(private alfrescoJsApi: AlfrescoApiService,
|
||||||
private logService: LogService) {
|
private logService: LogService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
getWorkflowUsers(taskId?: string, searchWord?: string): Observable<User[]> {
|
getWorkflowUsers(taskId?: string, searchWord?: string): Observable<LightUserRepresentation[]> {
|
||||||
let option = { excludeTaskId: taskId, filter: searchWord };
|
let option = { excludeTaskId: taskId, filter: searchWord };
|
||||||
return Observable.fromPromise(this.getWorkflowUserApi(option))
|
return Observable.fromPromise(this.getWorkflowUserApi(option))
|
||||||
.map((response: any) => <User[]> response.data || [])
|
.map((response: any) => <LightUserRepresentation[]> response.data || [])
|
||||||
.catch(err => this.handleError(err));
|
.catch(err => this.handleError(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
getWorkflowUsersWithImages(taskId?: string, searchWord?: string): Observable<User[]> {
|
getUserImage(user: LightUserRepresentation): string {
|
||||||
let option = { excludeTaskId: taskId, filter: searchWord };
|
|
||||||
return Observable.fromPromise(this.getWorkflowUserApi(option))
|
|
||||||
.switchMap((response: any) => <User[]> response.data || [])
|
|
||||||
.map((user: User) => this.addImageToUser(user))
|
|
||||||
.combineAll()
|
|
||||||
.catch(err => this.handleError(err));
|
|
||||||
}
|
|
||||||
|
|
||||||
getUserImage(user: User): string {
|
|
||||||
return this.getUserProfileImageApi(user.id + '');
|
return this.getUserProfileImageApi(user.id + '');
|
||||||
}
|
}
|
||||||
|
|
||||||
addImageToUser(user: User): Observable<User> {
|
involveUserWithTask(taskId: string, idToInvolve: string): Observable<LightUserRepresentation[]> {
|
||||||
user.userImage = this.getUserImage(user);
|
|
||||||
return Observable.of(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
involveUserWithTask(taskId: string, idToInvolve: string): Observable<User[]> {
|
|
||||||
let node = {userId: idToInvolve};
|
let node = {userId: idToInvolve};
|
||||||
return Observable.fromPromise(this.involveUserToTaskApi(taskId, node))
|
return Observable.fromPromise(this.involveUserToTaskApi(taskId, node))
|
||||||
.catch(err => this.handleError(err));
|
.catch(err => this.handleError(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
removeInvolvedUser(taskId: string, idToRemove: string): Observable<User[]> {
|
removeInvolvedUser(taskId: string, idToRemove: string): Observable<LightUserRepresentation[]> {
|
||||||
let node = {userId: idToRemove};
|
let node = {userId: idToRemove};
|
||||||
return Observable.fromPromise(this.removeInvolvedUserFromTaskApi(taskId, node))
|
return Observable.fromPromise(this.removeInvolvedUserFromTaskApi(taskId, node))
|
||||||
.catch(err => this.handleError(err));
|
.catch(err => this.handleError(err));
|
Reference in New Issue
Block a user