[ADF-1004] The process service definition file in the alfresco-js-api is incomplete (#2488)

* correction after new declaration file for PS

* remove unused jasmine

* commit ifx initial pipe

* fix tasklist test

* fix tasklist test

* reinsert test
This commit is contained in:
Eugenio Romano
2017-10-18 09:20:19 +01:00
committed by Denys Vuika
parent 0cc578ba0e
commit 036c63e43d
86 changed files with 1136 additions and 1162 deletions

View File

@@ -18,14 +18,13 @@
// tslint:disable-next-line:adf-file-name
import { AfterViewInit, Component, ElementRef, Input, OnDestroy, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Pagination } from 'alfresco-js-api';
import { Pagination, ProcessInstanceFilterRepresentation } from 'alfresco-js-api';
import { AnalyticsReportListComponent } from 'ng2-activiti-analytics';
import {
DynamicTableRow, FORM_FIELD_VALIDATORS, FormEvent, FormFieldEvent, FormRenderingService,
FormService, ValidateDynamicTableRowEvent
} from 'ng2-activiti-form';
import {
FilterProcessRepresentationModel,
ProcessFiltersComponent,
ProcessInstance,
ProcessInstanceDetailsComponent,
@@ -115,7 +114,7 @@ export class ActivitiDemoComponent implements AfterViewInit, OnDestroy, OnInit {
taskFilter: FilterRepresentationModel;
report: any;
processFilter: FilterProcessRepresentationModel;
processFilter: ProcessInstanceFilterRepresentation;
sub: Subscription;
blobFile: any;
@@ -276,7 +275,7 @@ export class ActivitiDemoComponent implements AfterViewInit, OnDestroy, OnInit {
this.currentTaskId = this.taskList.getCurrentId();
}
onProcessFilterClick(event: FilterProcessRepresentationModel): void {
onProcessFilterClick(event: ProcessInstanceFilterRepresentation): void {
this.currentProcessInstanceId = null;
this.processFilter = event;
}

View File

@@ -53,8 +53,6 @@ describe('AnalyticsGeneratorComponent', () => {
let debug: DebugElement;
let element: HTMLElement;
let componentHandler: any;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
@@ -83,10 +81,6 @@ describe('AnalyticsGeneratorComponent', () => {
component = fixture.componentInstance;
debug = fixture.debugElement;
element = fixture.nativeElement;
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered'
]);
window['componentHandler'] = componentHandler;
fixture.detectChanges();

View File

@@ -29,7 +29,6 @@ declare let jasmine: any;
describe('AnalyticsReportHeatMapComponent', () => {
let componentHandler: any;
let component: AnalyticsReportHeatMapComponent;
let fixture: ComponentFixture<AnalyticsReportHeatMapComponent>;
let debug: DebugElement;
@@ -70,10 +69,6 @@ describe('AnalyticsReportHeatMapComponent', () => {
component = fixture.componentInstance;
debug = fixture.debugElement;
element = fixture.nativeElement;
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered'
]);
window['componentHandler'] = componentHandler;
component.report = {
totalCountsPercentages: totalCountPerc,

View File

@@ -35,7 +35,7 @@ export class AnalyticsReportListComponent implements OnInit {
layoutType: string = AnalyticsReportListComponent.LAYOUT_LIST;
@Input()
appId: string;
appId: number;
@Input()
selectFirst: boolean = false;
@@ -83,7 +83,7 @@ export class AnalyticsReportListComponent implements OnInit {
/**
* Get the report list
*/
getReportList(appId: string, reportId?: string) {
getReportList(appId: number, reportId?: string) {
this.analyticsService.getReportList(appId).subscribe(
(res: ReportParametersModel[]) => {
if (res && res.length === 0) {

View File

@@ -36,8 +36,6 @@ describe('AnalyticsReportParametersComponent', () => {
let debug: DebugElement;
let element: HTMLElement;
let componentHandler: any;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
@@ -59,11 +57,6 @@ describe('AnalyticsReportParametersComponent', () => {
spyOn(translateService, 'get').and.callFake((key) => {
return Observable.of(key);
});
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered'
]);
window['componentHandler'] = componentHandler;
}));
beforeEach(() => {
@@ -327,7 +320,7 @@ describe('AnalyticsReportParametersComponent', () => {
responseText: analyticParamsMock.reportDefParamProcessDef
});
let appId = '1';
let appId = 1;
jasmine.Ajax.stubRequest('http://localhost:9876/bpm/activiti-app/api/enterprise/process-definitions?appDefinitionId=' + appId).andReturn({
status: 200,

View File

@@ -17,7 +17,6 @@
import {
AfterContentChecked,
AfterViewChecked,
Component,
EventEmitter,
Input,
@@ -36,20 +35,18 @@ import { ParameterValueModel, ReportParameterDetailsModel, ReportParametersModel
import { ContentService, LogService } from 'ng2-alfresco-core';
import { AnalyticsService } from '../services/analytics.service';
declare var componentHandler;
@Component({
selector: 'adf-analytics-report-parameters, analytics-report-parameters',
templateUrl: './analytics-report-parameters.component.html',
styleUrls: ['./analytics-report-parameters.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class AnalyticsReportParametersComponent implements OnInit, OnChanges, OnDestroy, AfterViewChecked, AfterContentChecked {
export class AnalyticsReportParametersComponent implements OnInit, OnChanges, OnDestroy, AfterContentChecked {
public static FORMAT_DATE_ACTIVITI: string = 'YYYY-MM-DD';
@Input()
appId: string;
appId: number;
@Input()
reportId: string;
@@ -208,7 +205,7 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
);
}
private retrieveParameterOptions(parameters: ReportParameterDetailsModel[], appId: string, reportId?: string, processDefinitionId?: string) {
private retrieveParameterOptions(parameters: ReportParameterDetailsModel[], appId: number, reportId?: string, processDefinitionId?: string) {
parameters.forEach((param) => {
this.analyticsService.getParamValuesByType(param.type, appId, reportId, processDefinitionId).subscribe(
(opts: ParameterValueModel[]) => {
@@ -371,12 +368,6 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
}, error => this.logService.error(error));
}
ngAfterViewChecked() {
if (componentHandler) {
componentHandler.upgradeAllRegistered();
}
}
ngAfterContentChecked() {
if (this.reportForm && this.reportForm.valid) {
this.reportForm.markAsDirty();

View File

@@ -51,8 +51,6 @@ describe('AnalyticsComponent', () => {
let debug: DebugElement;
let element: HTMLElement;
let componentHandler: any;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
@@ -79,10 +77,6 @@ describe('AnalyticsComponent', () => {
debug = fixture.debugElement;
element = fixture.nativeElement;
fixture.detectChanges();
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered'
]);
window['componentHandler'] = componentHandler;
});
describe('Rendering tests', () => {

View File

@@ -51,7 +51,7 @@ describe('Activiti Analytics Service', () => {
describe('Content tests', () => {
it('should return the report list by appId', (done) => {
service.getReportList('1').subscribe(
service.getReportList(1).subscribe(
(reportList) => {
expect(reportList).toBeDefined();
expect(reportList.length).toEqual(2);

View File

@@ -41,7 +41,7 @@ export class AnalyticsService {
* Retrive all the Deployed app
* @returns {Observable<any>}
*/
getReportList(appId: string): Observable<any> {
getReportList(appId: number): Observable<any> {
return Observable.fromPromise(this.apiService.getInstance().activiti.reportApi.getReportList())
.map((res: any) => {
let reports: ReportParametersModel[] = [];
@@ -67,9 +67,9 @@ export class AnalyticsService {
}).catch(err => this.handleError(err));
}
private isReportValid(appId: string, report: ReportParametersModel) {
private isReportValid(appId: number, report: ReportParametersModel) {
let isValid: boolean = true;
if (appId && appId !== '0' && report.name.includes('Process definition overview')) {
if (appId && appId !== 0 && report.name.includes('Process definition overview')) {
isValid = false;
}
return isValid;
@@ -82,7 +82,7 @@ export class AnalyticsService {
}).catch(err => this.handleError(err));
}
getParamValuesByType(type: string, appId: string, reportId?: string, processDefinitionId?: string) {
getParamValuesByType(type: string, appId: number, reportId?: string, processDefinitionId?: string) {
if (type === 'status') {
return this.getProcessStatusValues();
} else if (type === 'processDefinition') {
@@ -155,7 +155,7 @@ export class AnalyticsService {
}).catch(err => this.handleError(err));
}
getProcessDefinitionsValues(appId: string): Observable<any> {
getProcessDefinitionsValues(appId: number): Observable<any> {
let options = {'appDefinitionId': appId};
return Observable.fromPromise(this.apiService.getInstance().activiti.processDefinitionsApi.getProcessDefinitions(options))
.map((res: any) => {

View File

@@ -42,8 +42,6 @@ describe('Test ng2-activiti-diagrams ', () => {
let debug: DebugElement;
let element: HTMLElement;
let componentHandler: any;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
@@ -67,11 +65,6 @@ describe('Test ng2-activiti-diagrams ', () => {
debug = fixture.debugElement;
element = fixture.nativeElement;
fixture.detectChanges();
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered',
'upgradeElement'
]);
window['componentHandler'] = componentHandler;
});
describe('Diagrams component Events: ', () => {

View File

@@ -18,7 +18,7 @@
import { OverlayContainer } from '@angular/cdk/overlay';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { CoreModule, LightUserRepresentation } from 'ng2-alfresco-core';
import { CoreModule, UserProcessModel } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx';
import { ActivitiAlfrescoContentService } from '../../../services/activiti-alfresco.service';
import { FormService } from '../../../services/form.service';
@@ -85,7 +85,7 @@ describe('PeopleWidgetComponent', () => {
});
it('should return full name for a given model', () => {
let model = new LightUserRepresentation({
let model = new UserProcessModel({
firstName: 'John',
lastName: 'Doe'
});
@@ -93,17 +93,17 @@ describe('PeopleWidgetComponent', () => {
});
it('should skip first name for display name', () => {
let model = new LightUserRepresentation({firstName: null, lastName: 'Doe'});
let model = new UserProcessModel({firstName: null, lastName: 'Doe'});
expect(widget.getDisplayName(model)).toBe('Doe');
});
it('should skip last name for display name', () => {
let model = new LightUserRepresentation({firstName: 'John', lastName: null});
let model = new UserProcessModel({firstName: 'John', lastName: null});
expect(widget.getDisplayName(model)).toBe('John');
});
it('should init value from the field', () => {
widget.field.value = new LightUserRepresentation({
widget.field.value = new UserProcessModel({
id: 'people-id',
firstName: 'John',
lastName: 'Doe'
@@ -238,7 +238,7 @@ describe('PeopleWidgetComponent', () => {
});
it('should reset users when the input field is blank string', () => {
let fakeUser = new LightUserRepresentation({id: '1', email: 'ffff@fff'});
let fakeUser = new UserProcessModel({id: '1', email: 'ffff@fff'});
widget.users.push(fakeUser);
fixture.detectChanges();

View File

@@ -19,7 +19,7 @@
import { ENTER, ESCAPE } from '@angular/cdk/keycodes';
import { Component, ElementRef, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
import { LightUserRepresentation, PeopleProcessService } from 'ng2-alfresco-core';
import { PeopleProcessService, UserProcessModel } from 'ng2-alfresco-core';
import { FormService } from '../../../services/form.service';
import { GroupModel } from '../core/group.model';
import { baseHost, WidgetComponent } from './../widget.component';
@@ -38,7 +38,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
minTermLength: number = 1;
oldValue: string;
users: LightUserRepresentation[] = [];
users: UserProcessModel[] = [];
groupId: string;
constructor(public formService: FormService, public peopleProcessService: PeopleProcessService) {
@@ -71,7 +71,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
searchUsers(userName: string) {
this.formService.getWorkflowUsers(userName, this.groupId)
.subscribe((result: LightUserRepresentation[]) => {
.subscribe((result: UserProcessModel[]) => {
this.users = result || [];
this.validateValue(userName);
});
@@ -93,7 +93,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
isValidUser(value: string): boolean {
let isValid = false;
if (value) {
let resultUser: LightUserRepresentation = this.users.find((user) => this.getDisplayName(user).toLocaleLowerCase() === value.toLocaleLowerCase());
let resultUser: UserProcessModel = this.users.find((user) => this.getDisplayName(user).toLocaleLowerCase() === value.toLocaleLowerCase());
if (resultUser) {
isValid = true;
@@ -103,7 +103,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
return isValid;
}
getDisplayName(model: LightUserRepresentation) {
getDisplayName(model: UserProcessModel) {
if (model) {
let displayName = `${model.firstName || ''} ${model.lastName || ''}`;
return displayName.trim();
@@ -111,7 +111,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
return '';
}
onItemSelect(item: LightUserRepresentation) {
onItemSelect(item: UserProcessModel) {
if (item) {
this.field.value = item;
}

View File

@@ -60,7 +60,7 @@ export class ActivitiContentService {
* @param contentId
* @returns {any}
*/
deleteRelatedContent(contentId: string): Observable<any> {
deleteRelatedContent(contentId: number): Observable<any> {
return Observable.fromPromise(this.apiService.getInstance().activiti.contentApi.deleteContent(contentId))
.catch(err => this.handleError(err));
}

View File

@@ -16,7 +16,7 @@
*/
import { Injectable } from '@angular/core';
import { AlfrescoApiService, LightUserRepresentation, LogService } from 'ng2-alfresco-core';
import { AlfrescoApiService, LogService, UserProcessModel } from 'ng2-alfresco-core';
import { Observable, Subject } from 'rxjs/Rx';
import { FormDefinitionModel } from '../models/form-definition.model';
import { ContentLinkModel } from './../components/widgets/core/content-link.model';
@@ -371,17 +371,17 @@ export class FormService {
return Observable.fromPromise(this.taskApi.getRestFieldValuesColumn(taskId, field, column)).catch(err => this.handleError(err));
}
private getUserProfileImageApi(userId: string): string {
private getUserProfileImageApi(userId: number): string {
return this.apiService.getInstance().activiti.userApi.getUserProfilePictureUrl(userId);
}
getWorkflowUsers(filter: string, groupId?: string): Observable<LightUserRepresentation[]> {
getWorkflowUsers(filter: string, groupId?: string): Observable<UserProcessModel[]> {
let option: any = {filter: filter};
if (groupId) {
option.groupId = groupId;
}
return Observable.fromPromise(this.usersWorkflowApi.getUsers(option))
.switchMap((response: any) => <LightUserRepresentation[]> response.data || [])
.switchMap((response: any) => <UserProcessModel[]> response.data || [])
.map((user: any) => {
user.userImage = this.getUserProfileImageApi(user.id);
return Observable.of(user);

View File

@@ -15,8 +15,7 @@
* limitations under the License.
*/
import { AppDefinitionRepresentationModel, Comment, TaskDetailsModel } from 'ng2-activiti-tasklist';
import { LightUserRepresentation } from 'ng2-alfresco-core';
import { AppDefinitionRepresentationModel, TaskDetailsModel } from 'ng2-activiti-tasklist';
import { FilterProcessRepresentationModel } from '../models/filter-process.model';
import { ProcessDefinitionRepresentation } from '../models/process-definition.model';
@@ -76,13 +75,6 @@ export let fakeTaskList = {
})]
};
export let fakeComment = new Comment(1, 'Test', '2016-11-10T03:37:30.010+0000', new LightUserRepresentation({
id: 13,
firstName: 'Wilbur',
lastName: 'Adams',
email: 'wilbur@app.com'
}));
export let fakeProcessDef = new ProcessDefinitionRepresentation({
id: '32323',
key: 'blah',

View File

@@ -25,7 +25,6 @@ declare let jasmine: any;
describe('Activiti Process Create Attachment', () => {
let componentHandler: any;
let service: ActivitiContentService;
let component: CreateProcessAttachmentComponent;
let fixture: ComponentFixture<CreateProcessAttachmentComponent>;
@@ -70,12 +69,6 @@ describe('Activiti Process Create Attachment', () => {
service = fixture.debugElement.injector.get(ActivitiContentService);
element = fixture.nativeElement;
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered',
'upgradeElement'
]);
window['componentHandler'] = componentHandler;
component.processInstanceId = '9999';
fixture.detectChanges();
});

View File

@@ -30,7 +30,6 @@ import { ProcessAttachmentListComponent } from './process-attachment-list.compon
describe('ProcessAttachmentListComponent', () => {
let componentHandler: any;
let service: ActivitiContentService;
let component: ProcessAttachmentListComponent;
let fixture: ComponentFixture<ProcessAttachmentListComponent>;
@@ -123,12 +122,6 @@ describe('ProcessAttachmentListComponent', () => {
getFileRawContentSpy = spyOn(service, 'getFileRawContent').and.returnValue(Observable.of(
blobObj
));
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered',
'upgradeElement'
]);
window['componentHandler'] = componentHandler;
});
it('should load attachments when processInstanceId specified', () => {

View File

@@ -108,7 +108,7 @@ export class ProcessAttachmentListComponent implements OnChanges {
}
}
private deleteAttachmentById(contentId: string) {
private deleteAttachmentById(contentId: number) {
if (contentId) {
this.activitiContentService.deleteRelatedContent(contentId).subscribe(
(res: any) => {

View File

@@ -27,4 +27,36 @@
.hide-long-names {
overflow: auto;
}
}
.adf-comments-container {
height: 100%;
width: 100%;
overflow: auto;
}
.adf-comments-header {
padding: 10px 20px;
font-size: 14px;
font-weight: 600;
border-bottom: 1px solid #e1e1e1;
color: #a1a1a1;
}
.adf-comments-input-container {
padding: 0 15px;
width: calc(100% - 30px);
padding-top: 8px;
border-bottom: 1px solid #e1e1e1;
}
.adf-full-width {
width: 100%;
}
adf-comment-list {
float: left;
overflow: auto;
height: calc(100% - 101px);
width: 100%;
}

View File

@@ -1 +1,15 @@
<adf-comments [readOnly]="readOnly" [taskId]="processInstanceId" (error)="onError($event)" #activiticomments></adf-comments>
<div class="adf-comments-container">
<div id="comment-header" class="adf-comments-header">
{{'DETAILS.COMMENTS.HEADER' | translate: { count: comments?.length} }}
</div>
<div class="adf-comments-input-container" *ngIf="!isReadOnly()">
<mat-form-field class="adf-full-width">
<input matInput id="comment-input" placeholder="{{'DETAILS.COMMENTS.ADD' | translate}}" [(ngModel)]="message" (keyup.enter)="add()" (keyup.esc)="clear()">
</mat-form-field>
</div>
<div *ngIf="comments.length > 0">
<adf-comment-list [comments]="comments">
</adf-comment-list>
</div>
</div>

View File

@@ -16,6 +16,7 @@
*/
import { DatePipe } from '@angular/common';
import { SimpleChange } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MatInputModule } from '@angular/material';
import { Observable } from 'rxjs/Rx';
@@ -25,7 +26,7 @@ import {
CommentsComponent,
TaskListService
} from 'ng2-activiti-tasklist';
import { AlfrescoTranslationService, CoreModule, PeopleProcessService } from 'ng2-alfresco-core';
import { AlfrescoTranslationService, CommentProcessService, CoreModule, PeopleProcessService } from 'ng2-alfresco-core';
import { DataTableModule } from 'ng2-alfresco-datatable';
import { TranslationMock } from './../assets/translation.service.mock';
@@ -34,11 +35,11 @@ import { ProcessCommentsComponent } from './process-comments.component';
describe('ActivitiProcessInstanceComments', () => {
let componentHandler: any;
let service: TaskListService;
let component: ProcessCommentsComponent;
let fixture: ComponentFixture<ProcessCommentsComponent>;
let getCommentsSpy: jasmine.Spy;
let commentProcessService: CommentProcessService;
beforeEach(async(() => {
TestBed.configureTestingModule({
@@ -56,7 +57,8 @@ describe('ActivitiProcessInstanceComments', () => {
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
{ provide: TaskListService, useClass: ProcessService },
DatePipe,
PeopleProcessService
PeopleProcessService,
CommentProcessService
]
}).compileComponents();
}));
@@ -65,23 +67,19 @@ describe('ActivitiProcessInstanceComments', () => {
fixture = TestBed.createComponent(ProcessCommentsComponent);
component = fixture.componentInstance;
service = fixture.debugElement.injector.get(TaskListService);
service = TestBed.get(TaskListService);
commentProcessService = TestBed.get(CommentProcessService);
getCommentsSpy = spyOn(service, 'getComments').and.returnValue(Observable.of([
getCommentsSpy = spyOn(commentProcessService, 'getProcessInstanceComments').and.returnValue(Observable.of([
{ message: 'Test1', created: Date.now(), createdBy: {firstName: 'Admin', lastName: 'User'} },
{ message: 'Test2', created: Date.now(), createdBy: {firstName: 'Admin', lastName: 'User'} },
{ message: 'Test3', created: Date.now(), createdBy: {firstName: 'Admin', lastName: 'User'} }
]));
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered',
'upgradeElement'
]);
window['componentHandler'] = componentHandler;
});
it('should load comments when processInstanceId specified', () => {
component.processInstanceId = '123';
let change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change });
fixture.detectChanges();
expect(getCommentsSpy).toHaveBeenCalled();
});
@@ -89,7 +87,10 @@ describe('ActivitiProcessInstanceComments', () => {
it('should emit an error when an error occurs loading comments', () => {
let emitSpy = spyOn(component.error, 'emit');
getCommentsSpy.and.returnValue(Observable.throw({}));
component.processInstanceId = '123';
let change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change });
fixture.detectChanges();
expect(emitSpy).toHaveBeenCalled();
});
@@ -100,7 +101,9 @@ describe('ActivitiProcessInstanceComments', () => {
});
it('should display comments when the process has comments', async(() => {
component.processInstanceId = '123';
let change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change });
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(fixture.nativeElement.querySelectorAll('#comment-message').length).toBe(3);
@@ -109,17 +112,20 @@ describe('ActivitiProcessInstanceComments', () => {
}));
it('should display comments count when the process has comments', () => {
component.processInstanceId = '123';
let change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change });
fixture.whenStable().then(() => {
fixture.detectChanges();
let element = fixture.nativeElement.querySelector('#comment-header');
expect(element.innerText).toBe('TASK_DETAILS.COMMENTS.HEADER');
expect(element.innerText).toBe('DETAILS.COMMENTS.HEADER');
});
});
it('should not display comments when the process has no comments', async(() => {
component.processInstanceId = '123';
let change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change });
getCommentsSpy.and.returnValue(Observable.of([]));
fixture.whenStable().then(() => {
fixture.detectChanges();
@@ -128,7 +134,9 @@ describe('ActivitiProcessInstanceComments', () => {
}));
it('should not display comments input by default', async(() => {
component.processInstanceId = '123';
let change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change });
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(fixture.nativeElement.querySelector('#comment-input')).toBeNull();

View File

@@ -15,17 +15,16 @@
* limitations under the License.
*/
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { TaskListService } from 'ng2-activiti-tasklist';
import { ProcessService } from './../services/process.service';
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
import { CommentProcessModel, CommentProcessService } from 'ng2-alfresco-core';
import { Observable, Observer } from 'rxjs/Rx';
@Component({
selector: 'adf-process-instance-comments, activiti-process-instance-comments',
templateUrl: './process-comments.component.html',
styleUrls: ['./process-comments.component.css'],
providers: [{provide: TaskListService, useClass: ProcessService}]
styleUrls: ['./process-comments.component.css']
})
export class ProcessCommentsComponent {
export class ProcessCommentsComponent implements OnChanges {
@Input()
processInstanceId: string;
@@ -36,7 +35,87 @@ export class ProcessCommentsComponent {
@Output()
error: EventEmitter<any> = new EventEmitter<any>();
comments: CommentProcessModel [] = [];
private commentObserver: Observer<CommentProcessModel>;
comment$: Observable<CommentProcessModel>;
message: string;
beingAdded: boolean = false;
constructor(private commentProcessService: CommentProcessService) {
this.comment$ = new Observable<CommentProcessModel>(observer => this.commentObserver = observer).share();
this.comment$.subscribe((comment: CommentProcessModel) => {
this.comments.push(comment);
});
}
ngOnChanges(changes: SimpleChanges) {
let processInstanceId = changes['processInstanceId'];
if (processInstanceId) {
if (processInstanceId.currentValue) {
this.getProcessInstanceComments(processInstanceId.currentValue);
} else {
this.resetComments();
}
}
}
private getProcessInstanceComments(processInstanceId: string): void {
this.resetComments();
if (processInstanceId) {
this.commentProcessService.getProcessInstanceComments(processInstanceId).subscribe(
(res: CommentProcessModel[]) => {
res = res.sort((comment1: CommentProcessModel, comment2: CommentProcessModel) => {
let date1 = new Date(comment1.created);
let date2 = new Date(comment2.created);
return date1 > date2 ? -1 : date1 < date2 ? 1 : 0;
});
res.forEach((comment) => {
this.commentObserver.next(comment);
});
},
(err) => {
this.error.emit(err);
}
);
}
}
private resetComments(): void {
this.comments = [];
}
add(): void {
if (this.message && this.message.trim() && !this.beingAdded) {
this.beingAdded = true;
this.commentProcessService.addProcessInstanceComment(this.processInstanceId, this.message)
.subscribe(
(res: CommentProcessModel) => {
this.comments.unshift(res);
this.message = '';
this.beingAdded = false;
},
(err) => {
this.error.emit(err);
this.beingAdded = false;
}
);
}
}
clear(): void {
this.message = '';
}
isReadOnly(): boolean {
return this.readOnly;
}
onError(error: any) {
this.error.emit(error);
}
}

View File

@@ -16,7 +16,7 @@
*/
import { SimpleChange } from '@angular/core';
import { LogServiceMock } from 'ng2-alfresco-core';
import { AppsProcessService, LogServiceMock } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx';
import { FilterProcessRepresentationModel } from '../models/filter-process.model';
import { ProcessService } from '../services/process.service';
@@ -25,7 +25,8 @@ import { ProcessFiltersComponent } from './process-filters.component';
describe('ActivitiFilters', () => {
let filterList: ProcessFiltersComponent;
let activitiService: ProcessService;
let processService: ProcessService;
let appsProcessService: AppsProcessService;
let logService: LogServiceMock;
let fakeGlobalFilter = [];
@@ -57,12 +58,13 @@ describe('ActivitiFilters', () => {
beforeEach(() => {
logService = new LogServiceMock();
activitiService = new ProcessService(null, logService);
filterList = new ProcessFiltersComponent(activitiService);
processService = new ProcessService(null, logService);
appsProcessService = new AppsProcessService(null, logService);
filterList = new ProcessFiltersComponent(processService, appsProcessService);
});
it('should return the filter task list', (done) => {
spyOn(activitiService, 'getProcessFilters').and.returnValue(Observable.fromPromise(fakeGlobalFilterPromise));
spyOn(processService, 'getProcessFilters').and.returnValue(Observable.fromPromise(fakeGlobalFilterPromise));
const appId = '1';
let change = new SimpleChange(null, appId, true);
filterList.ngOnChanges({ 'appId': change });
@@ -81,7 +83,7 @@ describe('ActivitiFilters', () => {
});
it('should select the Running process filter', (done) => {
spyOn(activitiService, 'getProcessFilters').and.returnValue(Observable.fromPromise(fakeGlobalFilterPromise));
spyOn(processService, 'getProcessFilters').and.returnValue(Observable.fromPromise(fakeGlobalFilterPromise));
const appId = '1';
let change = new SimpleChange(null, appId, true);
filterList.ngOnChanges({ 'appId': change });
@@ -103,14 +105,14 @@ describe('ActivitiFilters', () => {
resolve({ id: 1 });
});
spyOn(activitiService, 'getDeployedApplications').and.returnValue(Observable.fromPromise(fakeDeployedApplicationsPromise));
spyOn(activitiService, 'getProcessFilters').and.returnValue(Observable.fromPromise(fakeGlobalFilterPromise));
spyOn(appsProcessService, 'getDeployedApplicationsByName').and.returnValue(Observable.fromPromise(fakeDeployedApplicationsPromise));
spyOn(processService, 'getProcessFilters').and.returnValue(Observable.fromPromise(fakeGlobalFilterPromise));
let change = new SimpleChange(null, 'test', true);
filterList.ngOnChanges({ 'appName': change });
filterList.onSuccess.subscribe((res) => {
let deployApp: any = activitiService.getDeployedApplications;
let deployApp: any = appsProcessService.getDeployedApplicationsByName;
expect(deployApp.calls.count()).toEqual(1);
expect(res).toBeDefined();
done();
@@ -120,7 +122,7 @@ describe('ActivitiFilters', () => {
});
it('should emit an error with a bad response', (done) => {
spyOn(activitiService, 'getProcessFilters').and.returnValue(Observable.fromPromise(fakeErrorFilterPromise));
spyOn(processService, 'getProcessFilters').and.returnValue(Observable.fromPromise(fakeErrorFilterPromise));
const appId = '1';
let change = new SimpleChange(null, appId, true);
@@ -135,7 +137,7 @@ describe('ActivitiFilters', () => {
});
it('should emit an error with a bad response', (done) => {
spyOn(activitiService, 'getDeployedApplications').and.returnValue(Observable.fromPromise(fakeErrorFilterPromise));
spyOn(appsProcessService, 'getDeployedApplicationsByName').and.returnValue(Observable.fromPromise(fakeErrorFilterPromise));
const appId = 'fake-app';
let change = new SimpleChange(null, appId, true);

View File

@@ -16,8 +16,10 @@
*/
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
import { ProcessInstanceFilterRepresentation } from 'alfresco-js-api';
import { AppsProcessService } from 'ng2-alfresco-core';
import { Observable, Observer } from 'rxjs/Rx';
import { FilterParamsModel, FilterProcessRepresentationModel } from './../models/filter-process.model';
import { FilterProcessRepresentationModel } from '../models/filter-process.model';
import { ProcessService } from './../services/process.service';
@Component({
@@ -28,13 +30,13 @@ import { ProcessService } from './../services/process.service';
export class ProcessFiltersComponent implements OnInit, OnChanges {
@Input()
filterParam: FilterParamsModel;
filterParam: FilterProcessRepresentationModel;
@Output()
filterClick: EventEmitter<FilterProcessRepresentationModel> = new EventEmitter<FilterProcessRepresentationModel>();
filterClick: EventEmitter<ProcessInstanceFilterRepresentation> = new EventEmitter<ProcessInstanceFilterRepresentation>();
@Output()
onSuccess: EventEmitter<FilterProcessRepresentationModel[]> = new EventEmitter<FilterProcessRepresentationModel[]>();
onSuccess: EventEmitter<ProcessInstanceFilterRepresentation[]> = new EventEmitter<ProcessInstanceFilterRepresentation[]>();
@Output()
onError: EventEmitter<any> = new EventEmitter<any>();
@@ -48,19 +50,19 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
@Input()
showIcon: boolean = true;
private filterObserver: Observer<FilterProcessRepresentationModel>;
filter$: Observable<FilterProcessRepresentationModel>;
private filterObserver: Observer<ProcessInstanceFilterRepresentation>;
filter$: Observable<ProcessInstanceFilterRepresentation>;
currentFilter: FilterProcessRepresentationModel;
currentFilter: ProcessInstanceFilterRepresentation;
filters: FilterProcessRepresentationModel [] = [];
filters: ProcessInstanceFilterRepresentation [] = [];
constructor(private activiti: ProcessService) {
this.filter$ = new Observable<FilterProcessRepresentationModel>(observer => this.filterObserver = observer).share();
constructor(private processService: ProcessService, private appsProcessService: AppsProcessService) {
this.filter$ = new Observable<ProcessInstanceFilterRepresentation>(observer => this.filterObserver = observer).share();
}
ngOnInit() {
this.filter$.subscribe((filter: FilterProcessRepresentationModel) => {
this.filter$.subscribe((filter: ProcessInstanceFilterRepresentation) => {
this.filters.push(filter);
});
}
@@ -82,18 +84,18 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
* Return the filter list filtered by appId
* @param appId - optional
*/
getFiltersByAppId(appId?: string) {
this.activiti.getProcessFilters(appId).subscribe(
(res: FilterProcessRepresentationModel[]) => {
getFiltersByAppId(appId?: number) {
this.processService.getProcessFilters(appId).subscribe(
(res: ProcessInstanceFilterRepresentation[]) => {
if (res.length === 0 && this.isFilterListEmpty()) {
this.activiti.createDefaultFilters(appId).subscribe(
(resDefault: FilterProcessRepresentationModel[]) => {
this.processService.createDefaultFilters(appId).subscribe(
(resDefault: ProcessInstanceFilterRepresentation[]) => {
this.resetFilter();
resDefault.forEach((filter) => {
this.filterObserver.next(filter);
});
this.selectTaskFilter(this.filterParam);
this.selectProcessFilter(this.filterParam);
this.onSuccess.emit(resDefault);
},
(errDefault: any) => {
@@ -106,7 +108,7 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
this.filterObserver.next(filter);
});
this.selectTaskFilter(this.filterParam);
this.selectProcessFilter(this.filterParam);
this.onSuccess.emit(res);
}
},
@@ -121,10 +123,10 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
* @param appName
*/
getFiltersByAppName(appName: string) {
this.activiti.getDeployedApplications(appName).subscribe(
this.appsProcessService.getDeployedApplicationsByName(appName).subscribe(
application => {
this.getFiltersByAppId(application.id.toString());
this.selectTaskFilter(this.filterParam);
this.getFiltersByAppId(application.id);
this.selectProcessFilter(this.filterParam);
},
(err) => {
this.onError.emit(err);
@@ -135,7 +137,7 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
* Pass the selected filter as next
* @param filter
*/
public selectFilter(filter: FilterProcessRepresentationModel) {
public selectFilter(filter: ProcessInstanceFilterRepresentation) {
this.currentFilter = filter;
this.filterClick.emit(filter);
}
@@ -143,12 +145,11 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
/**
* Select the first filter of a list if present
*/
public selectTaskFilter(filterParam: FilterParamsModel) {
public selectProcessFilter(filterParam: FilterProcessRepresentationModel) {
if (filterParam) {
this.filters.filter((taskFilter: FilterProcessRepresentationModel, index) => {
if (filterParam.name && filterParam.name.toLowerCase() === taskFilter.name.toLowerCase() ||
filterParam.id === taskFilter.id || filterParam.index === index) {
this.currentFilter = taskFilter;
this.filters.filter((processFilter: ProcessInstanceFilterRepresentation, index) => {
if (filterParam.name && filterParam.name.toLowerCase() === processFilter.name.toLowerCase() || filterParam.index === index) {
this.currentFilter = processFilter;
}
});
}
@@ -161,7 +162,7 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
* Select the Running filter
*/
public selectRunningFilter() {
this.selectTaskFilter(this.activiti.getRunningFilterInstance(null));
this.selectProcessFilter(this.processService.getRunningFilterInstance(null));
}
/**
@@ -175,9 +176,9 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
/**
* Return the current task
* @returns {FilterProcessRepresentationModel}
* @returns {ProcessInstanceFilterRepresentation}
*/
getCurrentFilter(): FilterProcessRepresentationModel {
getCurrentFilter(): ProcessInstanceFilterRepresentation {
return this.currentFilter;
}

View File

@@ -32,7 +32,6 @@ import { ProcessInstanceDetailsComponent } from './process-instance-details.comp
describe('ProcessInstanceDetailsComponent', () => {
let componentHandler: any;
let service: ProcessService;
let formService: FormService;
let component: ProcessInstanceDetailsComponent;
@@ -65,12 +64,6 @@ describe('ProcessInstanceDetailsComponent', () => {
formService = fixture.debugElement.injector.get(FormService);
getProcessSpy = spyOn(service, 'getProcess').and.returnValue(Observable.of(exampleProcess));
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered',
'upgradeElement'
]);
window['componentHandler'] = componentHandler;
});
it('should not load task details when no processInstanceId is specified', () => {

View File

@@ -27,7 +27,6 @@ import { ProcessInstanceHeaderComponent } from './process-instance-header.compon
describe('ProcessInstanceHeaderComponent', () => {
let service: ProcessService;
let componentHandler: any;
let component: ProcessInstanceHeaderComponent;
let fixture: ComponentFixture<ProcessInstanceHeaderComponent>;
@@ -57,12 +56,6 @@ describe('ProcessInstanceHeaderComponent', () => {
service = TestBed.get(ProcessService);
component.processInstance = new ProcessInstance(exampleProcess);
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered',
'upgradeElement'
]);
window['componentHandler'] = componentHandler;
});
it('should render empty component if no process details provided', () => {
@@ -80,7 +73,7 @@ describe('ProcessInstanceHeaderComponent', () => {
});
it('should display status as completed when process is complete', () => {
component.processInstance.ended = '2016-11-03';
component.processInstance.ended = new Date('2016-11-03');
component.ngOnChanges({});
fixture.detectChanges();
let valueEl = fixture.nativeElement.querySelector('[data-automation-id="card-textitem-value-status"]');
@@ -88,7 +81,7 @@ describe('ProcessInstanceHeaderComponent', () => {
});
it('should display due date', () => {
component.processInstance.ended = '2016-11-03';
component.processInstance.ended = new Date('2016-11-03');
component.ngOnChanges({});
fixture.detectChanges();
let valueEl = fixture.nativeElement.querySelector('[data-automation-id="card-dateitem-dueDate"]');
@@ -120,7 +113,7 @@ describe('ProcessInstanceHeaderComponent', () => {
});
it('should display created date', () => {
component.processInstance.started = '2016-11-03';
component.processInstance.started = new Date('2016-11-03');
component.ngOnChanges({});
fixture.detectChanges();
let valueEl = fixture.nativeElement.querySelector('[data-automation-id="card-dateitem-created"]');

View File

@@ -31,7 +31,6 @@ import { ProcessInstanceTasksComponent } from './process-instance-tasks.componen
describe('ProcessInstanceTasksComponent', () => {
let componentHandler: any;
let component: ProcessInstanceTasksComponent;
let fixture: ComponentFixture<ProcessInstanceTasksComponent>;
let debugElement: DebugElement;
@@ -64,11 +63,6 @@ describe('ProcessInstanceTasksComponent', () => {
service = fixture.debugElement.injector.get(ProcessService);
getProcessTasksSpy = spyOn(service, 'getProcessTasks').and.returnValue(Observable.of([new TaskDetailsModel(taskDetailsMock)]));
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered',
'upgradeElement'
]);
window['componentHandler'] = componentHandler;
});
it('should initially render message about no active tasks if no process instance ID provided', async(() => {

View File

@@ -87,15 +87,15 @@ export class ProcessInstanceTasksComponent implements OnInit, OnChanges {
}
}
load(processId: string) {
this.loadActive(processId);
this.loadCompleted(processId);
load(processInstanceId: string) {
this.loadActive(processInstanceId);
this.loadCompleted(processInstanceId);
}
loadActive(processId: string) {
loadActive(processInstanceId: string) {
this.activeTasks = [];
if (processId) {
this.activitiProcess.getProcessTasks(processId, null).subscribe(
if (processInstanceId) {
this.activitiProcess.getProcessTasks(processInstanceId, null).subscribe(
(res: TaskDetailsModel[]) => {
res.forEach((task) => {
this.taskObserver.next(task);
@@ -110,10 +110,10 @@ export class ProcessInstanceTasksComponent implements OnInit, OnChanges {
}
}
loadCompleted(processId: string) {
loadCompleted(processInstanceId: string) {
this.completedTasks = [];
if (processId) {
this.activitiProcess.getProcessTasks(processId, 'completed').subscribe(
if (processInstanceId) {
this.activitiProcess.getProcessTasks(processInstanceId, 'completed').subscribe(
(res: TaskDetailsModel[]) => {
res.forEach((task) => {
this.completedTaskObserver.next(task);

View File

@@ -30,7 +30,6 @@ import { TranslationMock } from './../assets/translation.service.mock';
describe('ProcessInstanceListComponent', () => {
let componentHandler: any;
let fixture: ComponentFixture<ProcessInstanceListComponent>;
let component: ProcessInstanceListComponent;
let service: ProcessService;
@@ -55,11 +54,6 @@ describe('ProcessInstanceListComponent', () => {
getProcessInstancesSpy = spyOn(service, 'getProcessInstances').and.returnValue(Observable.of(fakeProcessInstances));
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered',
'upgradeElement'
]);
window['componentHandler'] = componentHandler;
});
}));
@@ -90,7 +84,7 @@ describe('ProcessInstanceListComponent', () => {
it('should emit onSuccess event when process instances loaded', fakeAsync(() => {
let emitSpy = spyOn(component.onSuccess, 'emit');
component.appId = '1';
component.appId = 1;
component.state = 'open';
component.processDefinitionKey = null;
fixture.detectChanges();
@@ -105,7 +99,7 @@ describe('ProcessInstanceListComponent', () => {
{type: 'text', key: 'fake-id', title: 'Name'}
]
);
component.appId = '1';
component.appId = 1;
component.state = 'open';
component.processDefinitionKey = null;
component.onSuccess.subscribe((res) => {
@@ -121,7 +115,7 @@ describe('ProcessInstanceListComponent', () => {
});
it('should order the process instances by name column when no sort passed', (done) => {
component.appId = '1';
component.appId = 1;
component.state = 'open';
component.processDefinitionKey = null;
component.onSuccess.subscribe((res) => {
@@ -137,7 +131,7 @@ describe('ProcessInstanceListComponent', () => {
});
it('should order the process instances by descending column when specified', (done) => {
component.appId = '1';
component.appId = 1;
component.state = 'open';
component.processDefinitionKey = null;
component.sort = 'name-desc';
@@ -154,7 +148,7 @@ describe('ProcessInstanceListComponent', () => {
});
it('should order the process instances by ascending column when specified', (done) => {
component.appId = '1';
component.appId = 1;
component.state = 'open';
component.processDefinitionKey = null;
component.sort = 'started-asc';
@@ -171,7 +165,7 @@ describe('ProcessInstanceListComponent', () => {
});
it('should order the process instances by descending start date when specified', (done) => {
component.appId = '1';
component.appId = 1;
component.state = 'open';
component.processDefinitionKey = null;
component.sort = 'started-desc';
@@ -189,7 +183,7 @@ describe('ProcessInstanceListComponent', () => {
it('should return a default name if no name is specified on the process', (done) => {
getProcessInstancesSpy = getProcessInstancesSpy.and.returnValue(Observable.of(fakeProcessInstancesWithNoName));
component.appId = '1';
component.appId = 1;
component.state = 'open';
component.processDefinitionKey = 'fakeprocess';
component.onSuccess.subscribe( (res) => {
@@ -209,7 +203,7 @@ describe('ProcessInstanceListComponent', () => {
let emitSpy: jasmine.Spy = spyOn(component.onError, 'emit');
let fakeError = 'Fake server error';
getProcessInstancesSpy.and.returnValue(Observable.throw(fakeError));
component.appId = '1';
component.appId = 1;
component.state = 'open';
fixture.detectChanges();
tick();
@@ -217,7 +211,7 @@ describe('ProcessInstanceListComponent', () => {
}));
it('should emit onSuccess event when reload() called', fakeAsync(() => {
component.appId = '1';
component.appId = 1;
component.state = 'open';
component.processDefinitionKey = null;
fixture.detectChanges();

View File

@@ -19,7 +19,7 @@ import { DatePipe } from '@angular/common';
import { AfterContentInit, Component, ContentChild, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
import { DataColumnListComponent } from 'ng2-alfresco-core';
import { DataColumn, DataRowEvent, DataSorting, DataTableAdapter, ObjectDataRow, ObjectDataTableAdapter } from 'ng2-alfresco-datatable';
import { ProcessFilterRequestRepresentation } from '../models/process-instance-filter.model';
import { ProcessFilterParamRepresentationModel } from '../models/filter-process.model';
import { ProcessInstance } from '../models/process-instance.model';
import { ProcessService } from '../services/process.service';
@@ -33,7 +33,7 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit
@ContentChild(DataColumnListComponent) columnList: DataColumnListComponent;
@Input()
appId: string;
appId: number;
@Input()
processDefinitionKey: string;
@@ -47,7 +47,7 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit
@Input()
name: string;
requestNode: ProcessFilterRequestRepresentation;
requestNode: ProcessFilterParamRepresentationModel;
@Input()
data: DataTableAdapter;
@@ -136,7 +136,7 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit
this.load(this.requestNode);
}
private load(requestNode: ProcessFilterRequestRepresentation) {
private load(requestNode: ProcessFilterParamRepresentationModel) {
this.isLoading = true;
this.processService.getProcessInstances(requestNode, this.processDefinitionKey)
.subscribe(
@@ -284,6 +284,6 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit
state: this.state,
sort: this.sort
};
return new ProcessFilterRequestRepresentation(requestNode);
return new ProcessFilterParamRepresentationModel(requestNode);
}
}

View File

@@ -27,7 +27,7 @@ import { ActivitiFormModule, FormService } from 'ng2-activiti-form';
import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx';
import { RestVariable } from 'alfresco-js-api';
import { ProcessInstanceVariable } from '../models/process-instance-variable.model';
import { ProcessService } from '../services/process.service';
import { newProcess, taskFormMock, testProcessDefRepr, testProcessDefs, testProcessDefWithForm } from './../assets/start-process.component.mock';
import { TranslationMock } from './../assets/translation.service.mock';
@@ -35,7 +35,6 @@ import { StartProcessInstanceComponent } from './start-process.component';
describe('StartProcessInstanceComponent', () => {
let componentHandler: any;
let component: StartProcessInstanceComponent;
let fixture: ComponentFixture<StartProcessInstanceComponent>;
let processService: ProcessService;
@@ -78,11 +77,6 @@ describe('StartProcessInstanceComponent', () => {
startProcessSpy = spyOn(processService, 'startProcess').and.returnValue(Observable.of(newProcess));
getStartFormDefinitionSpy = spyOn(formService, 'getStartFormDefinition').and.returnValue(Observable.of(taskFormMock));
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered',
'upgradeElement'
]);
window['componentHandler'] = componentHandler;
});
it('should create instance of StartProcessInstanceComponent', () => {
@@ -170,11 +164,11 @@ describe('StartProcessInstanceComponent', () => {
describe('input changes', () => {
let change = new SimpleChange('123', '456', true);
let nullChange = new SimpleChange('123', null, true);
let change = new SimpleChange(123, 456, true);
let nullChange = new SimpleChange(123, null, true);
beforeEach(async(() => {
component.appId = '123';
component.appId = 123;
fixture.detectChanges();
fixture.whenStable().then(() => {
fixture.detectChanges();
@@ -184,7 +178,7 @@ describe('StartProcessInstanceComponent', () => {
it('should reload processes when appId input changed', () => {
component.ngOnChanges({appId: change});
expect(getDefinitionsSpy).toHaveBeenCalledWith('456');
expect(getDefinitionsSpy).toHaveBeenCalledWith(456);
});
it('should reload processes when appId input changed to null', () => {
@@ -205,7 +199,7 @@ describe('StartProcessInstanceComponent', () => {
beforeEach(() => {
component.name = 'My new process';
let change = new SimpleChange(null, '123', true);
let change = new SimpleChange(null, 123, true);
component.ngOnChanges({'appId': change});
});
@@ -234,9 +228,9 @@ describe('StartProcessInstanceComponent', () => {
}));
it('should call service to start process with the variables setted', async(() => {
let inputProcessVariable: RestVariable[] = [];
let inputProcessVariable: ProcessInstanceVariable[] = [];
let variable: RestVariable = {};
let variable: ProcessInstanceVariable = {};
variable.name = 'nodeId';
variable.value = 'id';

View File

@@ -16,8 +16,8 @@
*/
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges, ViewChild, ViewEncapsulation } from '@angular/core';
import { RestVariable } from 'alfresco-js-api';
import { StartFormComponent } from 'ng2-activiti-form';
import { ProcessInstanceVariable } from '../models/process-instance-variable.model';
import { ProcessDefinitionRepresentation } from './../models/process-definition.model';
import { ProcessInstance } from './../models/process-instance.model';
import { ProcessService } from './../services/process.service';
@@ -31,10 +31,10 @@ import { ProcessService } from './../services/process.service';
export class StartProcessInstanceComponent implements OnChanges {
@Input()
appId: string;
appId: number;
@Input()
variables: RestVariable[];
variables: ProcessInstanceVariable[];
@Output()
start: EventEmitter<ProcessInstance> = new EventEmitter<ProcessInstance>();
@@ -65,7 +65,7 @@ export class StartProcessInstanceComponent implements OnChanges {
this.load(appId);
}
public load(appId?: string) {
public load(appId?: number) {
this.resetSelectedProcessDefinition();
this.resetErrorMessage();
this.activitiProcess.getProcessDefinitions(appId).subscribe(

View File

@@ -40,6 +40,8 @@
"TASK_CLOSE": "Close"
},
"COMMENTS": {
"ADD": "Add a comment",
"HEADER": "Comments ({{ count }})",
"NONE": "No comments",
"BUTTON": {
"ADD": "Add a comment"
@@ -71,7 +73,6 @@
"DESCRIPTION": "You might not have the required access level, check with your IT Team."
}
},
"START_PROCESS": {
"BUTTON": "Start Process",
"NO_PROCESS_DEFINITIONS": "You can't start a process as there are no process definitions available",

View File

@@ -15,23 +15,18 @@
* limitations under the License.
*/
/**
*
* This object represent the filter.
*
*
* @returns {FilterProcessRepresentationModel} .
*/
export class FilterProcessRepresentationModel {
id: string;
appId: string;
import { ProcessFilterRequestRepresentation, ProcessInstanceFilterRepresentation, UserProcessInstanceFilterRepresentation } from 'alfresco-js-api';
export class FilterProcessRepresentationModel implements UserProcessInstanceFilterRepresentation {
appId: number;
filter: ProcessInstanceFilterRepresentation;
icon: number;
id: number;
index: number;
name: string;
recent: boolean;
icon: string;
filter: ProcessFilterParamRepresentationModel;
index: number;
constructor(obj?: any) {
constructor(obj: any) {
if (obj) {
this.id = obj.id || null;
this.appId = obj.appId || null;
@@ -44,26 +39,7 @@ export class FilterProcessRepresentationModel {
}
hasFilter() {
return this.filter ? true : false;
}
}
/**
*
* This object represent the parameters to filter a filter.
*
*
* @returns {FilterParamsModel} .
*/
export class FilterParamsModel {
id: string;
name: string;
index: number;
constructor(obj?: any) {
this.id = obj.id || null;
this.name = obj.name || null;
this.index = obj.index;
return !!this.filter;
}
}
@@ -74,12 +50,21 @@ export class FilterParamsModel {
*
* @returns {ProcessFilterParamRepresentationModel} .
*/
export class ProcessFilterParamRepresentationModel {
state: string;
sort: string;
export class ProcessFilterParamRepresentationModel implements ProcessFilterRequestRepresentation {
processDefinitionId?: number;
appDefinitionId?: number;
state?: string;
sort?: string;
page?: number;
size?: number;
constructor(obj?: any) {
this.processDefinitionId = obj.processDefinitionId || null;
this.appDefinitionId = obj.appDefinitionId || null;
this.state = obj.state || null;
this.sort = obj.sort || null;
this.page = obj.page || null;
this.size = obj.size || null;
}
}

View File

@@ -15,14 +15,20 @@
* limitations under the License.
*/
export class ProcessInstanceVariable {
name: string;
scope: string;
value: any;
import { RestVariable } from 'alfresco-js-api';
export class ProcessInstanceVariable implements RestVariable {
name?: string;
scope?: string;
type?: string;
value?: string;
valueUrl?: string;
constructor(obj?: any) {
this.name = obj && obj.name !== undefined ? obj.name : null;
this.scope = obj && obj.scope !== undefined ? obj.scope : null;
this.value = obj && obj.value !== undefined ? obj.value : null;
this.valueUrl = obj && obj.valueUrl !== undefined ? obj.valueUrl : null;
}
}

View File

@@ -15,26 +15,27 @@
* limitations under the License.
*/
export class ProcessInstance {
import { LightUserRepresentation, ProcessInstanceRepresentation, RestVariable } from 'alfresco-js-api';
public businessKey: string;
public ended: any;
public graphicalNotationDefined: boolean;
public id: string;
public name: string;
public processDefinitionCategory: string;
public processDefinitionDeploymentId: string;
public processDefinitionDescription: string;
public processDefinitionId: string;
public processDefinitionKey: string;
public processDefinitionName: string;
public processDefinitionVersion: number;
public startFormDefined: boolean;
public started: string;
public startedBy: any;
public suspended: boolean;
public tenantId: string;
public variables: any;
export class ProcessInstance implements ProcessInstanceRepresentation {
businessKey?: string;
ended?: Date;
graphicalNotationDefined?: boolean;
id?: string;
name?: string;
processDefinitionCategory?: string;
processDefinitionDeploymentId?: string;
processDefinitionDescription?: string;
processDefinitionId?: string;
processDefinitionKey?: string;
processDefinitionName?: string;
processDefinitionVersion?: number;
startFormDefined?: boolean;
started?: Date;
startedBy?: LightUserRepresentation;
tenantId?: string;
variables?: RestVariable[];
constructor(data?: any) {
this.businessKey = data && data.businessKey !== undefined ? data.businessKey : null;
@@ -52,7 +53,6 @@ export class ProcessInstance {
this.startFormDefined = data && data.startFormDefined !== undefined ? data.startFormDefined : null;
this.started = data && data.started !== undefined ? data.started : null;
this.startedBy = data && data.startedBy !== undefined ? data.startedBy : null;
this.suspended = data && data.suspended !== undefined ? data.suspended : null;
this.tenantId = data && data.tenantId !== undefined ? data.tenantId : null;
this.variables = data && data.variables !== undefined ? data.variables : null;
}

View File

@@ -20,17 +20,8 @@ import { async } from '@angular/core/testing';
import { AlfrescoApi } from 'alfresco-js-api';
import { AlfrescoApiService, CoreModule } from 'ng2-alfresco-core';
import { exampleProcess, fakeProcessInstances } from '../assets/process.model.mock';
import {
fakeApp1,
fakeApp2,
fakeComment,
fakeError,
fakeFilters,
fakeProcessDef,
fakeTaskList
} from '../assets/process.service.mock';
import { FilterProcessRepresentationModel } from '../models/filter-process.model';
import { ProcessFilterRequestRepresentation } from '../models/process-instance-filter.model';
import { fakeError, fakeFilters, fakeProcessDef, fakeTaskList } from '../assets/process.service.mock';
import { FilterProcessRepresentationModel, ProcessFilterParamRepresentationModel } from '../models/filter-process.model';
import { ProcessInstanceVariable } from '../models/process-instance-variable.model';
import { ProcessService } from './process.service';
@@ -58,7 +49,7 @@ describe('ProcessService', () => {
let getProcessInstances: jasmine.Spy;
let filter: ProcessFilterRequestRepresentation = new ProcessFilterRequestRepresentation({
let filter: ProcessFilterParamRepresentationModel = new ProcessFilterParamRepresentationModel({
processDefinitionId: '1',
appDefinitionId: '1',
page: 1,
@@ -327,7 +318,7 @@ describe('ProcessService', () => {
});
it('should call API with correct parameters when appId provided', () => {
const appId = '1';
const appId = 1;
service.getProcessDefinitions(appId);
expect(getProcessDefinitions).toHaveBeenCalledWith({
latest: true,
@@ -426,167 +417,6 @@ describe('ProcessService', () => {
});
describe('comments', () => {
const processId = '1001';
describe('get comments', () => {
let getProcessInstanceComments: jasmine.Spy;
beforeEach(() => {
getProcessInstanceComments = spyOn(alfrescoApi.activiti.commentsApi, 'getProcessInstanceComments')
.and
.returnValue(Promise.resolve({ data: [ fakeComment, fakeComment ] }));
});
it('should return the correct number of comments', async(() => {
service.getComments(processId).subscribe((tasks) => {
expect(tasks.length).toBe(2);
});
}));
it('should return the correct comment data', async(() => {
service.getComments(processId).subscribe((comments) => {
let comment = comments[0];
expect(comment.id).toBe(fakeComment.id);
expect(comment.created).toBe(fakeComment.created);
expect(comment.message).toBe(fakeComment.message);
expect(comment.createdBy.id).toBe(fakeComment.createdBy.id);
});
}));
it('should call service to fetch process instance comments', () => {
service.getComments(processId);
expect(getProcessInstanceComments).toHaveBeenCalledWith(processId);
});
it('should pass on any error that is returned by the API', async(() => {
getProcessInstanceComments = getProcessInstanceComments.and.returnValue(Promise.reject(fakeError));
service.getComments(processId).subscribe(
() => {},
(res) => {
expect(res).toBe(fakeError);
}
);
}));
it('should return a default error if no data is returned by the API', async(() => {
getProcessInstanceComments = getProcessInstanceComments.and.returnValue(Promise.reject(null));
service.getComments(processId).subscribe(
() => {},
(res) => {
expect(res).toBe('Server error');
}
);
}));
});
describe('add comment', () => {
const message = 'Test message';
let addProcessInstanceComment: jasmine.Spy;
beforeEach(() => {
addProcessInstanceComment = spyOn(alfrescoApi.activiti.commentsApi, 'addProcessInstanceComment')
.and
.returnValue(Promise.resolve(fakeComment));
});
it('should call service to add comment', () => {
service.addComment(processId, message);
expect(addProcessInstanceComment).toHaveBeenCalledWith({
message: message
}, processId);
});
it('should return the created comment', async(() => {
service.addComment(processId, message).subscribe((comment) => {
expect(comment.id).toBe(fakeComment.id);
expect(comment.created).toBe(fakeComment.created);
expect(comment.message).toBe(fakeComment.message);
expect(comment.createdBy).toBe(fakeComment.createdBy);
});
}));
it('should pass on any error that is returned by the API', async(() => {
addProcessInstanceComment = addProcessInstanceComment.and.returnValue(Promise.reject(fakeError));
service.addComment(processId, message).subscribe(
() => {},
(res) => {
expect(res).toBe(fakeError);
}
);
}));
it('should return a default error if no data is returned by the API', async(() => {
addProcessInstanceComment = addProcessInstanceComment.and.returnValue(Promise.reject(null));
service.addComment(processId, message).subscribe(
() => {},
(res) => {
expect(res).toBe('Server error');
}
);
}));
});
});
describe('deployed apps', () => {
let getAppDefinitions: jasmine.Spy;
beforeEach(() => {
getAppDefinitions = spyOn(alfrescoApi.activiti.appsApi, 'getAppDefinitions')
.and
.returnValue(Promise.resolve({ data: [ fakeApp1, fakeApp2 ] }));
});
it('should return the correct app', async(() => {
service.getDeployedApplications(fakeApp1.name).subscribe((app) => {
expect(app.id).toBe(fakeApp1.id);
expect(app.name).toBe(fakeApp1.name);
expect(app.deploymentId).toBe(fakeApp1.deploymentId);
});
}));
it('should call service to fetch apps', () => {
service.getDeployedApplications(null);
expect(getAppDefinitions).toHaveBeenCalled();
});
it('should pass on any error that is returned by the API', async(() => {
getAppDefinitions = getAppDefinitions.and.returnValue(Promise.reject(fakeError));
service.getDeployedApplications(null).subscribe(
() => {},
(res) => {
expect(res).toBe(fakeError);
}
);
}));
it('should return a default error if no data is returned by the API', async(() => {
getAppDefinitions = getAppDefinitions.and.returnValue(Promise.reject(null));
service.getDeployedApplications(null).subscribe(
() => {},
(res) => {
expect(res).toBe('Server error');
}
);
}));
it('should return the correct app by id', async(() => {
service.getApplicationDetailsById(fakeApp1.id).subscribe((app) => {
expect(app.id).toBe(fakeApp1.id);
expect(app.name).toBe(fakeApp1.name);
expect(app.deploymentId).toBe(fakeApp1.deploymentId);
});
}));
});
describe('filters', () => {
let getFilters: jasmine.Spy;
@@ -610,8 +440,8 @@ describe('ProcessService', () => {
});
it('should call the API with the correct appId when specified', () => {
service.getProcessFilters('226');
expect(getFilters).toHaveBeenCalledWith({appId: '226'});
service.getProcessFilters(226);
expect(getFilters).toHaveBeenCalledWith({appId: 226});
});
it('should return the task filter by id', (done) => {
@@ -649,7 +479,7 @@ describe('ProcessService', () => {
}));
it('should return the default filters', (done) => {
service.createDefaultFilters('1234').subscribe(
service.createDefaultFilters(1234).subscribe(
(res: FilterProcessRepresentationModel []) => {
expect(res).toBeDefined();
expect(res.length).toEqual(3);

View File

@@ -16,30 +16,25 @@
*/
import { Injectable } from '@angular/core';
import { RestVariable } from 'alfresco-js-api';
import {
Comment,
TaskDetailsModel,
TaskListService } from 'ng2-activiti-tasklist';
import { AlfrescoApiService, LightUserRepresentation, LogService } from 'ng2-alfresco-core';
import { TaskDetailsModel } from 'ng2-activiti-tasklist';
import { AlfrescoApiService, LogService } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Observable';
import { ProcessFilterParamRepresentationModel } from '../models/filter-process.model';
import { FilterProcessRepresentationModel } from '../models/filter-process.model';
import { ProcessDefinitionRepresentation } from '../models/process-definition.model';
import { ProcessFilterRequestRepresentation } from '../models/process-instance-filter.model';
import { ProcessInstanceVariable } from '../models/process-instance-variable.model';
import { ProcessInstance } from '../models/process-instance.model';
import { ProcessInstanceVariable } from './../models/process-instance-variable.model';
declare let moment: any;
@Injectable()
export class ProcessService extends TaskListService {
export class ProcessService {
constructor(private alfrescoApiService: AlfrescoApiService,
private processLogService: LogService) {
super(alfrescoApiService, processLogService);
}
getProcessInstances(requestNode: ProcessFilterRequestRepresentation, processDefinitionKey?: string): Observable<ProcessInstance[]> {
getProcessInstances(requestNode: ProcessFilterParamRepresentationModel, processDefinitionKey?: string): Observable<ProcessInstance[]> {
return Observable.fromPromise(this.alfrescoApiService.getInstance().activiti.processApi.getProcessInstances(requestNode))
.map((res: any) => {
if (processDefinitionKey) {
@@ -50,7 +45,7 @@ export class ProcessService extends TaskListService {
}).catch(err => this.handleProcessError(err));
}
getProcessFilters(appId: string): Observable<FilterProcessRepresentationModel[]> {
getProcessFilters(appId: number): Observable<FilterProcessRepresentationModel[]> {
return Observable.fromPromise(this.callApiProcessFilters(appId))
.map((response: any) => {
let filters: FilterProcessRepresentationModel[] = [];
@@ -69,7 +64,7 @@ export class ProcessService extends TaskListService {
* @param appId - string - optional - The id of app
* @returns {Observable<FilterProcessRepresentationModel>}
*/
getProcessFilterById(filterId: number, appId?: string): Observable<FilterProcessRepresentationModel> {
getProcessFilterById(filterId: number, appId?: number): Observable<FilterProcessRepresentationModel> {
return Observable.fromPromise(this.callApiProcessFilters(appId))
.map((response: any) => {
return response.data.find(filter => filter.id === filterId);
@@ -82,7 +77,7 @@ export class ProcessService extends TaskListService {
* @param appId - string - optional - The id of app
* @returns {Observable<FilterProcessRepresentationModel>}
*/
getProcessFilterByName(filterName: string, appId?: string): Observable<FilterProcessRepresentationModel> {
getProcessFilterByName(filterName: string, appId?: number): Observable<FilterProcessRepresentationModel> {
return Observable.fromPromise(this.callApiProcessFilters(appId))
.map((response: any) => {
return response.data.find(filter => filter.name === filterName);
@@ -112,7 +107,7 @@ export class ProcessService extends TaskListService {
* @param appId
* @returns {FilterProcessRepresentationModel[]}
*/
public createDefaultFilters(appId: string): Observable<any[]> {
public createDefaultFilters(appId: number): Observable<any[]> {
let runnintFilter = this.getRunningFilterInstance(appId);
let runnintObservable = this.addProcessFilter(runnintFilter);
@@ -148,7 +143,7 @@ export class ProcessService extends TaskListService {
});
}
public getRunningFilterInstance(appId: string): FilterProcessRepresentationModel {
public getRunningFilterInstance(appId: number): FilterProcessRepresentationModel {
return new FilterProcessRepresentationModel({
'name': 'Running',
'appId': appId,
@@ -163,7 +158,7 @@ export class ProcessService extends TaskListService {
* @param appId
* @returns {FilterProcessRepresentationModel}
*/
private getCompletedFilterInstance(appId: string): FilterProcessRepresentationModel {
private getCompletedFilterInstance(appId: number): FilterProcessRepresentationModel {
return new FilterProcessRepresentationModel({
'name': 'Completed',
'appId': appId,
@@ -178,7 +173,7 @@ export class ProcessService extends TaskListService {
* @param appId
* @returns {FilterProcessRepresentationModel}
*/
private getAllFilterInstance(appId: string): FilterProcessRepresentationModel {
private getAllFilterInstance(appId: number): FilterProcessRepresentationModel {
return new FilterProcessRepresentationModel({
'name': 'All',
'appId': appId,
@@ -194,24 +189,24 @@ export class ProcessService extends TaskListService {
* @returns {FilterProcessRepresentationModel}
*/
addProcessFilter(filter: FilterProcessRepresentationModel): Observable<FilterProcessRepresentationModel> {
return Observable.fromPromise(this.callApiAddProccessFilter(filter))
return Observable.fromPromise(this.callApiAddProcessFilter(filter))
.map(res => res)
.map((response: FilterProcessRepresentationModel) => {
return response;
}).catch(err => this.handleProcessError(err));
}
getProcess(id: string): Observable<ProcessInstance> {
return Observable.fromPromise(this.alfrescoApiService.getInstance().activiti.processApi.getProcessInstance(id))
getProcess(processInstanceId: string): Observable<ProcessInstance> {
return Observable.fromPromise(this.alfrescoApiService.getInstance().activiti.processApi.getProcessInstance(processInstanceId))
.catch(err => this.handleProcessError(err));
}
getProcessTasks(id: string, state?: string): Observable<TaskDetailsModel[]> {
getProcessTasks(processInstanceId: string, state?: string): Observable<TaskDetailsModel[]> {
let taskOpts = state ? {
processInstanceId: id,
processInstanceId: processInstanceId,
state: state
} : {
processInstanceId: id
processInstanceId: processInstanceId
};
return Observable.fromPromise(this.alfrescoApiService.getInstance().activiti.taskApi.listTasks(taskOpts))
.map(this.extractData)
@@ -222,41 +217,7 @@ export class ProcessService extends TaskListService {
.catch(err => this.handleProcessError(err));
}
/**
* Retrive all the process instance's comments
* @param id - process instance ID
* @returns {<Comment[]>}
*/
getComments(id: string): Observable<Comment[]> {
return Observable.fromPromise(this.alfrescoApiService.getInstance().activiti.commentsApi.getProcessInstanceComments(id))
.map(res => res)
.map((response: any) => {
let comments: Comment[] = [];
response.data.forEach((comment) => {
let user = new LightUserRepresentation(comment.createdBy);
comments.push(new Comment(comment.id, comment.message, comment.created, user));
});
return comments;
}).catch(err => this.handleProcessError(err));
}
/**
* Add a comment to a process instance
* @param id - process instance Id
* @param message - content of the comment
* @returns {Comment}
*/
addComment(id: string, message: string): Observable<Comment> {
return Observable.fromPromise(
this.alfrescoApiService.getInstance().activiti.commentsApi.addProcessInstanceComment({ message: message }, id)
)
.map((response: Comment) => {
return new Comment(response.id, response.message, response.created, response.createdBy);
}).catch(err => this.handleProcessError(err));
}
getProcessDefinitions(appId?: string): Observable<ProcessDefinitionRepresentation[]> {
getProcessDefinitions(appId?: number): Observable<ProcessDefinitionRepresentation[]> {
let opts = appId ? {
latest: true,
appDefinitionId: appId
@@ -271,7 +232,7 @@ export class ProcessService extends TaskListService {
.catch(err => this.handleProcessError(err));
}
startProcess(processDefinitionId: string, name: string, outcome?: string, startFormValues?: any, variables?: RestVariable[]): Observable<ProcessInstance> {
startProcess(processDefinitionId: string, name: string, outcome?: string, startFormValues?: any, variables?: ProcessInstanceVariable[]): Observable<ProcessInstance> {
let startRequest: any = {
name: name,
processDefinitionId: processDefinitionId
@@ -321,11 +282,11 @@ export class ProcessService extends TaskListService {
.catch(err => this.handleProcessError(err));
}
private callApiAddProccessFilter(filter: FilterProcessRepresentationModel) {
private callApiAddProcessFilter(filter: FilterProcessRepresentationModel) {
return this.alfrescoApiService.getInstance().activiti.userFiltersApi.createUserProcessInstanceFilter(filter);
}
callApiProcessFilters(appId?: string) {
callApiProcessFilters(appId?: number) {
if (appId) {
return this.alfrescoApiService.getInstance().activiti.userFiltersApi.getUserProcessInstanceFilters({ appId: appId });
} else {

View File

@@ -93,7 +93,6 @@ export {TaskHeaderComponent as ActivitiTaskHeader} from './src/components/task-h
export {TaskListComponent as ActivitiTaskList } from './src/components/tasklist.component';
export {TaskListService as ActivitiTaskListService } from './src/services/tasklist.service';
export * from './src/models/comment.model';
export * from './src/models/filter.model';
export * from './src/models/icon.model';
export * from './src/models/task-details.model';

View File

@@ -18,21 +18,19 @@
import { DebugElement } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { CoreModule, TranslationService } from 'ng2-alfresco-core';
import { AppsProcessService, CoreModule, TranslationService } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx';
import { TranslationMock } from '../assets/translation.service.mock';
import { defaultApp, deployedApps, nonDeployedApps } from './../assets/apps-list.mock';
import { TaskListService } from './../services/tasklist.service';
import { AppsListComponent } from './apps-list.component';
describe('AppsListComponent', () => {
let componentHandler: any;
let component: AppsListComponent;
let fixture: ComponentFixture<AppsListComponent>;
let debugElement: DebugElement;
let service: TaskListService;
let service: AppsProcessService;
let getAppsSpy: jasmine.Spy;
beforeEach(async(() => {
@@ -44,7 +42,7 @@ describe('AppsListComponent', () => {
AppsListComponent
],
providers: [
TaskListService,
AppsProcessService,
{ provide: TranslationService, useClass: TranslationMock }
]
}).compileComponents();
@@ -52,19 +50,12 @@ describe('AppsListComponent', () => {
}));
beforeEach(() => {
fixture = TestBed.createComponent(AppsListComponent);
component = fixture.componentInstance;
debugElement = fixture.debugElement;
service = fixture.debugElement.injector.get(TaskListService);
service = fixture.debugElement.injector.get(AppsProcessService);
getAppsSpy = spyOn(service, 'getDeployedApplications').and.returnValue(Observable.of(deployedApps));
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered',
'upgradeElement'
]);
window['componentHandler'] = componentHandler;
});
it('should define layoutType with the default value', () => {

View File

@@ -16,6 +16,7 @@
*/
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { AppsProcessService } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Observable';
import { Observer } from 'rxjs/Observer';
import { AppDefinitionRepresentationModel } from '../models/filter.model';
@@ -59,13 +60,8 @@ export class AppsListComponent implements OnInit {
private iconsMDL: IconModel;
/**
* Constructor
* @param translate Translate service
* @param activitiTaskList Task service
*/
constructor(private activitiTaskList: TaskListService) {
this.apps$ = new Observable<AppDefinitionRepresentationModel>(observer => this.appsObserver = observer).share();
constructor(private appsProcessService: AppsProcessService) {
this.apps$ = new Observable<AppDefinitionRepresentationModel>(observer => this.appsObserver = observer).share();
}
ngOnInit() {
@@ -81,10 +77,9 @@ export class AppsListComponent implements OnInit {
}
private load() {
this.activitiTaskList.getDeployedApplications().subscribe(
(res) => {
res = this.filterApps(res);
res.forEach((app: AppDefinitionRepresentationModel) => {
this.appsProcessService.getDeployedApplications().subscribe(
(res: AppDefinitionRepresentationModel[]) => {
this.filterApps(res).forEach((app: AppDefinitionRepresentationModel) => {
if (app.defaultAppId === AppsListComponent.DEFAULT_TASKS_APP) {
app.name = AppsListComponent.DEFAULT_TASKS_APP_NAME;
app.theme = AppsListComponent.DEFAULT_TASKS_APP_THEME;
@@ -120,7 +115,7 @@ export class AppsListComponent implements OnInit {
}
private filterApps(apps: AppDefinitionRepresentationModel []): AppDefinitionRepresentationModel[] {
let filteredApps = [];
let filteredApps: AppDefinitionRepresentationModel[] = [];
if (this.filtersAppId) {
apps.filter((app: AppDefinitionRepresentationModel) => {
this.filtersAppId.forEach((filter) => {

View File

@@ -17,31 +17,26 @@
import { DatePipe } from '@angular/common';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AppConfigService, CoreModule, TranslationService } from 'ng2-alfresco-core';
import { LightUserRepresentation } from 'ng2-alfresco-core';
import { AppConfigService, CommentProcessModel, CoreModule, TranslationService, UserProcessModel } from 'ng2-alfresco-core';
import { DataRowEvent, DataTableModule, ObjectDataRow } from 'ng2-alfresco-datatable';
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
import { TranslationMock } from '../assets/translation.service.mock';
import { Comment } from '../models/comment.model';
import { CommentListComponent } from './comment-list.component';
declare let jasmine: any;
const testUser: LightUserRepresentation = new LightUserRepresentation({
const testUser: UserProcessModel = new UserProcessModel({
id: '1',
firstName: 'Test',
lastName: 'User',
email: 'tu@domain.com'
});
const testDate = new Date();
const testComment: Comment = new Comment(1, 'Test Comment', testDate.toDateString(), testUser);
const testComment: CommentProcessModel = new CommentProcessModel({id: 1, message: 'Test Comment', created: testDate.toDateString(), createdBy: testUser});
describe('CommentListComponent', () => {
let commentList: CommentListComponent;
let fixture: ComponentFixture<CommentListComponent>;
let element: HTMLElement;
let componentHandler;
beforeEach(async(() => {
TestBed.configureTestingModule({
@@ -62,11 +57,6 @@ describe('CommentListComponent', () => {
fixture = TestBed.createComponent(CommentListComponent);
commentList = fixture.componentInstance;
element = fixture.nativeElement;
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered'
]);
window['componentHandler'] = componentHandler;
fixture.detectChanges();
});
}));
@@ -126,7 +116,7 @@ describe('CommentListComponent', () => {
});
it('comment date time should start with Yesterday when comment date is yesterday', () => {
testComment.created = (Date.now() - 24 * 3600 * 1000).toString();
testComment.created = new Date((Date.now() - 24 * 3600 * 1000));
commentList.comments = [testComment];
fixture.detectChanges();
element = fixture.nativeElement.querySelector('#comment-time');
@@ -134,7 +124,7 @@ describe('CommentListComponent', () => {
});
it('comment date time should not start with Today/Yesterday when comment date is before yesterday', () => {
testComment.created = (Date.now() - 24 * 3600 * 1000 * 2).toString();
testComment.created = new Date((Date.now() - 24 * 3600 * 1000 * 2));
commentList.comments = [testComment];
fixture.detectChanges();
element = fixture.nativeElement.querySelector('#comment-time');

View File

@@ -17,8 +17,7 @@
import { DatePipe } from '@angular/common';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { LightUserRepresentation, PeopleProcessService } from 'ng2-alfresco-core';
import { Comment } from '../models/comment.model';
import { CommentProcessModel, PeopleProcessService, UserProcessModel } from 'ng2-alfresco-core';
@Component({
selector: 'adf-comment-list',
@@ -29,12 +28,12 @@ import { Comment } from '../models/comment.model';
export class CommentListComponent {
@Input()
comments: Comment[];
comments: CommentProcessModel[];
@Output()
clickRow: EventEmitter<Comment> = new EventEmitter<Comment>();
clickRow: EventEmitter<CommentProcessModel> = new EventEmitter<CommentProcessModel>();
selectedComment: Comment;
selectedComment: CommentProcessModel;
constructor(private datePipe: DatePipe, public peopleProcessService: PeopleProcessService) {
}
@@ -44,7 +43,7 @@ export class CommentListComponent {
this.clickRow.emit(this.selectedComment);
}
getUserShortName(user: LightUserRepresentation): string {
getUserShortName(user: UserProcessModel): string {
let shortName = '';
if (user) {
if (user.firstName) {

View File

@@ -20,7 +20,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs/Rx';
import { ActivitiFormModule } from 'ng2-activiti-form';
import { AppConfigService, CoreModule, TranslationService } from 'ng2-alfresco-core';
import { AppConfigService, CommentProcessService, CoreModule, TranslationService } from 'ng2-alfresco-core';
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
import { TranslationMock } from '../assets/translation.service.mock';
@@ -34,12 +34,12 @@ import { CommentsComponent } from './comments.component';
describe('CommentsComponent', () => {
let componentHandler: any;
let service: TaskListService;
let component: CommentsComponent;
let fixture: ComponentFixture<CommentsComponent>;
let getCommentsSpy: jasmine.Spy;
let addCommentSpy: jasmine.Spy;
let commentProcessService: CommentProcessService;
beforeEach(async(() => {
TestBed.configureTestingModule({
@@ -58,7 +58,8 @@ describe('CommentsComponent', () => {
DatePipe,
PeopleProcessService,
{ provide: TranslationService, useClass: TranslationMock },
{ provide: AppConfigService, useClass: AppConfigServiceMock }
{ provide: AppConfigService, useClass: AppConfigServiceMock },
CommentProcessService
]
}).compileComponents();
@@ -68,19 +69,15 @@ describe('CommentsComponent', () => {
fixture = TestBed.createComponent(CommentsComponent);
component = fixture.componentInstance;
service = fixture.debugElement.injector.get(TaskListService);
commentProcessService = fixture.debugElement.injector.get(CommentProcessService);
getCommentsSpy = spyOn(service, 'getComments').and.returnValue(Observable.of([
getCommentsSpy = spyOn(commentProcessService, 'getTaskComments').and.returnValue(Observable.of([
{ message: 'Test1', created: Date.now(), createdBy: {firstName: 'Admin', lastName: 'User'} },
{ message: 'Test2', created: Date.now(), createdBy: {firstName: 'Admin', lastName: 'User'} },
{ message: 'Test3', created: Date.now(), createdBy: {firstName: 'Admin', lastName: 'User'} }
]));
addCommentSpy = spyOn(service, 'addComment').and.returnValue(Observable.of({id: 123, message: 'Test Comment', createdBy: {id: '999'}}));
addCommentSpy = spyOn(commentProcessService, 'addTaskComment').and.returnValue(Observable.of({id: 123, message: 'Test Comment', createdBy: {id: '999'}}));
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered',
'upgradeElement'
]);
window['componentHandler'] = componentHandler;
});
it('should load comments when taskId specified', () => {

View File

@@ -16,11 +16,9 @@
*/
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
import { CommentProcessModel, CommentProcessService } from 'ng2-alfresco-core';
import { Observable, Observer } from 'rxjs/Rx';
import { Comment } from '../models/comment.model';
import { TaskListService } from '../services/tasklist.service';
@Component({
selector: 'adf-comments, activiti-comments',
templateUrl: './comments.component.html',
@@ -37,23 +35,18 @@ export class CommentsComponent implements OnChanges {
@Output()
error: EventEmitter<any> = new EventEmitter<any>();
comments: Comment [] = [];
comments: CommentProcessModel [] = [];
private commentObserver: Observer<Comment>;
comment$: Observable<Comment>;
private commentObserver: Observer<CommentProcessModel>;
comment$: Observable<CommentProcessModel>;
message: string;
beingAdded: boolean = false;
/**
* Constructor
* @param translate Translation service
* @param activitiTaskList Task service
*/
constructor(private activitiTaskList: TaskListService) {
this.comment$ = new Observable<Comment>(observer => this.commentObserver = observer).share();
this.comment$.subscribe((comment: Comment) => {
constructor(private commentProcessService: CommentProcessService) {
this.comment$ = new Observable<CommentProcessModel>(observer => this.commentObserver = observer).share();
this.comment$.subscribe((comment: CommentProcessModel) => {
this.comments.push(comment);
});
}
@@ -72,9 +65,9 @@ export class CommentsComponent implements OnChanges {
private getTaskComments(taskId: string): void {
this.resetComments();
if (taskId) {
this.activitiTaskList.getComments(taskId).subscribe(
(res: Comment[]) => {
res = res.sort((comment1: Comment, comment2: Comment) => {
this.commentProcessService.getTaskComments(taskId).subscribe(
(res: CommentProcessModel[]) => {
res = res.sort((comment1: CommentProcessModel, comment2: CommentProcessModel) => {
let date1 = new Date(comment1.created);
let date2 = new Date(comment2.created);
return date1 > date2 ? -1 : date1 < date2 ? 1 : 0;
@@ -97,9 +90,9 @@ export class CommentsComponent implements OnChanges {
add(): void {
if (this.message && this.message.trim() && !this.beingAdded) {
this.beingAdded = true;
this.activitiTaskList.addComment(this.taskId, this.message)
this.commentProcessService.addTaskComment(this.taskId, this.message)
.subscribe(
(res: Comment) => {
(res: CommentProcessModel) => {
this.comments.unshift(res);
this.message = '';
this.beingAdded = false;

View File

@@ -27,7 +27,6 @@ import { AttachmentComponent } from './create-task-attachment.component';
describe('Activiti Task Create Attachment', () => {
let componentHandler: any;
let service: ActivitiContentService;
let component: AttachmentComponent;
let fixture: ComponentFixture<AttachmentComponent>;
@@ -59,12 +58,6 @@ describe('Activiti Task Create Attachment', () => {
{
status: true
}));
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered',
'upgradeElement'
]);
window['componentHandler'] = componentHandler;
});
it('should not call createTaskRelatedContent service when taskId changed', () => {

View File

@@ -16,17 +16,14 @@
*/
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AppConfigService, CoreModule, TranslationService } from 'ng2-alfresco-core';
import { LightUserRepresentation } from 'ng2-alfresco-core';
import { AppConfigService, CoreModule, TranslationService, UserProcessModel } from 'ng2-alfresco-core';
import { DataRowActionEvent, DataRowEvent, DataTableModule, ObjectDataRow } from 'ng2-alfresco-datatable';
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
import { TranslationMock } from '../assets/translation.service.mock';
import { UserEventModel } from '../models/user-event.model';
import { PeopleListComponent } from './people-list.component';
declare let jasmine: any;
const fakeUser: LightUserRepresentation = new LightUserRepresentation({
const fakeUser: UserProcessModel = new UserProcessModel({
id: '1',
firstName: 'fake-name',
lastName: 'fake-last',
@@ -38,7 +35,6 @@ describe('PeopleListComponent', () => {
let peopleListComponent: PeopleListComponent;
let fixture: ComponentFixture<PeopleListComponent>;
let element: HTMLElement;
let componentHandler;
beforeEach(async(() => {
TestBed.configureTestingModule({
@@ -58,11 +54,6 @@ describe('PeopleListComponent', () => {
fixture = TestBed.createComponent(PeopleListComponent);
peopleListComponent = fixture.componentInstance;
element = fixture.nativeElement;
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered'
]);
window['componentHandler'] = componentHandler;
fixture.detectChanges();
});
}));

View File

@@ -16,13 +16,10 @@
*/
import { AfterContentInit, AfterViewInit, Component, ContentChild, EventEmitter, Input, Output, ViewChild } from '@angular/core';
import { DataColumnListComponent } from 'ng2-alfresco-core';
import { LightUserRepresentation } from 'ng2-alfresco-core';
import { DataColumnListComponent, UserProcessModel } from 'ng2-alfresco-core';
import { DataTableComponent } from 'ng2-alfresco-datatable';
import { UserEventModel } from '../models/user-event.model';
declare let componentHandler: any;
@Component({
selector: 'adf-people-list',
templateUrl: './people-list.component.html',
@@ -37,35 +34,24 @@ export class PeopleListComponent implements AfterViewInit, AfterContentInit {
peopleDataTable: DataTableComponent;
@Input()
users: LightUserRepresentation[];
users: UserProcessModel[];
@Input()
actions: boolean = false;
@Output()
clickRow: EventEmitter<LightUserRepresentation> = new EventEmitter<LightUserRepresentation>();
clickRow: EventEmitter<UserProcessModel> = new EventEmitter<UserProcessModel>();
@Output()
clickAction: EventEmitter<UserEventModel> = new EventEmitter<UserEventModel>();
user: LightUserRepresentation;
user: UserProcessModel;
ngAfterContentInit() {
this.peopleDataTable.columnList = this.columnList;
}
ngAfterViewInit() {
this.setupMaterialComponents(componentHandler);
}
setupMaterialComponents(handler?: any): boolean {
// workaround for MDL issues with dynamic components
let isUpgraded: boolean = false;
if (handler) {
handler.upgradeAllRegistered();
isUpgraded = true;
}
return isUpgraded;
}
selectUser(event: any) {

View File

@@ -17,8 +17,7 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MatButtonModule, MatInputModule } from '@angular/material';
import { AppConfigService, CoreModule, TranslationService } from 'ng2-alfresco-core';
import { LightUserRepresentation } from 'ng2-alfresco-core';
import { AppConfigService, CoreModule, TranslationService, UserProcessModel } from 'ng2-alfresco-core';
import { DataTableModule } from 'ng2-alfresco-datatable';
import { Observable } from 'rxjs/Observable';
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
@@ -26,16 +25,14 @@ import { TranslationMock } from '../assets/translation.service.mock';
import { PeopleListComponent } from './people-list.component';
import { PeopleSearchComponent } from './people-search.component';
declare let jasmine: any;
const fakeUser: LightUserRepresentation = new LightUserRepresentation({
const fakeUser: UserProcessModel = new UserProcessModel({
id: '1',
firstName: 'fake-name',
lastName: 'fake-last',
email: 'fake@mail.com'
});
const fakeSecondUser: LightUserRepresentation = new LightUserRepresentation({
const fakeSecondUser: UserProcessModel = new UserProcessModel({
id: '2',
firstName: 'fake-involve-name',
lastName: 'fake-involve-last',
@@ -47,7 +44,6 @@ describe('PeopleSearchComponent', () => {
let peopleSearchComponent: PeopleSearchComponent;
let fixture: ComponentFixture<PeopleSearchComponent>;
let element: HTMLElement;
let componentHandler;
let userArray = [fakeUser, fakeSecondUser];
let searchInput: any;
@@ -72,11 +68,6 @@ describe('PeopleSearchComponent', () => {
fixture = TestBed.createComponent(PeopleSearchComponent);
peopleSearchComponent = fixture.componentInstance;
element = fixture.nativeElement;
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered'
]);
window['componentHandler'] = componentHandler;
peopleSearchComponent.results = Observable.of([]);
fixture.detectChanges();
});

View File

@@ -17,8 +17,7 @@
import { Component, Directive, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from '@angular/core';
import { FormControl } from '@angular/forms';
import { LightUserRepresentation } from 'ng2-alfresco-core';
import { PeopleProcessService } from 'ng2-alfresco-core';
import { PeopleProcessService, UserProcessModel } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Observable';
@Component({
@@ -34,22 +33,22 @@ import { Observable } from 'rxjs/Observable';
export class PeopleSearchComponent implements OnInit {
@Input()
results: Observable<LightUserRepresentation[]>;
results: Observable<UserProcessModel[]>;
@Output()
searchPeople: EventEmitter<any> = new EventEmitter();
@Output()
success: EventEmitter<LightUserRepresentation> = new EventEmitter<LightUserRepresentation>();
success: EventEmitter<UserProcessModel> = new EventEmitter<UserProcessModel>();
@Output()
closeSearch = new EventEmitter();
searchUser: FormControl = new FormControl();
users: LightUserRepresentation[] = [];
users: UserProcessModel[] = [];
selectedUser: LightUserRepresentation;
selectedUser: UserProcessModel;
constructor(public peopleProcessService: PeopleProcessService) {
this.searchUser
@@ -70,7 +69,7 @@ export class PeopleSearchComponent implements OnInit {
});
}
onRowClick(user: LightUserRepresentation) {
onRowClick(user: UserProcessModel) {
this.selectedUser = user;
}

View File

@@ -19,8 +19,7 @@ import { NO_ERRORS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MatButtonModule, MatInputModule } from '@angular/material';
import { AppConfigService, CoreModule, LogService, TranslationService } from 'ng2-alfresco-core';
import { LightUserRepresentation } from 'ng2-alfresco-core';
import { PeopleProcessService } from 'ng2-alfresco-core';
import { PeopleProcessService, UserProcessModel } from 'ng2-alfresco-core';
import { DataTableModule } from 'ng2-alfresco-datatable';
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
import { TranslationMock } from '../assets/translation.service.mock';
@@ -30,14 +29,14 @@ import { PeopleComponent } from './people.component';
declare let jasmine: any;
const fakeUser: LightUserRepresentation = new LightUserRepresentation({
const fakeUser: UserProcessModel = new UserProcessModel({
id: 'fake-id',
firstName: 'fake-name',
lastName: 'fake-last',
email: 'fake@mail.com'
});
const fakeSecondUser: LightUserRepresentation = new LightUserRepresentation({
const fakeSecondUser: UserProcessModel = new UserProcessModel({
id: 'fake-involve-id',
firstName: 'fake-involve-name',
lastName: 'fake-involve-last',
@@ -49,7 +48,6 @@ describe('PeopleComponent', () => {
let activitiPeopleComponent: PeopleComponent;
let fixture: ComponentFixture<PeopleComponent>;
let element: HTMLElement;
let componentHandler;
let userArray = [fakeUser, fakeSecondUser];
let logService: LogService;
@@ -78,11 +76,6 @@ describe('PeopleComponent', () => {
fixture = TestBed.createComponent(PeopleComponent);
activitiPeopleComponent = fixture.componentInstance;
element = fixture.nativeElement;
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered'
]);
window['componentHandler'] = componentHandler;
activitiPeopleComponent.people = [];
activitiPeopleComponent.readOnly = true;

View File

@@ -16,13 +16,12 @@
*/
import { AfterViewInit, Component, Input, OnInit, ViewChild } from '@angular/core';
import { LogService } from 'ng2-alfresco-core';
import { LightUserRepresentation, PeopleProcessService } from 'ng2-alfresco-core';
import { LogService, UserProcessModel } from 'ng2-alfresco-core';
import { PeopleProcessService } from 'ng2-alfresco-core';
import { Observable, Observer } from 'rxjs/Rx';
import { UserEventModel } from '../models/user-event.model';
import { PeopleSearchComponent } from './people-search.component';
declare let componentHandler: any;
declare var require: any;
@Component({
@@ -36,7 +35,7 @@ export class PeopleComponent implements OnInit, AfterViewInit {
iconImageUrl: string = require('../assets/images/user.jpg');
@Input()
people: LightUserRepresentation[] = [];
people: UserProcessModel[] = [];
@Input()
taskId: string = '';
@@ -49,28 +48,17 @@ export class PeopleComponent implements OnInit, AfterViewInit {
showAssignment: boolean = false;
private peopleSearchObserver: Observer<LightUserRepresentation[]>;
peopleSearch$: Observable<LightUserRepresentation[]>;
private peopleSearchObserver: Observer<UserProcessModel[]>;
peopleSearch$: Observable<UserProcessModel[]>;
constructor(private logService: LogService, public peopleProcessService: PeopleProcessService) {
this.peopleSearch$ = new Observable<LightUserRepresentation[]>(observer => this.peopleSearchObserver = observer).share();
this.peopleSearch$ = new Observable<UserProcessModel[]>(observer => this.peopleSearchObserver = observer).share();
}
ngOnInit() {
}
ngAfterViewInit() {
this.setupMaterialComponents(componentHandler);
}
setupMaterialComponents(handler?: any): boolean {
// workaround for MDL issues with dynamic components
let isUpgraded: boolean = false;
if (handler) {
handler.upgradeAllRegistered();
isUpgraded = true;
}
return isUpgraded;
}
involveUserAndCloseSearch() {
@@ -92,14 +80,14 @@ export class PeopleComponent implements OnInit, AfterViewInit {
}, error => this.logService.error(error));
}
involveUser(user: LightUserRepresentation) {
involveUser(user: UserProcessModel) {
this.peopleProcessService.involveUserWithTask(this.taskId, user.id.toString())
.subscribe(() => {
this.people = [...this.people, user];
}, error => this.logService.error('Impossible to involve user with task'));
}
removeInvolvedUser(user: LightUserRepresentation) {
removeInvolvedUser(user: UserProcessModel) {
this.peopleProcessService.removeInvolvedUser(this.taskId, user.id.toString())
.subscribe(() => {
this.people = this.people.filter((involvedUser) => {

View File

@@ -129,7 +129,7 @@ describe('StartTaskComponent', () => {
it('should create new task when start is clicked', () => {
let successSpy = spyOn(component.success, 'emit');
component.appId = 'fakeAppId';
component.appId = 42;
component.startTaskmodel = new StartTaskModel(startTaskMock);
fixture.detectChanges();
let createTaskButton = <HTMLElement> element.querySelector('#button-start');
@@ -139,7 +139,7 @@ describe('StartTaskComponent', () => {
it('should send on success event when the task is started', () => {
let successSpy = spyOn(component.success, 'emit');
component.appId = 'fakeAppId';
component.appId = 42;
component.startTaskmodel = new StartTaskModel(startTaskMock);
fixture.detectChanges();
let createTaskButton = <HTMLElement> element.querySelector('#button-start');
@@ -154,7 +154,7 @@ describe('StartTaskComponent', () => {
it('should send on success event when only name is given', () => {
let successSpy = spyOn(component.success, 'emit');
component.appId = 'fakeAppId';
component.appId = 42;
component.startTaskmodel.name = 'fakeName';
fixture.detectChanges();
let createTaskButton = <HTMLElement> element.querySelector('#button-start');
@@ -195,7 +195,7 @@ describe('StartTaskComponent', () => {
it('should attach form to the task when a form is selected', () => {
let successSpy = spyOn(component.success, 'emit');
component.appId = 'fakeAppId';
component.appId = 42;
component.startTaskmodel = new StartTaskModel(startTaskMock);
component.formKey = 1204;
fixture.detectChanges();
@@ -211,7 +211,7 @@ describe('StartTaskComponent', () => {
it('should not attach form to the task when a no form is selected', () => {
let successSpy = spyOn(component.success, 'emit');
component.appId = 'fakeAppId';
component.appId = 42;
component.startTaskmodel = new StartTaskModel(startTaskMock);
component.formKey = null;
fixture.detectChanges();
@@ -256,7 +256,7 @@ describe('StartTaskComponent', () => {
it('should assign task when an assignee is selected', () => {
let successSpy = spyOn(component.success, 'emit');
component.appId = 'fakeAppId';
component.appId = 42;
component.startTaskmodel = new StartTaskModel(startTaskMock);
component.formKey = 1204;
component.assigneeId = testUser.id;
@@ -273,7 +273,7 @@ describe('StartTaskComponent', () => {
it('should not assign task when no assignee is selected', () => {
let successSpy = spyOn(component.success, 'emit');
component.appId = 'fakeAppId';
component.appId = 42;
component.formKey = 1204;
component.assigneeId = null;
component.startTaskmodel = new StartTaskModel(startTaskMock);
@@ -385,7 +385,7 @@ describe('StartTaskComponent', () => {
expect(testFullname4.trim()).toBe('');
});
it('should emit error when there is an error while creating task', () => {
xit('should emit error when there is an error while creating task', () => {
let errorSpy = spyOn(component.error, 'emit');
spyOn(service, 'createNewTask').and.returnValue(Observable.throw({}));
let createTaskButton = <HTMLElement> element.querySelector('#button-start');

View File

@@ -19,8 +19,8 @@ import { Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation } fro
import { DateAdapter, MAT_DATE_FORMATS } from '@angular/material';
import * as moment from 'moment';
import { Moment } from 'moment';
import { LightUserRepresentation, LogService, MOMENT_DATE_FORMATS,
MomentDateAdapter, PeopleProcessService, UserPreferencesService } from 'ng2-alfresco-core';
import { LogService, MOMENT_DATE_FORMATS,
MomentDateAdapter, PeopleProcessService, UserPreferencesService, UserProcessModel } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx';
import { Form } from '../models/form.model';
import { StartTaskModel } from '../models/start-task.model';
@@ -41,7 +41,7 @@ export class StartTaskComponent implements OnInit {
public FORMAT_DATE: string = 'DD/MM/YYYY';
@Input()
appId: string;
appId: number;
@Output()
success: EventEmitter<any> = new EventEmitter<any>();
@@ -52,7 +52,7 @@ export class StartTaskComponent implements OnInit {
@Output()
error: EventEmitter<any> = new EventEmitter<any>();
people: LightUserRepresentation[] = [];
people: UserProcessModel[] = [];
startTaskmodel: StartTaskModel = new StartTaskModel();
@@ -90,7 +90,7 @@ export class StartTaskComponent implements OnInit {
public start(): void {
if (this.startTaskmodel.name) {
this.startTaskmodel.category = this.appId;
this.startTaskmodel.category = this.appId.toString();
this.taskService.createNewTask(new TaskDetailsModel(this.startTaskmodel))
.switchMap((createRes: any) =>
this.attachForm(createRes.id, this.formKey).defaultIfEmpty(createRes)
@@ -148,7 +148,7 @@ export class StartTaskComponent implements OnInit {
});
}
public isUserNameEmpty(user: LightUserRepresentation): boolean {
public isUserNameEmpty(user: UserProcessModel): boolean {
return !user || (this.isEmpty(user.firstName) && this.isEmpty(user.lastName));
}

View File

@@ -27,11 +27,8 @@ import { AppConfigServiceMock } from '../assets/app-config.service.mock';
import { TranslationMock } from '../assets/translation.service.mock';
import { TaskAttachmentListComponent } from './task-attachment-list.component';
declare let jasmine: any;
describe('TaskAttachmentList', () => {
let componentHandler: any;
let component: TaskAttachmentListComponent;
let fixture: ComponentFixture<TaskAttachmentListComponent>;
let service: ActivitiContentService;
@@ -113,11 +110,6 @@ describe('TaskAttachmentList', () => {
blobObj
));
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered',
'upgradeElement'
]);
window['componentHandler'] = componentHandler;
});
it('should load attachments when taskId specified', () => {

View File

@@ -110,7 +110,7 @@ export class TaskAttachmentListComponent implements OnChanges {
}
}
private deleteAttachmentById(contentId: string) {
private deleteAttachmentById(contentId: number) {
if (contentId) {
this.activitiContentService.deleteRelatedContent(contentId).subscribe(
(res: any) => {

View File

@@ -22,10 +22,9 @@ import { By } from '@angular/platform-browser';
import { Observable } from 'rxjs/Rx';
import { ActivitiFormModule, FormModel, FormOutcomeEvent, FormOutcomeModel, FormService } from 'ng2-activiti-form';
import { AppConfigService, CoreModule, LogService, TranslationService } from 'ng2-alfresco-core';
import { AppConfigService, CommentProcessService, CoreModule, LogService, TranslationService } from 'ng2-alfresco-core';
import { LightUserRepresentation } from 'ng2-alfresco-core';
import { PeopleProcessService } from 'ng2-alfresco-core';
import { PeopleProcessService, UserProcessModel } from 'ng2-alfresco-core';
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
import { TranslationMock } from '../assets/translation.service.mock';
import { TaskDetailsModel } from '../models/task-details.model';
@@ -36,7 +35,7 @@ import { TaskDetailsComponent } from './task-details.component';
declare let jasmine: any;
const fakeUser: LightUserRepresentation = new LightUserRepresentation({
const fakeUser: UserProcessModel = new UserProcessModel({
id: 'fake-id',
firstName: 'fake-name',
lastName: 'fake-last',
@@ -45,7 +44,6 @@ const fakeUser: LightUserRepresentation = new LightUserRepresentation({
describe('TaskDetailsComponent', () => {
let componentHandler: any;
let service: TaskListService;
let formService: FormService;
let component: TaskDetailsComponent;
@@ -57,6 +55,7 @@ describe('TaskDetailsComponent', () => {
let getFormTaskSpy: jasmine.Spy;
let completeTaskSpy: jasmine.Spy;
let logService: LogService;
let commentProcessService: CommentProcessService;
beforeEach(async(() => {
TestBed.configureTestingModule({
@@ -74,7 +73,8 @@ describe('TaskDetailsComponent', () => {
TaskListService,
PeopleProcessService,
{provide: TranslationService, useClass: TranslationMock},
{provide: AppConfigService, useClass: AppConfigServiceMock}
{provide: AppConfigService, useClass: AppConfigServiceMock},
CommentProcessService
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
@@ -89,6 +89,7 @@ describe('TaskDetailsComponent', () => {
component = fixture.componentInstance;
service = fixture.debugElement.injector.get(TaskListService);
formService = fixture.debugElement.injector.get(FormService);
commentProcessService = TestBed.get(CommentProcessService);
getTaskDetailsSpy = spyOn(service, 'getTaskDetails').and.returnValue(Observable.of(taskDetailsMock));
getFormSpy = spyOn(formService, 'getTaskForm').and.returnValue(Observable.of(taskFormMock));
@@ -98,14 +99,9 @@ describe('TaskDetailsComponent', () => {
getTasksSpy = spyOn(service, 'getTasks').and.returnValue(Observable.of(tasksMock));
assignTaskSpy = spyOn(service, 'assignTask').and.returnValue(Observable.of(fakeUser));
completeTaskSpy = spyOn(service, 'completeTask').and.returnValue(Observable.of({}));
spyOn(service, 'getComments').and.returnValue(Observable.of(noDataMock));
spyOn(commentProcessService, 'getTaskComments').and.returnValue(Observable.of(noDataMock));
spyOn(service, 'getTaskChecklist').and.returnValue(Observable.of(noDataMock));
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered',
'upgradeElement'
]);
window['componentHandler'] = componentHandler;
});
it('should load task details when taskId specified', () => {
@@ -293,7 +289,7 @@ describe('TaskDetailsComponent', () => {
component.ngOnChanges({'taskId': new SimpleChange('123', '456', true)});
component.taskPeople = [];
component.taskDetails = new TaskDetailsModel(taskDetailsMock);
component.taskDetails.endDate = '2017-10-03T17:03:57.311+0000';
component.taskDetails.endDate = new Date('2017-10-03T17:03:57.311+0000');
fixture.detectChanges();
expect((component.activiticomments as any).nativeElement.readOnly).toBe(true);
@@ -305,7 +301,7 @@ describe('TaskDetailsComponent', () => {
component.ngOnChanges({'taskId': new SimpleChange('123', '456', true)});
component.taskPeople = [];
component.taskDetails = new TaskDetailsModel(taskDetailsMock);
component.taskDetails.endDate = '2017-10-03T17:03:57.311+0000';
component.taskDetails.endDate = new Date('2017-10-03T17:03:57.311+0000');
fixture.detectChanges();
expect((component.activiticomments as any).nativeElement.readOnly).toBe(true);
@@ -329,7 +325,7 @@ describe('TaskDetailsComponent', () => {
component.ngOnChanges({'taskId': new SimpleChange('123', '456', true)});
component.taskPeople = [fakeUser];
component.taskDetails = new TaskDetailsModel(taskDetailsMock);
component.taskDetails.endDate = '2017-10-03T17:03:57.311+0000';
component.taskDetails.endDate = new Date('2017-10-03T17:03:57.311+0000');
fixture.detectChanges();
expect((component.activiticomments as any).nativeElement.readOnly).toBe(false);

View File

@@ -27,8 +27,8 @@ import { Component,
} from '@angular/core';
import { MatDialog, MatDialogRef } from '@angular/material';
import { ContentLinkModel, FormFieldValidator, FormModel, FormOutcomeEvent } from 'ng2-activiti-form';
import { PeopleProcessService, UserProcessModel } from 'ng2-alfresco-core';
import { AlfrescoAuthenticationService, CardViewUpdateService, ClickNotification, LogService, UpdateNotification } from 'ng2-alfresco-core';
import { LightUserRepresentation, PeopleProcessService } from 'ng2-alfresco-core';
import { Observable, Observer } from 'rxjs/Rx';
import { TaskQueryRequestRepresentationModel } from '../models/filter.model';
import { TaskDetailsModel } from '../models/task-details.model';
@@ -131,16 +131,16 @@ export class TaskDetailsComponent implements OnInit, OnChanges {
taskDetails: TaskDetailsModel;
taskFormName: string = null;
taskPeople: LightUserRepresentation[] = [];
taskPeople: UserProcessModel[] = [];
noTaskDetailsTemplateComponent: TemplateRef<any>;
showAssignee: boolean = false;
private peopleSearchObserver: Observer<LightUserRepresentation[]>;
private peopleSearchObserver: Observer<UserProcessModel[]>;
public errorDialogRef: MatDialogRef<TemplateRef<any>>;
peopleSearch$: Observable<LightUserRepresentation[]>;
peopleSearch$: Observable<UserProcessModel[]>;
constructor(private activitiTaskList: TaskListService,
private authService: AlfrescoAuthenticationService,
@@ -148,7 +148,7 @@ export class TaskDetailsComponent implements OnInit, OnChanges {
private logService: LogService,
private cardViewUpdateService: CardViewUpdateService,
private dialog: MatDialog) {
this.peopleSearch$ = new Observable<LightUserRepresentation[]>(observer => this.peopleSearchObserver = observer).share();
this.peopleSearch$ = new Observable<UserProcessModel[]>(observer => this.peopleSearchObserver = observer).share();
}
ngOnInit() {
@@ -234,7 +234,7 @@ export class TaskDetailsComponent implements OnInit, OnChanges {
this.readOnlyForm = this.readOnlyForm ? this.readOnlyForm : !!(endDate && !isNaN(endDate.getTime()));
if (this.taskDetails && this.taskDetails.involvedPeople) {
this.taskDetails.involvedPeople.forEach((user) => {
this.taskPeople.push(new LightUserRepresentation(user));
this.taskPeople.push(new UserProcessModel(user));
});
}
});
@@ -347,7 +347,7 @@ export class TaskDetailsComponent implements OnInit, OnChanges {
this.showAssignee = false;
}
assignTaskToUser(selectedUser: LightUserRepresentation) {
assignTaskToUser(selectedUser: UserProcessModel) {
this.activitiTaskList.assignTask(this.taskDetails.id, selectedUser).subscribe(
(res: any) => {
this.logService.info('Task Assigned to ' + selectedUser.email);

View File

@@ -17,8 +17,7 @@
import { SimpleChange } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AppConfigService, CoreModule, TranslationService } from 'ng2-alfresco-core';
import { AppConfigService, AppsProcessService, CoreModule, TranslationService } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx';
import { TranslationMock } from '../assets/translation.service.mock';
import { FilterParamsModel, FilterRepresentationModel } from '../models/filter.model';
@@ -28,6 +27,7 @@ import { TaskFiltersComponent } from './task-filters.component';
describe('TaskFiltersComponent', () => {
let activitiService: TaskListService;
let appsProcessService: AppsProcessService;
let fakeGlobalFilter = [];
fakeGlobalFilter.push(new FilterRepresentationModel({
@@ -46,11 +46,6 @@ describe('TaskFiltersComponent', () => {
filter: { state: 'open', assignment: 'fake-assignee' }
}));
let fakeFilter = new FilterRepresentationModel({
name: 'FakeMyTasks1',
filter: { state: 'open', assignment: 'fake-assignee' }
});
let fakeGlobalFilterPromise = new Promise(function (resolve, reject) {
resolve(fakeGlobalFilter);
});
@@ -90,6 +85,7 @@ describe('TaskFiltersComponent', () => {
component = fixture.componentInstance;
activitiService = TestBed.get(TaskListService);
appsProcessService = TestBed.get(AppsProcessService);
});
it('should emit an error with a bad response', (done) => {
@@ -106,20 +102,6 @@ describe('TaskFiltersComponent', () => {
});
it('should emit an error with a bad response', (done) => {
spyOn(activitiService, 'getDeployedApplications').and.returnValue(Observable.fromPromise(fakeErrorFilterPromise));
const appId = 'fake-app';
let change = new SimpleChange(null, appId, true);
component.ngOnChanges({ 'appName': change });
component.onError.subscribe((err) => {
expect(err).toBeDefined();
done();
});
});
it('should return the filter task list', (done) => {
spyOn(activitiService, 'getTaskListFilters').and.returnValue(Observable.fromPromise(fakeGlobalFilterPromise));
const appId = '1';
@@ -145,14 +127,14 @@ describe('TaskFiltersComponent', () => {
resolve({});
});
spyOn(activitiService, 'getDeployedApplications').and.returnValue(Observable.fromPromise(fakeDeployedApplicationsPromise));
spyOn(appsProcessService, 'getDeployedApplicationsByName').and.returnValue(Observable.fromPromise(fakeDeployedApplicationsPromise));
spyOn(activitiService, 'getTaskListFilters').and.returnValue(Observable.fromPromise(fakeGlobalFilterPromise));
let change = new SimpleChange(null, 'test', true);
component.ngOnChanges({ 'appName': change });
component.onSuccess.subscribe((res) => {
let deployApp: any = activitiService.getDeployedApplications;
let deployApp: any = appsProcessService.getDeployedApplicationsByName;
expect(deployApp.calls.count()).toEqual(1);
expect(res).toBeDefined();
done();
@@ -320,20 +302,6 @@ describe('TaskFiltersComponent', () => {
expect(component.getFiltersByAppId).toHaveBeenCalled();
});
it('should change the current filter if a filter with taskid is found', async(() => {
spyOn(activitiService, 'isTaskRelatedToFilter').and.returnValue(Observable.of(fakeFilter));
component.filters = fakeGlobalFilter;
component.selectFilterWithTask('111');
fixture.detectChanges();
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(component.currentFilter.landingTaskId).toBeDefined();
expect(component.currentFilter.landingTaskId).toBe('111');
});
}));
it('should not change the current filter if no filter with taskid is found', async(() => {
let filter = new FilterRepresentationModel({
name: 'FakeMyTasks',

View File

@@ -16,12 +16,13 @@
*/
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
import { AppsProcessService } from 'ng2-alfresco-core';
import { Observable, Observer } from 'rxjs/Rx';
import { FilterParamsModel, FilterRepresentationModel } from '../models/filter.model';
import { TaskListService } from './../services/tasklist.service';
@Component({
selector: 'adf-filters, activiti-filters',
selector: 'adf-filters, taskListService-filters',
templateUrl: './task-filters.component.html',
styleUrls: ['task-filters.component.scss']
})
@@ -40,7 +41,7 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
onError: EventEmitter<any> = new EventEmitter<any>();
@Input()
appId: string;
appId: number;
@Input()
appName: string;
@@ -55,7 +56,7 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
filters: FilterRepresentationModel [] = [];
constructor(private activiti: TaskListService) {
constructor(private taskListService: TaskListService, private appsProcessService: AppsProcessService) {
this.filter$ = new Observable<FilterRepresentationModel>(observer => this.filterObserver = observer).share();
}
@@ -85,7 +86,7 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
* @param appId
* @param appName
*/
getFilters(appId?: string, appName?: string) {
getFilters(appId?: number, appName?: string) {
if (appName) {
this.getFiltersByAppName(appName);
} else {
@@ -97,11 +98,11 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
* Return the filter list filtered by appId
* @param appId - optional
*/
getFiltersByAppId(appId?: string) {
this.activiti.getTaskListFilters(appId).subscribe(
getFiltersByAppId(appId?: number) {
this.taskListService.getTaskListFilters(appId).subscribe(
(res: FilterRepresentationModel[]) => {
if (res.length === 0 && this.isFilterListEmpty()) {
this.activiti.createDefaultFilters(appId).subscribe(
this.taskListService.createDefaultFilters(appId).subscribe(
(resDefault: FilterRepresentationModel[]) => {
this.resetFilter();
resDefault.forEach((filter) => {
@@ -136,7 +137,7 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
* @param appName
*/
getFiltersByAppName(appName: string) {
this.activiti.getDeployedApplications(appName).subscribe(
this.appsProcessService.getDeployedApplicationsByName(appName).subscribe(
application => {
this.getFiltersByAppId(application.id);
this.selectTaskFilter(this.filterParam, this.filters);
@@ -157,7 +158,7 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
public selectFilterWithTask(taskId: string) {
let filteredFilterList: FilterRepresentationModel[] = [];
this.activiti.getFilterForTaskById(taskId, this.filters).subscribe(
this.taskListService.getFilterForTaskById(taskId, this.filters).subscribe(
(filter: FilterRepresentationModel) => {
filteredFilterList.push(filter);
},
@@ -167,7 +168,6 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
() => {
if (filteredFilterList.length > 0) {
this.selectTaskFilter(new FilterParamsModel({name: 'My Tasks'}), filteredFilterList);
this.currentFilter.landingTaskId = taskId;
this.filterClick.emit(this.currentFilter);
}
});
@@ -181,7 +181,8 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
if (filterParam) {
filteredFilterList.filter((taskFilter: FilterRepresentationModel, index) => {
if (filterParam.name && filterParam.name.toLowerCase() === taskFilter.name.toLowerCase() ||
filterParam.id === taskFilter.id || filterParam.index === index) {
filterParam.id === taskFilter.id.toString()
|| filterParam.index === index) {
findTaskFilter = taskFilter;
}
});

View File

@@ -18,12 +18,11 @@
import { DebugElement } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { AppConfigService, CardViewUpdateService, CoreModule, TranslationService } from 'ng2-alfresco-core';
import { AppConfigService, CardViewUpdateService, CoreModule, TranslationService, UserProcessModel } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx';
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
import { TranslationMock } from '../assets/translation.service.mock';
import { LightUserRepresentation } from '../../../ng2-alfresco-core/src/models/user-process.model';
import { TaskDetailsModel } from '../models/task-details.model';
import { taskDetailsMock } from './../assets/task-details.mock';
import { TaskListService } from './../services/tasklist.service';
@@ -32,7 +31,6 @@ import { TaskHeaderComponent } from './task-header.component';
describe('TaskHeaderComponent', () => {
let service: TaskListService;
let componentHandler: any;
let component: TaskHeaderComponent;
let fixture: ComponentFixture<TaskHeaderComponent>;
let debugElement: DebugElement;
@@ -62,12 +60,6 @@ describe('TaskHeaderComponent', () => {
debugElement = fixture.debugElement;
component.taskDetails = new TaskDetailsModel(taskDetailsMock);
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered',
'upgradeElement'
]);
window['componentHandler'] = componentHandler;
});
it('should render empty component if no task details provided', () => {
@@ -107,7 +99,7 @@ describe('TaskHeaderComponent', () => {
});
it('should set editable to false if the task has already completed', () => {
component.taskDetails.endDate = '05/05/2002';
component.taskDetails.endDate = new Date('05/05/2002');
component.ngOnChanges({});
fixture.detectChanges();
@@ -139,7 +131,7 @@ describe('TaskHeaderComponent', () => {
describe('Unclaim', () => {
const batman = new LightUserRepresentation({ id : 1, email: 'bruce.wayne@gotham.com', firstName: 'Bruce', lastName: 'Wayne', userImage: 'batman.jpg' });
const batman = new UserProcessModel({ id : 1, email: 'bruce.wayne@gotham.com', firstName: 'Bruce', lastName: 'Wayne', userImage: 'batman.jpg' });
let taskListService;
beforeEach(() => {
@@ -176,7 +168,7 @@ describe('TaskHeaderComponent', () => {
});
it('should display due date', () => {
component.taskDetails.dueDate = '2016-11-03';
component.taskDetails.dueDate = new Date('2016-11-03');
component.ngOnChanges({});
fixture.detectChanges();
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-dueDate"] .adf-property-value'));

View File

@@ -84,7 +84,6 @@ describe('TaskListComponent', () => {
error: 'wrong request'
};
let componentHandler: any;
let component: TaskListComponent;
let fixture: ComponentFixture<TaskListComponent>;
let taskListService: TaskListService;
@@ -116,11 +115,6 @@ describe('TaskListComponent', () => {
taskListService = TestBed.get(TaskListService);
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered',
'upgradeElement'
]);
window['componentHandler'] = componentHandler;
});
beforeEach(() => {

View File

@@ -36,7 +36,7 @@ export class TaskListComponent implements OnChanges, OnInit, AfterContentInit {
@ContentChild(DataColumnListComponent) columnList: DataColumnListComponent;
@Input()
appId: string;
appId: number;
@Input()
processInstanceId: string;

View File

@@ -15,13 +15,8 @@
* limitations under the License.
*/
/**
*
* This object represent the app definition.
*
*
* @returns {AppDefinitionRepresentationModel} .
*/
import { TaskQueryRequestRepresentation, UserTaskFilterRepresentation } from 'alfresco-js-api';
export class AppDefinitionRepresentationModel {
defaultAppId: string;
deploymentId: string;
@@ -36,25 +31,18 @@ export class AppDefinitionRepresentationModel {
constructor(obj?: any) {
if (obj) {
this.defaultAppId = obj.defaultAppId ? obj.defaultAppId : null;
this.deploymentId = obj.deploymentId ? obj.deploymentId : null;
this.name = obj.name ? obj.name : null;
this.description = obj.description ? obj.description : null;
this.theme = obj.theme ? obj.theme : null;
this.icon = obj.icon ? obj.icon : null;
this.id = obj.id ? obj.id : null;
this.modelId = obj.modelId ? obj.modelId : null;
this.tenantId = obj.tenantId ? obj.tenantId : null;
this.deploymentId = obj.deploymentId ? obj.deploymentId : null;
this.name = obj.name ? obj.name : null;
this.description = obj.description ? obj.description : null;
this.theme = obj.theme ? obj.theme : null;
this.icon = obj.icon ? obj.icon : null;
this.id = obj.id ? obj.id : null;
this.modelId = obj.modelId ? obj.modelId : null;
this.tenantId = obj.tenantId ? obj.tenantId : null;
}
}
}
/**
*
* This object represent the parameters to filter a filter.
*
*
* @returns {FilterParamsModel} .
*/
export class FilterParamsModel {
id: string;
name: string;
@@ -69,22 +57,14 @@ export class FilterParamsModel {
}
}
/**
*
* This object represent the filter.
*
*
* @returns {FilterRepresentationModel} .
*/
export class FilterRepresentationModel {
id: string;
appId: string;
export class FilterRepresentationModel implements UserTaskFilterRepresentation {
id: number;
appId: number;
name: string;
recent: boolean;
icon: string;
filter: FilterParamRepresentationModel;
index: number;
landingTaskId: string;
constructor(obj?: any) {
if (obj) {
@@ -95,7 +75,6 @@ export class FilterRepresentationModel {
this.icon = obj.icon || null;
this.filter = new FilterParamRepresentationModel(obj.filter);
this.index = obj.index;
this.landingTaskId = obj.landingTaskId;
}
}
@@ -104,13 +83,6 @@ export class FilterRepresentationModel {
}
}
/**
*
* This object represent the parameters of a filter.
*
*
* @returns {FilterParamRepresentationModel} .
*/
export class FilterParamRepresentationModel {
processDefinitionId: string;
processDefinitionKey: string;
@@ -135,7 +107,7 @@ export class FilterParamRepresentationModel {
}
}
export class TaskQueryRequestRepresentationModel {
export class TaskQueryRequestRepresentationModel implements TaskQueryRequestRepresentation {
appDefinitionId: string;
processInstanceId: string;
processDefinitionId: string;

View File

@@ -22,13 +22,13 @@
*
* @returns {StartTaskModel} .
*/
import { LightUserRepresentation } from 'ng2-alfresco-core';
import { UserProcessModel } from 'ng2-alfresco-core';
export class StartTaskModel {
name: string;
description: string;
assignee: LightUserRepresentation;
assignee: UserProcessModel;
dueDate: any;
formKey: any;
category: string;
@@ -36,7 +36,7 @@ export class StartTaskModel {
constructor(obj?: any) {
this.name = obj && obj.name || null;
this.description = obj && obj.description || null;
this.assignee = obj && obj.assignee ? new LightUserRepresentation(obj.assignee) : null;
this.assignee = obj && obj.assignee ? new UserProcessModel(obj.assignee) : null;
this.dueDate = obj && obj.dueDate || null;
this.formKey = obj && obj.formKey || null;
this.category = obj && obj.category || null;

View File

@@ -22,27 +22,28 @@
*
* @returns {TaskDetailsModel} .
*/
import { LightUserRepresentation } from 'ng2-alfresco-core';
import { TaskRepresentation } from 'alfresco-js-api';
import { UserProcessModel } from 'ng2-alfresco-core';
export class TaskDetailsModel {
export class TaskDetailsModel implements TaskRepresentation {
id: string;
name: string;
assignee: LightUserRepresentation;
assignee: UserProcessModel;
priority: number;
adhocTaskCanBeReassigned: number;
adhocTaskCanBeReassigned: boolean;
category: string;
created: string;
created: Date;
description: string;
dueDate: string;
duration: string;
endDate: string;
dueDate: Date;
duration: number;
endDate: Date;
executionId: string;
formKey: string;
initiatorCanCompleteTask: boolean;
managerOfCandidateGroup: boolean;
memberOfCandidateGroup: boolean;
memberOfCandidateUsers: boolean;
involvedPeople: LightUserRepresentation [];
involvedPeople: UserProcessModel [];
parentTaskId: string;
parentTaskName: string;
processDefinitionCategory: string;
@@ -62,7 +63,7 @@ export class TaskDetailsModel {
this.id = obj.id || null;
this.name = obj.name || null;
this.priority = obj.priority;
this.assignee = obj.assignee ? new LightUserRepresentation(obj.assignee) : null;
this.assignee = obj.assignee ? new UserProcessModel(obj.assignee) : null;
this.adhocTaskCanBeReassigned = obj.adhocTaskCanBeReassigned;
this.category = obj.category || null;
this.created = obj.created || null;

View File

@@ -16,14 +16,12 @@
*/
import { async, TestBed } from '@angular/core/testing';
import { AppConfigService, CoreModule, TranslationService } from 'ng2-alfresco-core';
import { LightUserRepresentation } from 'ng2-alfresco-core';
import { AppConfigService, CoreModule, TranslationService, UserProcessModel } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx';
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
import {
fakeAppFilter,
fakeAppPromise,
fakeApps,
fakeErrorTaskList,
fakeFilter,
fakeFilters,
@@ -34,13 +32,11 @@ import {
fakeTaskList,
fakeTaskListDifferentProcessDefinitionKey,
fakeTasksChecklist,
fakeTasksComment,
fakeUser1,
fakeUser2,
secondFakeTaskList
} from '../assets/tasklist-service.mock';
import { TranslationMock } from '../assets/translation.service.mock';
import { Comment } from '../models/comment.model';
import { FilterRepresentationModel, TaskQueryRequestRepresentationModel } from '../models/filter.model';
import { TaskDetailsModel } from '../models/task-details.model';
import { TaskListService } from './tasklist.service';
@@ -139,7 +135,7 @@ describe('Activiti TaskList Service', () => {
it('should call the api withthe appId', (done) => {
spyOn(service, 'callApiTaskFilters').and.returnValue((fakeAppPromise));
let appId = '1';
let appId = 1;
service.getTaskListFilters(appId).subscribe(
(res) => {
expect(service.callApiTaskFilters).toHaveBeenCalledWith(appId);
@@ -149,7 +145,7 @@ describe('Activiti TaskList Service', () => {
});
it('should return the app filter by id', (done) => {
let appId = '1';
let appId = 1;
service.getTaskListFilters(appId).subscribe(
(res) => {
expect(res).toBeDefined();
@@ -359,24 +355,6 @@ describe('Activiti TaskList Service', () => {
});
});
it('should return the tasks comments ', (done) => {
service.getComments('999').subscribe(
(res: Comment[]) => {
expect(res).toBeDefined();
expect(res.length).toEqual(2);
expect(res[0].message).toEqual('fake-message-1');
expect(res[1].message).toEqual('fake-message-2');
done();
}
);
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeTasksComment)
});
});
it('should return the tasks checklists ', (done) => {
service.getTaskChecklist('999').subscribe(
(res: TaskDetailsModel[]) => {
@@ -446,31 +424,6 @@ describe('Activiti TaskList Service', () => {
});
});
it('should add a comment task ', (done) => {
service.addComment('999', 'fake-comment-message').subscribe(
(res: Comment) => {
expect(res).toBeDefined();
expect(res.id).not.toEqual('');
expect(res.message).toEqual('fake-comment-message');
expect(res.created).not.toEqual('');
expect(res.createdBy.email).toEqual('fake-email@dom.com');
expect(res.createdBy.firstName).toEqual('firstName');
expect(res.createdBy.lastName).toEqual('lastName');
done();
}
);
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
contentType: 'application/json',
responseText: JSON.stringify({
id: '111', message: 'fake-comment-message',
createdBy: fakeUser1,
created: '2016-07-15T11:19:17.440+0000'
})
});
});
it('should complete the task ', (done) => {
service.completeTask('999').subscribe(
(res: any) => {
@@ -504,7 +457,7 @@ describe('Activiti TaskList Service', () => {
});
it('should return the default filters', (done) => {
service.createDefaultFilters('1234').subscribe(
service.createDefaultFilters(1234).subscribe(
(res: FilterRepresentationModel []) => {
expect(res).toBeDefined();
expect(res.length).toEqual(4);
@@ -574,65 +527,6 @@ describe('Activiti TaskList Service', () => {
});
});
it('should get the deployed apps ', (done) => {
service.getDeployedApplications().subscribe(
(res: any) => {
expect(res).toBeDefined();
expect(res.length).toEqual(2);
expect(res[0].name).toEqual('Sales-Fakes-App');
expect(res[0].description).toEqual('desc-fake1');
expect(res[0].deploymentId).toEqual('111');
expect(res[1].name).toEqual('health-care-Fake');
expect(res[1].description).toEqual('desc-fake2');
expect(res[1].deploymentId).toEqual('444');
done();
}
);
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeApps)
});
});
it('should get the filter deployed app ', (done) => {
let name = 'health-care-Fake';
service.getDeployedApplications(name).subscribe(
(res: any) => {
expect(res).toBeDefined();
expect(res.name).toEqual('health-care-Fake');
expect(res.description).toEqual('desc-fake2');
expect(res.deploymentId).toEqual('444');
done();
}
);
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeApps)
});
});
it('should get the deployed app details by id ', (done) => {
service.getApplicationDetailsById(1).subscribe(
(app: any) => {
expect(app).toBeDefined();
expect(app.name).toEqual('Sales-Fakes-App');
expect(app.description).toEqual('desc-fake1');
expect(app.deploymentId).toEqual('111');
done();
}
);
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeApps)
});
});
it('should create a new standalone task ', (done) => {
let taskFake = new TaskDetailsModel({
name: 'FakeNameTask',
@@ -677,8 +571,11 @@ describe('Activiti TaskList Service', () => {
expect(res.category).toEqual('3');
expect(res.created).not.toEqual('');
expect(res.adhocTaskCanBeReassigned).toBe(true);
expect(res.assignee).toEqual(new LightUserRepresentation(fakeUser2));
expect(res.involvedPeople).toEqual([fakeUser1]);
expect(res.assignee).toEqual(new UserProcessModel(fakeUser2));
expect(res.involvedPeople[0].email).toEqual(fakeUser1.email);
expect(res.involvedPeople[0].firstName).toEqual(fakeUser1.firstName);
expect(res.involvedPeople[0].lastName).toEqual(fakeUser1.lastName);
expect(res.involvedPeople[0].id).toEqual(fakeUser1.id);
done();
}
);
@@ -710,8 +607,9 @@ describe('Activiti TaskList Service', () => {
expect(res.category).toEqual('3');
expect(res.created).not.toEqual('');
expect(res.adhocTaskCanBeReassigned).toBe(true);
expect(res.assignee).toEqual(new LightUserRepresentation(fakeUser2));
expect(res.involvedPeople).toEqual([fakeUser1]);
expect(res.assignee).toEqual(new UserProcessModel(fakeUser2));
expect(res.involvedPeople[0].email).toEqual(fakeUser1.email);
expect(res.involvedPeople[0].firstName).toEqual(fakeUser1.firstName);
done();
}
);
@@ -813,7 +711,7 @@ describe('Activiti TaskList Service', () => {
let fakeFilterList: FilterRepresentationModel[] = [];
fakeFilterList.push(fakeRepresentationFilter1, fakeRepresentationFilter2);
let resultFilter = null;
let resultFilter: FilterRepresentationModel = null;
service.getFilterForTaskById(taskId, fakeFilterList).subscribe(
(res: FilterRepresentationModel) => {
resultFilter = res;

View File

@@ -17,13 +17,8 @@
import { Injectable } from '@angular/core';
import { AlfrescoApiService, LogService } from 'ng2-alfresco-core';
import { LightUserRepresentation } from 'ng2-alfresco-core';
import { Observable, Subject } from 'rxjs/Rx';
import { Comment } from '../models/comment.model';
import {
FilterRepresentationModel,
TaskQueryRequestRepresentationModel
} from '../models/filter.model';
import { FilterRepresentationModel, TaskQueryRequestRepresentationModel } from '../models/filter.model';
import { Form } from '../models/form.model';
import { TaskDetailsModel } from '../models/task-details.model';
import { TaskListModel } from '../models/task-list.model';
@@ -39,38 +34,11 @@ export class TaskListService {
this.tasksList$ = this.tasksListSubject.asObservable();
}
/**
* Retrieve all the Deployed app
* @returns {Observable<any>}
*/
getDeployedApplications(name?: string): Observable<any> {
return Observable.fromPromise(this.apiService.getInstance().activiti.appsApi.getAppDefinitions())
.map((response: any) => {
if (name) {
return response.data.find(app => app.name === name);
}
return response.data;
})
.catch(err => this.handleError(err));
}
/**
* Retrieve Deployed App details by appId
* @returns {Observable<any>}
*/
getApplicationDetailsById(appId: number): Observable<any> {
return Observable.fromPromise(this.apiService.getInstance().activiti.appsApi.getAppDefinitions())
.map((response: any) => {
return response.data.find(app => app.id === appId);
})
.catch(err => this.handleError(err));
}
/**
* Retrieve all the Tasks filters
* @returns {Observable<any>}
*/
getTaskListFilters(appId?: string): Observable<any> {
getTaskListFilters(appId?: number): Observable<any> {
return Observable.fromPromise(this.callApiTaskFilters(appId))
.map((response: any) => {
let filters: FilterRepresentationModel[] = [];
@@ -88,7 +56,7 @@ export class TaskListService {
* @param appId - string - optional - The id of app
* @returns {Observable<FilterRepresentationModel>}
*/
getTaskFilterById(filterId: number, appId?: string): Observable<FilterRepresentationModel> {
getTaskFilterById(filterId: number, appId?: number): Observable<FilterRepresentationModel> {
return Observable.fromPromise(this.callApiTaskFilters(appId))
.map((response: any) => {
return response.data.find(filter => filter.id === filterId);
@@ -100,7 +68,7 @@ export class TaskListService {
* @param taskName - string - The name of the filter
* @returns {Observable<FilterRepresentationModel>}
*/
getTaskFilterByName(taskName: string, appId?: string): Observable<FilterRepresentationModel> {
getTaskFilterByName(taskName: string, appId?: number): Observable<FilterRepresentationModel> {
return Observable.fromPromise(this.callApiTaskFilters(appId))
.map((response: any) => {
return response.data.find(filter => filter.name === taskName);
@@ -182,8 +150,7 @@ export class TaskListService {
if (state) {
requestNode.state = state;
}
return this.getTotalTasks(requestNode).
switchMap((res: any) => {
return this.getTotalTasks(requestNode).switchMap((res: any) => {
requestNode.size = res.total;
return this.getTasks(requestNode);
});
@@ -196,15 +163,15 @@ export class TaskListService {
*/
findAllTasksWhitoutState(requestNode: TaskQueryRequestRepresentationModel): Observable<TaskListModel> {
return Observable.forkJoin(
this.findTasksByState(requestNode, 'open'),
this.findAllTaskByState(requestNode, 'completed'),
(activeTasks: TaskListModel, completedTasks: TaskListModel) => {
const tasks = Object.assign({}, activeTasks);
tasks.total += completedTasks.total;
tasks.data = tasks.data.concat(completedTasks.data);
return tasks;
}
);
this.findTasksByState(requestNode, 'open'),
this.findAllTaskByState(requestNode, 'completed'),
(activeTasks: TaskListModel, completedTasks: TaskListModel) => {
const tasks = Object.assign({}, activeTasks);
tasks.total += completedTasks.total;
tasks.data = tasks.data.concat(completedTasks.data);
return tasks;
}
);
}
/**
@@ -212,32 +179,14 @@ export class TaskListService {
* @param id - taskId
* @returns {<TaskDetailsModel>}
*/
getTaskDetails(id: string): Observable<TaskDetailsModel> {
return Observable.fromPromise(this.callApiTaskDetails(id))
getTaskDetails(taskId: string): Observable<TaskDetailsModel> {
return Observable.fromPromise(this.callApiTaskDetails(taskId))
.map(res => res)
.map((details: any) => {
return new TaskDetailsModel(details);
}).catch(err => this.handleError(err));
}
/**
* Retrieve all the task's comments
* @param id - taskId
* @returns {<Comment[]>}
*/
getComments(id: string): Observable<Comment[]> {
return Observable.fromPromise(this.callApiTaskComments(id))
.map(res => res)
.map((response: any) => {
let comments: Comment[] = [];
response.data.forEach((comment) => {
let user = new LightUserRepresentation(comment.createdBy);
comments.push(new Comment(comment.id, comment.message, comment.created, user));
});
return comments;
}).catch(err => this.handleError(err));
}
/**
* Retrieve all the task's checklist
* @param id - taskId
@@ -277,7 +226,7 @@ export class TaskListService {
}
attachFormToATask(taskId: string, formId: number): Observable<any> {
return Observable.fromPromise(this.apiService.getInstance().activiti.taskApi.attachForm(taskId, { 'formId': formId }));
return Observable.fromPromise(this.apiService.getInstance().activiti.taskApi.attachForm(taskId, {'formId': formId}));
}
/**
@@ -285,7 +234,7 @@ export class TaskListService {
* @param appId
* @returns {FilterRepresentationModel[]}
*/
public createDefaultFilters(appId: string): Observable<FilterRepresentationModel[]> {
public createDefaultFilters(appId: number): Observable<FilterRepresentationModel[]> {
let involvedTasksFilter = this.getInvolvedTasksFilterInstance(appId);
let involvedObservable = this.addFilter(involvedTasksFilter);
@@ -362,28 +311,13 @@ export class TaskListService {
}).catch(err => this.handleError(err));
}
/**
* Add a comment to a task
* @param id - taskId
* @param message - content of the comment
* @returns {Comment}
*/
addComment(id: string, message: string): Observable<Comment> {
return Observable.fromPromise(this.callApiAddTaskComment(id, message))
.map(res => res)
.map((response: Comment) => {
return new Comment(response.id, response.message, response.created, response.createdBy);
}).catch(err => this.handleError(err));
}
/**
* Make the task completed
* @param id - taskId
* @returns {TaskDetailsModel}
*/
completeTask(id: string) {
return Observable.fromPromise(this.callApiCompleteTask(id))
completeTask(taskId: string) {
return Observable.fromPromise(this.apiService.getInstance().activiti.taskApi.completeTask(taskId))
.map(res => res);
}
@@ -420,7 +354,7 @@ export class TaskListService {
* @returns {TaskDetailsModel}
*/
assignTask(taskId: string, requestNode: any): Observable<TaskDetailsModel> {
let assignee = {assignee: requestNode.id} ;
let assignee = {assignee: requestNode.id};
return Observable.fromPromise(this.callApiAssignTask(taskId, assignee))
.map(res => res)
.map((response: TaskDetailsModel) => {
@@ -429,7 +363,7 @@ export class TaskListService {
}
assignTaskByUserId(taskId: string, userId: number): Observable<TaskDetailsModel> {
let assignee = {assignee: userId} ;
let assignee = {assignee: userId};
return Observable.fromPromise(this.callApiAssignTask(taskId, assignee))
.map(res => res)
.map((response: TaskDetailsModel) => {
@@ -486,24 +420,16 @@ export class TaskListService {
return this.apiService.getInstance().activiti.taskApi.listTasks(requestNode);
}
callApiTaskFilters(appId?: string) {
callApiTaskFilters(appId?: number) {
if (appId) {
return this.apiService.getInstance().activiti.userFiltersApi.getUserTaskFilters({ appId: appId });
return this.apiService.getInstance().activiti.userFiltersApi.getUserTaskFilters({appId: appId});
} else {
return this.apiService.getInstance().activiti.userFiltersApi.getUserTaskFilters();
}
}
private callApiTaskDetails(id: string) {
return this.apiService.getInstance().activiti.taskApi.getTask(id);
}
private callApiTaskComments(id: string) {
return this.apiService.getInstance().activiti.taskApi.getTaskComments(id);
}
private callApiAddTaskComment(id: string, message: string) {
return this.apiService.getInstance().activiti.taskApi.addTaskComment({ message: message }, id);
private callApiTaskDetails(taskId: string) {
return this.apiService.getInstance().activiti.taskApi.getTask(taskId);
}
private callApiAddTask(task: TaskDetailsModel) {
@@ -518,12 +444,8 @@ export class TaskListService {
return this.apiService.getInstance().activiti.userFiltersApi.createUserTaskFilter(filter);
}
private callApiTaskChecklist(id: string) {
return this.apiService.getInstance().activiti.taskApi.getChecklist(id);
}
private callApiCompleteTask(id: string) {
return this.apiService.getInstance().activiti.taskApi.completeTask(id);
private callApiTaskChecklist(taskId: string) {
return this.apiService.getInstance().activiti.taskApi.getChecklist(taskId);
}
private callApiCreateTask(task: TaskDetailsModel) {
@@ -546,13 +468,13 @@ export class TaskListService {
* @param appId
* @returns {FilterRepresentationModel}
*/
getInvolvedTasksFilterInstance(appId: string): FilterRepresentationModel {
getInvolvedTasksFilterInstance(appId: number): FilterRepresentationModel {
return new FilterRepresentationModel({
'name': 'Involved Tasks',
'appId': appId,
'recent': false,
'icon': 'glyphicon-align-left',
'filter': { 'sort': 'created-desc', 'name': '', 'state': 'open', 'assignment': 'involved' }
'filter': {'sort': 'created-desc', 'name': '', 'state': 'open', 'assignment': 'involved'}
});
}
@@ -561,13 +483,13 @@ export class TaskListService {
* @param appId
* @returns {FilterRepresentationModel}
*/
getMyTasksFilterInstance(appId: string): FilterRepresentationModel {
getMyTasksFilterInstance(appId: number): FilterRepresentationModel {
return new FilterRepresentationModel({
'name': 'My Tasks',
'appId': appId,
'recent': false,
'icon': 'glyphicon-inbox',
'filter': { 'sort': 'created-desc', 'name': '', 'state': 'open', 'assignment': 'assignee' }
'filter': {'sort': 'created-desc', 'name': '', 'state': 'open', 'assignment': 'assignee'}
});
}
@@ -576,13 +498,13 @@ export class TaskListService {
* @param appId
* @returns {FilterRepresentationModel}
*/
getQueuedTasksFilterInstance(appId: string): FilterRepresentationModel {
getQueuedTasksFilterInstance(appId: number): FilterRepresentationModel {
return new FilterRepresentationModel({
'name': 'Queued Tasks',
'appId': appId,
'recent': false,
'icon': 'glyphicon-record',
'filter': { 'sort': 'created-desc', 'name': '', 'state': 'open', 'assignment': 'candidate' }
'filter': {'sort': 'created-desc', 'name': '', 'state': 'open', 'assignment': 'candidate'}
});
}
@@ -591,13 +513,13 @@ export class TaskListService {
* @param appId
* @returns {FilterRepresentationModel}
*/
getCompletedTasksFilterInstance(appId: string): FilterRepresentationModel {
getCompletedTasksFilterInstance(appId: number): FilterRepresentationModel {
return new FilterRepresentationModel({
'name': 'Completed Tasks',
'appId': appId,
'recent': true,
'icon': 'glyphicon-ok-sign',
'filter': { 'sort': 'created-desc', 'name': '', 'state': 'completed', 'assignment': 'involved' }
'filter': {'sort': 'created-desc', 'name': '', 'state': 'completed', 'assignment': 'involved'}
});
}

View File

@@ -39,10 +39,11 @@ import { AuthGuardBpm } from './src/services/auth-guard-bpm.service';
import { AuthGuardEcm } from './src/services/auth-guard-ecm.service';
import { AuthGuard } from './src/services/auth-guard.service';
import { AuthenticationService } from './src/services/authentication.service';
import { CommentProcessService } from './src/services/comment-process.service';
import { ContentService } from './src/services/content.service';
import { CookieService } from './src/services/cookie.service';
import { LogService } from './src/services/log.service';
import { LogServiceMock } from './src/services/log.service';
import { LogService } from './src/services/log.service';
import { NotificationService } from './src/services/notification.service';
import { PageTitleService } from './src/services/page-title.service';
import { RenditionsService } from './src/services/renditions.service';
@@ -51,11 +52,11 @@ import { ThumbnailService } from './src/services/thumbnail.service';
import { AlfrescoTranslateLoader } from './src/services/translate-loader.service';
import { TRANSLATION_PROVIDER, TranslationService } from './src/services/translation.service';
import { UploadService } from './src/services/upload.service';
import { UserPreferencesService } from './src/services/user-preferences.service';
import { HighlightDirective } from './src/directives/highlight.directive';
import { LogoutDirective } from './src/directives/logout.directive';
import { NodeFavoriteDirective } from './src/directives/node-favorite.directive';
import { AppsProcessService } from './src/services/apps-process.service';
import { DeletedNodesApiService } from './src/services/deleted-nodes-api.service';
import { DiscoveryApiService } from './src/services/discovery-api.service';
import { FavoritesApiService } from './src/services/favorites-api.service';
@@ -67,6 +68,7 @@ import { SearchApiService } from './src/services/search-api.service';
import { SearchService } from './src/services/search.service';
import { SharedLinksApiService } from './src/services/shared-links-api.service';
import { SitesApiService } from './src/services/sites-api.service';
import { UserPreferencesService } from './src/services/user-preferences.service';
export { MomentDateAdapter, MOMENT_DATE_FORMATS } from './src/utils/momentDateAdapter';
import { MomentDateAdapter } from './src/utils/momentDateAdapter';
@@ -100,6 +102,7 @@ export { ClickNotification } from './src/services/card-view-update.service';
export { AppConfigModule } from './src/services/app-config.service';
export { UserPreferencesService } from './src/services/user-preferences.service';
export { HighlightTransformService, HightlightTransformResult } from './src/services/highlight-transform.service';
export { AppsProcessService } from './src/services/apps-process.service';
export { DeletedNodesApiService } from './src/services/deleted-nodes-api.service';
export { FavoritesApiService } from './src/services/favorites-api.service';
@@ -110,6 +113,7 @@ export { SearchApiService } from './src/services/search-api.service';
export { SharedLinksApiService } from './src/services/shared-links-api.service';
export { SitesApiService } from './src/services/sites-api.service';
export { DiscoveryApiService } from './src/services/discovery-api.service';
export { CommentProcessService } from './src/services/comment-process.service';
import { DataColumnListComponent } from './src/components/data-column/data-column-list.component';
import { DataColumnComponent } from './src/components/data-column/data-column.component';
@@ -164,6 +168,7 @@ export * from './src/models/permissions.enum';
export * from './src/models/site.model';
export * from './src/models/product-version.model';
export * from './src/models/user-process.model';
export * from './src/models/comment-process.model';
// Old deprecated import
import { AuthenticationService as AlfrescoAuthenticationService } from './src/services/authentication.service';
@@ -205,7 +210,9 @@ export function providers() {
DiscoveryApiService,
HighlightTransformService,
MomentDateAdapter,
PeopleProcessService
PeopleProcessService,
AppsProcessService,
CommentProcessService
];
}

View File

@@ -0,0 +1,30 @@
/*!
* @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.
*/
export let fakeApps = {
size: 2, total: 2, start: 0,
data: [
{
id: 1, defaultAppId: null, name: 'Sales-Fakes-App', description: 'desc-fake1', modelId: 22,
theme: 'theme-1-fake', icon: 'glyphicon-asterisk', 'deploymentId': '111', 'tenantId': null
},
{
id: 2, defaultAppId: null, name: 'health-care-Fake', description: 'desc-fake2', modelId: 33,
theme: 'theme-2-fake', icon: 'glyphicon-asterisk', 'deploymentId': '444', 'tenantId': null
}
]
};

View File

@@ -0,0 +1,42 @@
/*!
* @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 { CommentProcessModel } from '../models/comment-process.model';
import { UserProcessModel } from '../models/user-process.model';
export let fakeUser1 = { id: 1, email: 'fake-email@dom.com', firstName: 'firstName', lastName: 'lastName' };
export let fakeUser2 = { id: 1001, email: 'some-one@somegroup.com', firstName: 'some', lastName: 'one' };
export let fakeTasksComment = {
size: 2, total: 2, start: 0,
data: [
{
id: 1, message: 'fake-message-1', created: '', createdBy: fakeUser1
},
{
id: 2, message: 'fake-message-2', created: '', createdBy: fakeUser1
}
]
};
export let fakeProcessComment = new CommentProcessModel({id: 1, message: 'Test', created: new Date('2016-11-10T03:37:30.010+0000'), createdBy: new UserProcessModel({
id: 13,
firstName: 'Wilbur',
lastName: 'Adams',
email: 'wilbur@app.com'
}));

View File

@@ -22,10 +22,7 @@ import { MaterialModule } from '../../material.module';
import { InfoDrawerLayoutComponent } from './info-drawer-layout.component';
import { InfoDrawerComponent } from './info-drawer.component';
declare let jasmine: any;
describe('InfoDrawerComponent', () => {
let componentHandler: any;
let debugElement: DebugElement;
let element: HTMLElement;
let component: InfoDrawerComponent;
@@ -48,11 +45,6 @@ describe('InfoDrawerComponent', () => {
component = fixture.componentInstance;
element = fixture.nativeElement;
debugElement = fixture.debugElement;
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered',
'upgradeElement'
]);
window['componentHandler'] = componentHandler;
});
it('should create instance of InfoDrawerComponent', () => {

View File

@@ -15,25 +15,20 @@
* limitations under the License.
*/
/**
*
* This object represent the comment of a task.
*
*
* @returns {Comment} .
*/
import { LightUserRepresentation } from 'ng2-alfresco-core';
import { CommentRepresentation, LightUserRepresentation } from 'alfresco-js-api';
export class Comment {
export class CommentProcessModel implements CommentRepresentation {
id: number;
message: string;
created: string;
created: Date;
createdBy: LightUserRepresentation;
constructor(id: number, message: string, created: string, createdBy: LightUserRepresentation) {
this.id = id;
this.message = message;
this.created = created;
this.createdBy = createdBy;
constructor(obj?: any) {
if (obj) {
this.id = obj.id;
this.message = obj.message;
this.created = obj.created;
this.createdBy = obj.createdBy;
}
}
}

View File

@@ -19,12 +19,14 @@
* This object represent the process service user.*
*/
export class LightUserRepresentation {
id: number;
email: string;
firstName: string;
lastName: string;
pictureId: number = null;
import { LightUserRepresentation } from 'alfresco-js-api';
export class UserProcessModel implements LightUserRepresentation {
id?: number;
email?: string;
firstName?: string;
lastName?: string;
pictureId?: number = null;
constructor(obj?: any) {
if (obj) {

View File

@@ -16,7 +16,7 @@
*/
import { DomSanitizer } from '@angular/platform-browser';
import { LightUserRepresentation } from '../models/user-process.model';
import { UserProcessModel } from '../models/user-process.model';
import { InitialUsernamePipe } from './user-initial.pipe';
class FakeSanitazer extends DomSanitizer {
@@ -53,11 +53,11 @@ class FakeSanitazer extends DomSanitizer {
describe('UserInitialPipe', () => {
let pipe: InitialUsernamePipe;
let fakeUser: LightUserRepresentation;
let fakeUser: UserProcessModel;
beforeEach(() => {
pipe = new InitialUsernamePipe(new FakeSanitazer());
fakeUser = new LightUserRepresentation();
fakeUser = new UserProcessModel();
});
it('should return a div with the user initials', () => {

View File

@@ -17,7 +17,7 @@
import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { LightUserRepresentation } from '../models/user-process.model';
import { UserProcessModel } from '../models/user-process.model';
@Pipe({
name: 'usernameInitials'
@@ -26,7 +26,7 @@ export class InitialUsernamePipe implements PipeTransform {
constructor(private sanitized: DomSanitizer) {}
transform(user: LightUserRepresentation, className: string = '', delimiter: string = ''): SafeHtml {
transform(user: UserProcessModel, className: string = '', delimiter: string = ''): SafeHtml {
let result: SafeHtml = '';
if (user) {
let initialResult = this.getInitialUserName(user.firstName, user.lastName, delimiter);

View File

@@ -0,0 +1,113 @@
/*!
* @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 { TestBed } from '@angular/core/testing';
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
import { fakeApps } from '../assets/apps-service.mock';
import { AlfrescoApiService } from './alfresco-api.service';
import { AppConfigService } from './app-config.service';
import { AppsProcessService } from './apps-process.service';
import { LogService } from './log.service';
import { StorageService } from './storage.service';
declare let jasmine: any;
describe('Apps Service', () => {
let service: AppsProcessService;
beforeEach((() => {
TestBed.configureTestingModule({
providers: [
AppsProcessService,
AlfrescoApiService,
StorageService,
LogService,
{provide: AppConfigService, useClass: AppConfigServiceMock}
]
}).compileComponents();
}));
beforeEach(() => {
service = TestBed.get(AppsProcessService);
});
beforeEach(() => {
jasmine.Ajax.install();
});
afterEach(() => {
jasmine.Ajax.uninstall();
});
it('should get the deployed apps ', (done) => {
service.getDeployedApplications().subscribe(
(res: any) => {
expect(res).toBeDefined();
expect(res.length).toEqual(2);
expect(res[0].name).toEqual('Sales-Fakes-App');
expect(res[0].description).toEqual('desc-fake1');
expect(res[0].deploymentId).toEqual('111');
expect(res[1].name).toEqual('health-care-Fake');
expect(res[1].description).toEqual('desc-fake2');
expect(res[1].deploymentId).toEqual('444');
done();
}
);
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeApps)
});
});
it('should get the filter deployed app ', (done) => {
service.getDeployedApplicationsByName('health-care-Fake').subscribe(
(res: any) => {
expect(res).toBeDefined();
expect(res.name).toEqual('health-care-Fake');
expect(res.description).toEqual('desc-fake2');
expect(res.deploymentId).toEqual('444');
done();
}
);
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeApps)
});
});
it('should get the deployed app details by id ', (done) => {
service.getApplicationDetailsById(1).subscribe(
(app: any) => {
expect(app).toBeDefined();
expect(app.name).toEqual('Sales-Fakes-App');
expect(app.description).toEqual('desc-fake1');
expect(app.deploymentId).toEqual('111');
done();
}
);
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeApps)
});
});
});

View File

@@ -0,0 +1,60 @@
/*!
* @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 { Injectable } from '@angular/core';
import { AppDefinitionRepresentation } from 'alfresco-js-api';
import { Observable } from 'rxjs/Rx';
import { AlfrescoApiService } from './alfresco-api.service';
import { LogService } from './log.service';
@Injectable()
export class AppsProcessService {
constructor(private apiService: AlfrescoApiService,
private logService: LogService) {
}
getDeployedApplications(): Observable<AppDefinitionRepresentation[]> {
return Observable.fromPromise(this.apiService.getInstance().activiti.appsApi.getAppDefinitions())
.map((response: any) => {
return response.data;
})
.catch(err => this.handleError(err));
}
getDeployedApplicationsByName(name: string): Observable<AppDefinitionRepresentation> {
return Observable.fromPromise(this.apiService.getInstance().activiti.appsApi.getAppDefinitions())
.map((response: any) => {
return response.data.find(app => app.name === name);
})
.catch(err => this.handleError(err));
}
getApplicationDetailsById(appId: number): Observable<AppDefinitionRepresentation> {
return Observable.fromPromise(this.apiService.getInstance().activiti.appsApi.getAppDefinitions())
.map((response: any) => {
return response.data.find(app => app.id === appId);
})
.catch(err => this.handleError(err));
}
private handleError(error: any) {
this.logService.error(error);
return Observable.throw(error || 'Server error');
}
}

View File

@@ -0,0 +1,194 @@
/*!
* @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 { async, TestBed } from '@angular/core/testing';
import { CommentProcessModel } from 'ng2-alfresco-core';
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
import { fakeProcessComment, fakeTasksComment, fakeUser1 } from '../assets/comment-process-service.mock';
import { AlfrescoApiService } from './alfresco-api.service';
import { AppConfigService } from './app-config.service';
import { CommentProcessService } from './comment-process.service';
import { LogService } from './log.service';
import { StorageService } from './storage.service';
declare let jasmine: any;
describe('Comment ProcessService Service', () => {
let service: CommentProcessService;
let alfrescoApi: any;
beforeEach((() => {
TestBed.configureTestingModule({
providers: [
CommentProcessService,
AlfrescoApiService,
StorageService,
LogService,
{provide: AppConfigService, useClass: AppConfigServiceMock}
]
}).compileComponents();
}));
beforeEach(() => {
service = TestBed.get(CommentProcessService);
alfrescoApi = TestBed.get(AlfrescoApiService).getInstance();
});
beforeEach(() => {
jasmine.Ajax.install();
});
afterEach(() => {
jasmine.Ajax.uninstall();
});
describe('Process comments', () => {
const processId = '1001';
describe('get comments', () => {
let getProcessInstanceComments: jasmine.Spy;
beforeEach(() => {
getProcessInstanceComments = spyOn(alfrescoApi.activiti.commentsApi, 'getProcessInstanceComments')
.and
.returnValue(Promise.resolve({data: [fakeProcessComment, fakeProcessComment]}));
});
it('should return the correct number of comments', async(() => {
service.getProcessInstanceComments(processId).subscribe((tasks) => {
expect(tasks.length).toBe(2);
});
}));
it('should return the correct comment data', async(() => {
service.getProcessInstanceComments(processId).subscribe((comments) => {
let comment: any = comments[0];
expect(comment.id).toBe(fakeProcessComment.id);
expect(comment.created).toBe(fakeProcessComment.created);
expect(comment.message).toBe(fakeProcessComment.message);
expect(comment.createdBy.id).toBe(fakeProcessComment.createdBy.id);
});
}));
it('should call service to fetch process instance comments', () => {
service.getProcessInstanceComments(processId);
expect(getProcessInstanceComments).toHaveBeenCalledWith(processId);
});
it('should return a default error if no data is returned by the API', async(() => {
getProcessInstanceComments = getProcessInstanceComments.and.returnValue(Promise.reject(null));
service.getProcessInstanceComments(processId).subscribe(
() => {
},
(res) => {
expect(res).toBe('Server error');
}
);
}));
});
describe('add comment', () => {
const message = 'Test message';
let addProcessInstanceComment: jasmine.Spy;
beforeEach(() => {
addProcessInstanceComment = spyOn(alfrescoApi.activiti.commentsApi, 'addProcessInstanceComment')
.and
.returnValue(Promise.resolve(fakeProcessComment));
});
it('should call service to add comment', () => {
service.addProcessInstanceComment(processId, message);
expect(addProcessInstanceComment).toHaveBeenCalledWith({
message: message
}, processId);
});
it('should return the created comment', async(() => {
service.addProcessInstanceComment(processId, message).subscribe((comment) => {
expect(comment.id).toBe(fakeProcessComment.id);
expect(comment.created).toBe(fakeProcessComment.created);
expect(comment.message).toBe(fakeProcessComment.message);
expect(comment.createdBy).toBe(fakeProcessComment.createdBy);
});
}));
it('should return a default error if no data is returned by the API', async(() => {
addProcessInstanceComment = addProcessInstanceComment.and.returnValue(Promise.reject(null));
service.addProcessInstanceComment(processId, message).subscribe(
() => {
},
(res) => {
expect(res).toBe('Server error');
}
);
}));
});
});
describe('Task comments', () => {
it('should add a comment task ', (done) => {
service.addTaskComment('999', 'fake-comment-message').subscribe(
(res: CommentProcessModel) => {
expect(res).toBeDefined();
expect(res.id).not.toEqual('');
expect(res.message).toEqual('fake-comment-message');
expect(res.created).not.toEqual('');
expect(res.createdBy.email).toEqual('fake-email@dom.com');
expect(res.createdBy.firstName).toEqual('firstName');
expect(res.createdBy.lastName).toEqual('lastName');
done();
}
);
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
contentType: 'application/json',
responseText: JSON.stringify({
id: '111', message: 'fake-comment-message',
createdBy: fakeUser1,
created: '2016-07-15T11:19:17.440+0000'
})
});
});
it('should return the tasks comments ', (done) => {
service.getTaskComments('999').subscribe(
(res: CommentProcessModel[]) => {
expect(res).toBeDefined();
expect(res.length).toEqual(2);
expect(res[0].message).toEqual('fake-message-1');
expect(res[1].message).toEqual('fake-message-2');
done();
}
);
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeTasksComment)
});
});
});
});

View File

@@ -0,0 +1,82 @@
/*!
* @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 { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx';
import { CommentProcessModel } from '../models/comment-process.model';
import { UserProcessModel } from '../models/user-process.model';
import { AlfrescoApiService } from './alfresco-api.service';
import { LogService } from './log.service';
@Injectable()
export class CommentProcessService {
constructor(private apiService: AlfrescoApiService,
private logService: LogService) {
}
addTaskComment(taskId: string, message: string): Observable<CommentProcessModel> {
return Observable.fromPromise(this.apiService.getInstance().activiti.taskApi.addTaskComment({message: message}, taskId))
.map(res => res)
.map((response: CommentProcessModel) => {
return new CommentProcessModel({id: response.id, message: response.message, created: response.created, createdBy: response.createdBy});
}).catch(err => this.handleError(err));
}
getTaskComments(taskId: string): Observable<CommentProcessModel[]> {
return Observable.fromPromise(this.apiService.getInstance().activiti.taskApi.getTaskComments(taskId))
.map(res => res)
.map((response: any) => {
let comments: CommentProcessModel[] = [];
response.data.forEach((comment: CommentProcessModel) => {
let user = new UserProcessModel(comment.createdBy);
comments.push(new CommentProcessModel({id: comment.id, message: comment.message, created: comment.created, createdBy: user}));
});
return comments;
}).catch(err => this.handleError(err));
}
getProcessInstanceComments(processInstanceId: string): Observable<CommentProcessModel[]> {
return Observable.fromPromise(this.apiService.getInstance().activiti.commentsApi.getProcessInstanceComments(processInstanceId))
.map(res => res)
.map((response: any) => {
let comments: CommentProcessModel[] = [];
response.data.forEach((comment: CommentProcessModel) => {
let user = new UserProcessModel(comment.createdBy);
comments.push(new CommentProcessModel({id: comment.id, message: comment.message, created: comment.created, createdBy: user}));
});
return comments;
}).catch(err => this.handleError(err));
}
addProcessInstanceComment(processInstanceId: string, message: string): Observable<CommentProcessModel> {
return Observable.fromPromise(
this.apiService.getInstance().activiti.commentsApi.addProcessInstanceComment({ message: message }, processInstanceId)
)
.map((response: CommentProcessModel) => {
return new CommentProcessModel({id: response.id, message: response.message, created: response.created, createdBy: response.createdBy});
}).catch(err => this.handleError(err));
}
private handleError(error: any) {
this.logService.error(error);
return Observable.throw(error || 'Server error');
}
}

View File

@@ -16,8 +16,8 @@
*/
import { TestBed } from '@angular/core/testing';
import { UserProcessModel } from 'ng2-alfresco-core';
import { AppConfigServiceMock } from '../assets/app-config.service.mock';
import { LightUserRepresentation } from '../models/user-process.model';
import { AlfrescoApiService } from './alfresco-api.service';
import { AppConfigService } from './app-config.service';
import { LogService } from './log.service';
@@ -26,21 +26,21 @@ import { StorageService } from './storage.service';
declare let jasmine: any;
const firstInvolvedUser: LightUserRepresentation = new LightUserRepresentation({
const firstInvolvedUser: UserProcessModel = new UserProcessModel({
id: '1',
email: 'fake-user1@fake.com',
firstName: 'fakeName1',
lastName: 'fakeLast1'
});
const secondInvolvedUser: LightUserRepresentation = new LightUserRepresentation({
const secondInvolvedUser: UserProcessModel = new UserProcessModel({
id: '2',
email: 'fake-user2@fake.com',
firstName: 'fakeName2',
lastName: 'fakeLast2'
});
const fakeInvolveUserList: LightUserRepresentation[] = [firstInvolvedUser, secondInvolvedUser];
const fakeInvolveUserList: UserProcessModel[] = [firstInvolvedUser, secondInvolvedUser];
describe('PeopleProcessService', () => {
@@ -71,7 +71,7 @@ describe('PeopleProcessService', () => {
it('should be able to retrieve people to involve in the task', (done) => {
service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe(
(users: LightUserRepresentation[]) => {
(users: UserProcessModel[]) => {
expect(users).toBeDefined();
expect(users.length).toBe(2);
expect(users[0].id).toEqual('1');
@@ -89,7 +89,7 @@ describe('PeopleProcessService', () => {
it('should be able to get people images for people retrieved', (done) => {
service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe(
(users: LightUserRepresentation[]) => {
(users: UserProcessModel[]) => {
expect(users).toBeDefined();
expect(users.length).toBe(2);
expect(service.getUserImage(users[0])).toContain('/users/' + users[0].id + '/picture');
@@ -111,7 +111,7 @@ describe('PeopleProcessService', () => {
it('should return empty list when there are no users to involve', (done) => {
service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe(
(users: LightUserRepresentation[]) => {
(users: UserProcessModel[]) => {
expect(users).toBeDefined();
expect(users.length).toBe(0);
done();

View File

@@ -18,7 +18,7 @@
import { Injectable } from '@angular/core';
import { Response } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { LightUserRepresentation } from '../models/user-process.model';
import { UserProcessModel } from '../models/user-process.model';
import { AlfrescoApiService } from './alfresco-api.service';
import { LogService } from './log.service';
@@ -29,24 +29,24 @@ export class PeopleProcessService {
private logService: LogService) {
}
getWorkflowUsers(taskId?: string, searchWord?: string): Observable<LightUserRepresentation[]> {
getWorkflowUsers(taskId?: string, searchWord?: string): Observable<UserProcessModel[]> {
let option = { excludeTaskId: taskId, filter: searchWord };
return Observable.fromPromise(this.getWorkflowUserApi(option))
.map((response: any) => <LightUserRepresentation[]> response.data || [])
.map((response: any) => <UserProcessModel[]> response.data || [])
.catch(err => this.handleError(err));
}
getUserImage(user: LightUserRepresentation): string {
return this.getUserProfileImageApi(user.id + '');
getUserImage(user: UserProcessModel): string {
return this.getUserProfileImageApi(user.id);
}
involveUserWithTask(taskId: string, idToInvolve: string): Observable<LightUserRepresentation[]> {
involveUserWithTask(taskId: string, idToInvolve: string): Observable<UserProcessModel[]> {
let node = {userId: idToInvolve};
return Observable.fromPromise(this.involveUserToTaskApi(taskId, node))
.catch(err => this.handleError(err));
}
removeInvolvedUser(taskId: string, idToRemove: string): Observable<LightUserRepresentation[]> {
removeInvolvedUser(taskId: string, idToRemove: string): Observable<UserProcessModel[]> {
let node = {userId: idToRemove};
return Observable.fromPromise(this.removeInvolvedUserFromTaskApi(taskId, node))
.catch(err => this.handleError(err));
@@ -64,7 +64,7 @@ export class PeopleProcessService {
return this.alfrescoJsApi.getInstance().activiti.taskActionsApi.removeInvolvedUser(taskId, node);
}
private getUserProfileImageApi(userId: string) {
private getUserProfileImageApi(userId: number) {
return this.alfrescoJsApi.getInstance().activiti.userApi.getUserProfilePictureUrl(userId);
}

View File

@@ -108,12 +108,7 @@ describe('SearchComponent', () => {
}
};
let componentHandler;
beforeEach(async(() => {
componentHandler = jasmine.createSpyObj('componentHandler', ['upgradeAllRegistered', 'upgradeElement']);
window['componentHandler'] = componentHandler;
TestBed.configureTestingModule({
imports: [
CoreModule,

View File

@@ -74,8 +74,6 @@ describe('UploadButtonComponent', () => {
}));
beforeEach(() => {
window['componentHandler'] = null;
fixture = TestBed.createComponent(UploadButtonComponent);
uploadService = TestBed.get(UploadService);
contentService = TestBed.get(AlfrescoContentService);

View File

@@ -41,11 +41,8 @@ describe('User info component', () => {
let element: HTMLElement;
let stubAuthService: AlfrescoAuthenticationService;
let stubContent: AlfrescoContentService;
let componentHandler;
beforeEach(async(() => {
componentHandler = jasmine.createSpyObj('componentHandler', ['upgradeAllRegistered', 'upgradeElement']);
window['componentHandler'] = componentHandler;
TestBed.configureTestingModule({
imports: [
CoreModule,

View File

@@ -15,11 +15,13 @@
* limitations under the License.
*/
export class BpmUserModel {
import { UserRepresentation } from 'alfresco-js-api';
export class BpmUserModel implements UserRepresentation {
apps: any;
capabilities: string;
capabilities: string[];
company: string;
created: string;
created: Date;
email: string;
externalId: string;
firstName: string;
@@ -28,14 +30,14 @@ export class BpmUserModel {
fullNameDisplay: string;
groups: any;
id: string;
lastUpdate: string;
latestSyncTimeStamp: string;
lastUpdate: Date;
latestSyncTimeStamp: Date;
password: string;
pictureId: string;
pictureId: number;
status: string;
tenantId: string;
tenantId: number;
tenantName: string;
tenantPictureId: string;
tenantPictureId: number;
type: string;
constructor(obj?: any) {