[ACS-7420] cleanup process types (#9709)

This commit is contained in:
Denys Vuika
2024-05-21 12:03:57 -04:00
committed by GitHub
parent 07370d963f
commit ff6a92a471
31 changed files with 344 additions and 434 deletions

View File

@@ -20,6 +20,7 @@ import {
LightUserRepresentation,
ProcessInstanceRepresentation,
RestVariable,
TaskRepresentation,
UserRepresentation,
UserTaskFilterRepresentation
} from '@alfresco/js-api';
@@ -45,4 +46,7 @@ export type UserProcessModel = LightUserRepresentation;
/** @deprecated use js-api/RestVariable instead */
export type ProcessInstanceVariable = RestVariable;
/** @deprecated use js-api/TaskRepresentation instead */
export type TaskDetailsModel = TaskRepresentation;
export { ProcessDefinitionRepresentation } from '@alfresco/js-api';

View File

@@ -15,10 +15,9 @@
* limitations under the License.
*/
import { UserRepresentation } from '@alfresco/js-api';
import { TaskDetailsModel } from '../../task-list/models/task-details.model';
import { TaskRepresentation, UserRepresentation } from '@alfresco/js-api';
export const standaloneTaskWithoutForm = new TaskDetailsModel({
export const standaloneTaskWithoutForm = new TaskRepresentation({
id: '200',
name: 'Standalone Task Without Form',
description: null,
@@ -29,7 +28,7 @@ export const standaloneTaskWithoutForm = new TaskDetailsModel({
lastName: 'Adams',
email: 'wilbur@app.activiti.com'
},
created: '2016-11-03T15:25:42.749+0000',
created: new Date('2016-11-03T15:25:42.749+0000'),
dueDate: null,
endDate: null,
duration: null,
@@ -58,7 +57,7 @@ export const standaloneTaskWithoutForm = new TaskDetailsModel({
memberOfCandidateGroup: false
});
export const completedStandaloneTaskWithoutForm = new TaskDetailsModel({
export const completedStandaloneTaskWithoutForm = new TaskRepresentation({
id: '200',
name: 'Standalone Task Without Form',
description: null,
@@ -69,7 +68,7 @@ export const completedStandaloneTaskWithoutForm = new TaskDetailsModel({
lastName: 'Adams',
email: 'wilbur@app.activiti.com'
},
created: '2016-11-03T15:25:42.749+0000',
created: new Date('2016-11-03T15:25:42.749+0000'),
dueDate: null,
endDate: new Date(),
duration: null,
@@ -98,7 +97,7 @@ export const completedStandaloneTaskWithoutForm = new TaskDetailsModel({
memberOfCandidateGroup: false
});
export const taskDetailsMock = new TaskDetailsModel({
export const taskDetailsMock = new TaskRepresentation({
id: '91',
name: 'Request translation',
description: null,
@@ -109,7 +108,7 @@ export const taskDetailsMock = new TaskDetailsModel({
lastName: 'Adams',
email: 'wilbur@app.activiti.com'
},
created: '2016-11-03T15:25:42.749+0000',
created: new Date('2016-11-03T15:25:42.749+0000'),
dueDate: null,
endDate: null,
duration: null,
@@ -138,13 +137,13 @@ export const taskDetailsMock = new TaskDetailsModel({
memberOfCandidateGroup: false
});
export const initiatorCanCompleteTaskDetailsMock = new TaskDetailsModel({
export const initiatorCanCompleteTaskDetailsMock = new TaskRepresentation({
id: '91',
name: 'Request translation',
description: null,
category: null,
assignee: { email: 'mock-user-email' },
created: '2016-11-03T15:25:42.749+0000',
created: new Date('2016-11-03T15:25:42.749+0000'),
dueDate: null,
endDate: null,
duration: null,
@@ -173,13 +172,13 @@ export const initiatorCanCompleteTaskDetailsMock = new TaskDetailsModel({
memberOfCandidateGroup: false
});
export const initiatorWithCandidatesTaskDetailsMock = new TaskDetailsModel({
export const initiatorWithCandidatesTaskDetailsMock = new TaskRepresentation({
id: '91',
name: 'Request translation',
description: null,
category: null,
assignee: null,
created: '2016-11-03T15:25:42.749+0000',
created: new Date('2016-11-03T15:25:42.749+0000'),
dueDate: null,
endDate: null,
duration: null,
@@ -221,13 +220,13 @@ export const initiatorWithCandidatesTaskDetailsMock = new TaskDetailsModel({
memberOfCandidateGroup: true
});
export const taskDetailsWithOutAssigneeMock = new TaskDetailsModel({
export const taskDetailsWithOutAssigneeMock = new TaskRepresentation({
id: '91',
name: 'Request translation',
description: null,
category: null,
assignee: undefined,
created: '2016-11-03T15:25:42.749+0000',
created: new Date('2016-11-03T15:25:42.749+0000'),
dueDate: null,
endDate: null,
duration: null,
@@ -256,13 +255,13 @@ export const taskDetailsWithOutAssigneeMock = new TaskDetailsModel({
memberOfCandidateGroup: false
});
export const claimableTaskDetailsMock = new TaskDetailsModel({
export const claimableTaskDetailsMock = new TaskRepresentation({
id: '91',
name: 'Request translation',
description: null,
category: null,
assignee: null,
created: '2016-11-03T15:25:42.749+0000',
created: new Date('2016-11-03T15:25:42.749+0000'),
dueDate: null,
endDate: null,
duration: null,
@@ -296,7 +295,7 @@ export const claimableTaskDetailsMock = new TaskDetailsModel({
memberOfCandidateUsers: false
});
export const claimedTaskDetailsMock = new TaskDetailsModel({
export const claimedTaskDetailsMock = new TaskRepresentation({
id: '91',
name: 'Request translation',
description: null,
@@ -307,7 +306,7 @@ export const claimedTaskDetailsMock = new TaskDetailsModel({
lastName: 'Adams',
email: 'wilbur@app.activiti.com'
},
created: '2016-11-03T15:25:42.749+0000',
created: new Date('2016-11-03T15:25:42.749+0000'),
dueDate: null,
endDate: null,
duration: null,
@@ -349,7 +348,7 @@ export const claimedTaskDetailsMock = new TaskDetailsModel({
memberOfCandidateUsers: true
});
export const claimedByGroupMemberMock = new TaskDetailsModel({
export const claimedByGroupMemberMock = new TaskRepresentation({
id: '91',
name: 'Request translation',
description: null,
@@ -360,7 +359,7 @@ export const claimedByGroupMemberMock = new TaskDetailsModel({
lastName: 'fake-last-name',
email: 'fake@app.activiti.com'
},
created: '2016-11-03T15:25:42.749+0000',
created: new Date('2016-11-03T15:25:42.749+0000'),
dueDate: null,
endDate: null,
duration: null,
@@ -399,7 +398,7 @@ export const claimedByGroupMemberMock = new TaskDetailsModel({
memberOfCandidateUsers: true
});
export const taskDetailsWithOutCandidateGroup = new TaskDetailsModel({
export const taskDetailsWithOutCandidateGroup = new TaskRepresentation({
id: '91',
name: 'Request translation',
description: null,
@@ -410,7 +409,7 @@ export const taskDetailsWithOutCandidateGroup = new TaskDetailsModel({
lastName: 'Adams',
email: 'wilbur@app.activiti.com'
},
created: '2016-11-03T15:25:42.749+0000',
created: new Date('2016-11-03T15:25:42.749+0000'),
dueDate: null,
endDate: null,
duration: null,
@@ -441,7 +440,7 @@ export const taskDetailsWithOutCandidateGroup = new TaskDetailsModel({
]
});
export const completedTaskWithFormMock = new TaskDetailsModel({
export const completedTaskWithFormMock = new TaskRepresentation({
id: '91',
name: 'Request translation',
description: null,
@@ -452,7 +451,7 @@ export const completedTaskWithFormMock = new TaskDetailsModel({
lastName: 'Adams',
email: 'wilbur@app.activiti.com'
},
created: '2016-11-03T15:25:42.749+0000',
created: new Date('2016-11-03T15:25:42.749+0000'),
dueDate: null,
endDate: new Date(),
duration: null,
@@ -471,7 +470,7 @@ export const completedTaskWithFormMock = new TaskDetailsModel({
memberOfCandidateUsers: false
});
export const completedTaskDetailsMock = new TaskDetailsModel({
export const completedTaskDetailsMock = new TaskRepresentation({
id: '91',
name: 'Request translation',
description: null,
@@ -482,7 +481,7 @@ export const completedTaskDetailsMock = new TaskDetailsModel({
lastName: 'Adams',
email: 'wilbur@app.activiti.com'
},
created: '2016-11-03T15:25:42.749+0000',
created: new Date('2016-11-03T15:25:42.749+0000'),
dueDate: null,
endDate: new Date(),
duration: null,
@@ -501,14 +500,14 @@ export const completedTaskDetailsMock = new TaskDetailsModel({
memberOfCandidateUsers: false
});
export const taskDetailsWithOutFormMock = new TaskDetailsModel({
export const taskDetailsWithOutFormMock = new TaskRepresentation({
id: '91',
name: 'Request translation',
description: 'fake description',
category: null,
assignee: { id: 1001, firstName: 'Admin', lastName: 'Paul', email: 'fake-email@gmail.com' },
created: '2016-11-03T15:25:42.749+0000',
dueDate: '2016-11-03T15:25:42.749+0000',
created: new Date('2016-11-03T15:25:42.749+0000'),
dueDate: new Date('2016-11-03T15:25:42.749+0000'),
endDate: null,
duration: null,
priority: 50,
@@ -791,20 +790,20 @@ export const taskFormMock = {
globalDateFormat: 'D-M-YYYY'
};
export const tasksMock = [new TaskDetailsModel(taskDetailsMock)];
export const tasksMock = [taskDetailsMock];
export const noDataMock = [
new TaskDetailsModel({
id: 1005,
export const noDataMock: any[] = [
{
id: '1005',
message: 'example-message',
created: '2017-10-06T11:54:53.443+0000',
created: new Date('2017-10-06T11:54:53.443+0000'),
createdBy: {
id: 4004,
firstName: 'gadget',
lastName: 'inspector',
email: 'gadget@inspector.com'
}
})
}
];
export const involvedUserTaskForm = {
@@ -935,7 +934,7 @@ export const fakeUser = new UserRepresentation({
tenantName: 'abc'
});
export const completedProcessTaskWithoutForm = new TaskDetailsModel({
export const completedProcessTaskWithoutForm = new TaskRepresentation({
id: '49',
name: 'process task without form',
description: null,
@@ -946,9 +945,9 @@ export const completedProcessTaskWithoutForm = new TaskDetailsModel({
lastName: 'User',
email: 'hruser@example.com'
},
created: '2021-07-08T07:39:27.046+0000',
created: new Date('2021-07-08T07:39:27.046+0000'),
dueDate: null,
endDate: '2021-07-08T07:39:35.817+0000',
endDate: new Date('2021-07-08T07:39:35.817+0000'),
duration: 8771,
priority: 0,
parentTaskId: null,

View File

@@ -19,7 +19,6 @@ import { SimpleChange } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { of } from 'rxjs';
import { TaskDetailsModel } from '../../task-list';
import { taskDetailsMock } from '../../mock';
import { ProcessService } from './../services/process.service';
import { ProcessInstanceTasksComponent } from './process-instance-tasks.component';
@@ -27,7 +26,7 @@ import { ProcessTestingModule } from '../../testing/process.testing.module';
import { HarnessLoader } from '@angular/cdk/testing';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { MatListItemHarness } from '@angular/material/list/testing';
import { ProcessInstanceRepresentation } from '@alfresco/js-api';
import { ProcessInstanceRepresentation, TaskRepresentation } from '@alfresco/js-api';
describe('ProcessInstanceTasksComponent', () => {
let component: ProcessInstanceTasksComponent;
@@ -46,7 +45,7 @@ describe('ProcessInstanceTasksComponent', () => {
component = fixture.componentInstance;
loader = TestbedHarnessEnvironment.loader(fixture);
spyOn(processService, 'getProcessTasks').and.returnValue(of([new TaskDetailsModel(taskDetailsMock)]));
spyOn(processService, 'getProcessTasks').and.returnValue(of([new TaskRepresentation(taskDetailsMock)]));
});
it('should initially render message about no active tasks if no process instance ID provided', () => {

View File

@@ -19,10 +19,10 @@ import { DatePipe } from '@angular/common';
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild, OnDestroy } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Observable, Observer, Subject } from 'rxjs';
import { TaskDetailsEvent, TaskDetailsModel } from '../../task-list';
import { TaskDetailsEvent } from '../../task-list';
import { ProcessService } from './../services/process.service';
import { share, takeUntil } from 'rxjs/operators';
import { ProcessInstanceRepresentation } from '@alfresco/js-api';
import { ProcessInstanceRepresentation, TaskRepresentation } from '@alfresco/js-api';
@Component({
selector: 'adf-process-instance-tasks',
@@ -55,20 +55,20 @@ export class ProcessInstanceTasksComponent implements OnInit, OnChanges, OnDestr
@Output()
taskClick = new EventEmitter<TaskDetailsEvent>();
activeTasks: TaskDetailsModel[] = [];
completedTasks: TaskDetailsModel[] = [];
task$: Observable<TaskDetailsModel>;
completedTask$: Observable<TaskDetailsModel>;
activeTasks: TaskRepresentation[] = [];
completedTasks: TaskRepresentation[] = [];
task$: Observable<TaskRepresentation>;
completedTask$: Observable<TaskRepresentation>;
message: string;
processId: string;
private taskObserver: Observer<TaskDetailsModel>;
private completedTaskObserver: Observer<TaskDetailsModel>;
private taskObserver: Observer<TaskRepresentation>;
private completedTaskObserver: Observer<TaskRepresentation>;
private onDestroy$ = new Subject<boolean>();
constructor(private processService: ProcessService, private dialog: MatDialog) {
this.task$ = new Observable<TaskDetailsModel>((observer) => (this.taskObserver = observer)).pipe(share());
this.completedTask$ = new Observable<TaskDetailsModel>((observer) => (this.completedTaskObserver = observer)).pipe(share());
this.task$ = new Observable<TaskRepresentation>((observer) => (this.taskObserver = observer)).pipe(share());
this.completedTask$ = new Observable<TaskRepresentation>((observer) => (this.completedTaskObserver = observer)).pipe(share());
}
ngOnInit() {
@@ -150,7 +150,7 @@ export class ProcessInstanceTasksComponent implements OnInit, OnChanges, OnDestr
}
}
clickTask(task: TaskDetailsModel) {
clickTask(task: TaskRepresentation) {
const args = new TaskDetailsEvent(task);
this.taskClick.emit(args);
}

View File

@@ -20,22 +20,21 @@ import { exampleProcess } from '../../mock';
import { ProcessService } from './process.service';
import { CoreModule, DateFnsUtils } from '@alfresco/adf-core';
import { ProcessTestingModule } from '../../testing/process.testing.module';
import { ProcessInstanceQueryRepresentation, ProcessDefinitionRepresentation, RestVariable } from '@alfresco/js-api';
import { TaskDetailsModel } from '@alfresco/adf-process-services';
import { ProcessInstanceQueryRepresentation, ProcessDefinitionRepresentation, RestVariable, TaskRepresentation } from '@alfresco/js-api';
const fakeTasksList = {
data: [
new TaskDetailsModel({
id: 1,
new TaskRepresentation({
id: '1',
name: 'Task 1',
processInstanceId: 1000,
created: '2016-11-10T03:37:30.010+0000'
processInstanceId: '1000',
created: new Date('2016-11-10T03:37:30.010+0000')
}),
new TaskDetailsModel({
id: 2,
new TaskRepresentation({
id: '2',
name: 'Task 2',
processInstanceId: 1000,
created: '2016-11-10T03:37:30.010+0000'
processInstanceId: '1000',
created: new Date('2016-11-10T03:37:30.010+0000')
})
]
};

View File

@@ -16,7 +16,7 @@
*/
import { AlfrescoApiService, DateFnsUtils, FormValues } from '@alfresco/adf-core';
import { Injectable } from '@angular/core';
import { inject, Injectable } from '@angular/core';
import {
FormDefinitionRepresentation,
ProcessDefinitionsApi,
@@ -28,10 +28,10 @@ import {
RestVariable,
ResultListDataRepresentationProcessInstanceRepresentation,
TasksApi,
ProcessDefinitionRepresentation
ProcessDefinitionRepresentation,
TaskRepresentation
} from '@alfresco/js-api';
import { from, Observable } from 'rxjs';
import { TaskDetailsModel } from '../../task-list';
import { map } from 'rxjs/operators';
import { DatePipe } from '@angular/common';
@@ -39,6 +39,8 @@ import { DatePipe } from '@angular/common';
providedIn: 'root'
})
export class ProcessService {
private alfrescoApiService = inject(AlfrescoApiService);
private _tasksApi: TasksApi;
get tasksApi(): TasksApi {
return (this._tasksApi ||= new TasksApi(this.alfrescoApiService.getInstance()));
@@ -59,8 +61,6 @@ export class ProcessService {
return (this._processInstanceVariablesApi ||= new ProcessInstanceVariablesApi(this.alfrescoApiService.getInstance()));
}
constructor(private alfrescoApiService: AlfrescoApiService) {}
/**
* Gets process instances for a filter and optionally a process definition.
*
@@ -174,7 +174,7 @@ export class ProcessService {
* @param state Task state filter (can be "active" or "completed")
* @returns Array of task instance details
*/
getProcessTasks(processInstanceId: string, state?: string): Observable<TaskDetailsModel[]> {
getProcessTasks(processInstanceId: string, state?: string): Observable<TaskRepresentation[]> {
const taskOpts = state
? {
processInstanceId,

View File

@@ -17,11 +17,11 @@
import { SimpleChange } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { TaskDetailsModel } from '../models/task-details.model';
import { ChecklistComponent } from './checklist.component';
import { ProcessTestingModule } from '../../testing/process.testing.module';
import { TaskListService } from './../services/tasklist.service';
import { of } from 'rxjs';
import { TaskRepresentation } from '@alfresco/js-api';
describe('ChecklistComponent', () => {
let checklistComponent: ChecklistComponent;
@@ -37,7 +37,7 @@ describe('ChecklistComponent', () => {
service = TestBed.inject(TaskListService);
spyOn(service, 'getTaskChecklist').and.returnValue(
of([
new TaskDetailsModel({
new TaskRepresentation({
id: 'fake-check-changed-id',
name: 'fake-check-changed-name'
})
@@ -65,7 +65,7 @@ describe('ChecklistComponent', () => {
beforeEach(() => {
checklistComponent.taskId = 'fake-task-id';
checklistComponent.checklist.push(
new TaskDetailsModel({
new TaskRepresentation({
id: 'fake-check-id',
name: 'fake-check-name'
})
@@ -90,7 +90,7 @@ describe('ChecklistComponent', () => {
checklistComponent.taskId = 'fake-task-id';
checklistComponent.readOnly = false;
checklistComponent.checklist.push(
new TaskDetailsModel({
new TaskRepresentation({
id: 'fake-check-id',
name: 'fake-check-name'
})
@@ -148,7 +148,7 @@ describe('ChecklistComponent', () => {
it('should show task checklist', () => {
checklistComponent.checklist.push(
new TaskDetailsModel({
new TaskRepresentation({
id: 'fake-check-id',
name: 'fake-check-name'
})
@@ -160,16 +160,16 @@ describe('ChecklistComponent', () => {
it('should not show delete icon when checklist task is completed', () => {
checklistComponent.checklist.push(
new TaskDetailsModel({
new TaskRepresentation({
id: 'fake-check-id',
name: 'fake-check-name'
})
);
checklistComponent.checklist.push(
new TaskDetailsModel({
new TaskRepresentation({
id: 'fake-completed-id',
name: 'fake-completed-name',
endDate: '2018-05-23T11:25:14.552+0000'
endDate: new Date('2018-05-23T11:25:14.552+0000')
})
);
fixture.detectChanges();
@@ -182,7 +182,7 @@ describe('ChecklistComponent', () => {
it('should add checklist', async () => {
spyOn(service, 'addTask').and.returnValue(
of(
new TaskDetailsModel({
new TaskRepresentation({
id: 'fake-check-added-id',
name: 'fake-check-added-name'
})
@@ -205,7 +205,7 @@ describe('ChecklistComponent', () => {
checklistComponent.taskId = 'new-fake-task-id';
checklistComponent.checklist.push(
new TaskDetailsModel({
new TaskRepresentation({
id: 'fake-check-id',
name: 'fake-check-name'
})
@@ -229,7 +229,7 @@ describe('ChecklistComponent', () => {
spyOn(service, 'deleteTask').and.returnValue(of(null));
checklistComponent.taskId = 'new-fake-task-id';
checklistComponent.checklist.push(
new TaskDetailsModel({
new TaskRepresentation({
id: 'fake-check-id',
name: 'fake-check-name'
})
@@ -250,7 +250,7 @@ describe('ChecklistComponent', () => {
it('should show load task checklist on change', async () => {
checklistComponent.taskId = 'new-fake-task-id';
checklistComponent.checklist.push(
new TaskDetailsModel({
new TaskRepresentation({
id: 'fake-check-id',
name: 'fake-check-name'
})
@@ -271,7 +271,7 @@ describe('ChecklistComponent', () => {
it('should show empty checklist when task id is null', async () => {
checklistComponent.taskId = 'new-fake-task-id';
checklistComponent.checklist.push(
new TaskDetailsModel({
new TaskRepresentation({
id: 'fake-check-id',
name: 'fake-check-name'
})
@@ -294,9 +294,9 @@ describe('ChecklistComponent', () => {
});
it('should emit checklist task created event when the checklist is successfully added', (done) => {
spyOn(service, 'addTask').and.returnValue(of(new TaskDetailsModel({ id: 'fake-check-added-id', name: 'fake-check-added-name' })));
spyOn(service, 'addTask').and.returnValue(of(new TaskRepresentation({ id: 'fake-check-added-id', name: 'fake-check-added-name' })));
const disposableCreated = checklistComponent.checklistTaskCreated.subscribe((taskAdded: TaskDetailsModel) => {
const disposableCreated = checklistComponent.checklistTaskCreated.subscribe((taskAdded) => {
fixture.detectChanges();
expect(taskAdded.id).toEqual('fake-check-added-id');
expect(taskAdded.name).toEqual('fake-check-added-name');

View File

@@ -17,8 +17,8 @@
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges, ViewChild } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { TaskDetailsModel } from '../models/task-details.model';
import { TaskListService } from './../services/tasklist.service';
import { TaskRepresentation } from '@alfresco/js-api';
@Component({
selector: 'adf-checklist',
@@ -41,11 +41,11 @@ export class ChecklistComponent implements OnChanges {
/** (required) The assignee id that the subtasks are assigned to. */
@Input()
assignee: string;
assignee: number;
/** Emitted when a new checklist task is created. */
@Output()
checklistTaskCreated = new EventEmitter<TaskDetailsModel>();
checklistTaskCreated = new EventEmitter<TaskRepresentation>();
/** Emitted when a checklist task is deleted. */
@Output()
@@ -60,7 +60,7 @@ export class ChecklistComponent implements OnChanges {
taskName: string;
checklist: TaskDetailsModel[] = [];
checklist: TaskRepresentation[] = [];
constructor(private taskListService: TaskListService, private dialog: MatDialog) {}
@@ -95,7 +95,7 @@ export class ChecklistComponent implements OnChanges {
}
public add() {
const newTask = new TaskDetailsModel({
const newTask = new TaskRepresentation({
name: this.taskName,
parentTaskId: this.taskId,
assignee: { id: this.assignee }

View File

@@ -21,10 +21,10 @@ import { TaskListService } from '../services/tasklist.service';
import { StartTaskComponent } from './start-task.component';
import { ProcessTestingModule } from '../../testing/process.testing.module';
import { taskDetailsMock } from '../../mock/task/task-details.mock';
import { TaskDetailsModel } from '../models/task-details.model';
import { HarnessLoader } from '@angular/cdk/testing';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { MatButtonHarness } from '@angular/material/button/testing';
import { TaskRepresentation } from '@alfresco/js-api';
describe('StartTaskComponent', () => {
let component: StartTaskComponent;
@@ -99,7 +99,7 @@ describe('StartTaskComponent', () => {
it('should send on success event when the task is started', () => {
const successSpy = spyOn(component.success, 'emit');
component.taskDetailsModel = new TaskDetailsModel(taskDetailsMock);
component.taskDetailsModel = new TaskRepresentation(taskDetailsMock);
component.taskForm.controls['name'].setValue('fakeName');
fixture.detectChanges();
const createTaskButton = element.querySelector<HTMLElement>('#button-start');
@@ -124,7 +124,7 @@ describe('StartTaskComponent', () => {
it('should not emit success event when data not present', () => {
const successSpy = spyOn(component.success, 'emit');
component.taskDetailsModel = new TaskDetailsModel(null);
component.taskDetailsModel = new TaskRepresentation(null);
fixture.detectChanges();
const createTaskButton = element.querySelector<HTMLElement>('#button-start');
createTaskButton.click();
@@ -158,7 +158,7 @@ describe('StartTaskComponent', () => {
component.taskForm.controls['name'].setValue('fakeName');
component.taskForm.controls['formKey'].setValue(1204);
component.appId = 42;
component.taskDetailsModel = new TaskDetailsModel(taskDetailsMock);
component.taskDetailsModel = new TaskRepresentation(taskDetailsMock);
fixture.detectChanges();
const createTaskButton = element.querySelector<HTMLElement>('#button-start');
createTaskButton.click();
@@ -183,7 +183,7 @@ describe('StartTaskComponent', () => {
component.taskForm.controls['name'].setValue('fakeName');
component.taskForm.controls['formKey'].setValue(null);
component.appId = 42;
component.taskDetailsModel = new TaskDetailsModel(taskDetailsMock);
component.taskDetailsModel = new TaskRepresentation(taskDetailsMock);
fixture.detectChanges();
const createTaskButton = element.querySelector<HTMLElement>('#button-start');
createTaskButton.click();
@@ -243,7 +243,7 @@ describe('StartTaskComponent', () => {
it('should assign task with id of selected user assigned', () => {
const successSpy = spyOn(component.success, 'emit');
component.taskDetailsModel = new TaskDetailsModel(taskDetailsMock);
component.taskDetailsModel = new TaskRepresentation(taskDetailsMock);
component.taskForm.controls['name'].setValue('fakeName');
component.taskForm.controls['formKey'].setValue(1204);
component.appId = 42;
@@ -265,7 +265,7 @@ describe('StartTaskComponent', () => {
component.taskForm.controls['formKey'].setValue(1204);
component.appId = 42;
component.assigneeId = null;
component.taskDetailsModel = new TaskDetailsModel(taskDetailsMock);
component.taskDetailsModel = new TaskRepresentation(taskDetailsMock);
fixture.detectChanges();
const createTaskButton = element.querySelector<HTMLElement>('#button-start');
createTaskButton.click();
@@ -280,7 +280,7 @@ describe('StartTaskComponent', () => {
it('should not attach a form when a form id is not selected', () => {
const attachFormToATask = spyOn(service, 'attachFormToATask').and.returnValue(of([]));
spyOn(service, 'createNewTask').and.returnValue(of(new TaskDetailsModel({ id: 'task-id' })));
spyOn(service, 'createNewTask').and.returnValue(of(new TaskRepresentation({ id: 'task-id' })));
component.taskForm.controls['name'].setValue('fakeName');
fixture.detectChanges();
const createTaskButton = element.querySelector<HTMLElement>('#button-start');

View File

@@ -20,11 +20,11 @@ import { Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation, OnDe
import { DateAdapter, MAT_DATE_FORMATS } from '@angular/material/core';
import { EMPTY, Observable, Subject } from 'rxjs';
import { Form } from '../models/form.model';
import { TaskDetailsModel } from '../models/task-details.model';
import { TaskListService } from './../services/tasklist.service';
import { switchMap, defaultIfEmpty, takeUntil } from 'rxjs/operators';
import { UntypedFormBuilder, AbstractControl, Validators, UntypedFormGroup, UntypedFormControl } from '@angular/forms';
import { isValid } from 'date-fns';
import { TaskRepresentation } from '@alfresco/js-api';
const FORMAT_DATE = 'DD/MM/YYYY';
const MAX_LENGTH = 255;
@@ -60,7 +60,7 @@ export class StartTaskComponent implements OnInit, OnDestroy {
@Output()
error = new EventEmitter<any>();
taskDetailsModel: TaskDetailsModel = new TaskDetailsModel();
taskDetailsModel = new TaskRepresentation();
forms$: Observable<Form[]>;
assigneeId: number;
field: FormFieldModel;
@@ -213,7 +213,7 @@ export class StartTaskComponent implements OnInit, OnDestroy {
return response;
}
private assignTaskByUserId(taskId: string, userId: string): Observable<TaskDetailsModel> {
private assignTaskByUserId(taskId: string, userId: string): Observable<TaskRepresentation> {
if (taskId && userId) {
return this.taskService.assignTaskByUserId(taskId, userId);
}

View File

@@ -92,7 +92,7 @@
<adf-checklist
[readOnly]="internalReadOnlyForm"
[taskId]="taskDetails.id"
[assignee]="$any(taskDetails)?.assignee?.id"
[assignee]="taskDetails.assignee?.id"
(checklistTaskCreated)="onChecklistTaskCreated($event)"
(checklistTaskDeleted)="onChecklistTaskDeleted($event)">
</adf-checklist>

View File

@@ -20,7 +20,6 @@ import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { of, throwError } from 'rxjs';
import { FormModel, FormOutcomeEvent, FormOutcomeModel, CommentModel, User } from '@alfresco/adf-core';
import { TaskDetailsModel } from '../models/task-details.model';
import { noDataMock, taskDetailsMock, taskFormMock, tasksMock, taskDetailsWithOutAssigneeMock } from '../../mock';
import { TaskListService } from './../services/tasklist.service';
import { TaskDetailsComponent } from './task-details.component';
@@ -32,7 +31,7 @@ import { PeopleProcessService } from '../../common/services/people-process.servi
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { HarnessLoader } from '@angular/cdk/testing';
import { MatDialogHarness } from '@angular/material/dialog/testing';
import { LightUserRepresentation } from '@alfresco/js-api';
import { LightUserRepresentation, TaskRepresentation } from '@alfresco/js-api';
const fakeUser: LightUserRepresentation = {
id: 0,
@@ -41,12 +40,12 @@ const fakeUser: LightUserRepresentation = {
email: 'fake@mail.com'
};
const fakeTaskAssignResponse = new TaskDetailsModel({
const fakeTaskAssignResponse: any = {
id: 'fake-id',
firstName: 'fake-name',
lastName: 'fake-last',
email: 'fake@mail.com'
});
};
describe('TaskDetailsComponent', () => {
let taskListService: TaskListService;
@@ -295,7 +294,7 @@ describe('TaskDetailsComponent', () => {
it('should emit a task created event when checklist task is created', () => {
const emitSpy: jasmine.Spy = spyOn(component.taskCreated, 'emit');
const mockTask = new TaskDetailsModel(taskDetailsMock);
const mockTask = new TaskRepresentation(taskDetailsMock);
component.onChecklistTaskCreated(mockTask);
expect(emitSpy).toHaveBeenCalled();
});
@@ -307,7 +306,7 @@ describe('TaskDetailsComponent', () => {
component.showHeaderContent = true;
component.ngOnChanges({ taskId: new SimpleChange('123', '456', true) });
component.taskPeople = [];
component.taskDetails = new TaskDetailsModel(taskDetailsMock);
component.taskDetails = new TaskRepresentation(taskDetailsMock);
component.taskDetails.endDate = new Date('2017-10-03T17:03:57.311+0000');
fixture.detectChanges();
@@ -319,7 +318,7 @@ describe('TaskDetailsComponent', () => {
component.showHeaderContent = true;
component.ngOnChanges({ taskId: new SimpleChange('123', '456', true) });
component.taskPeople = [];
component.taskDetails = new TaskDetailsModel(taskDetailsMock);
component.taskDetails = new TaskRepresentation(taskDetailsMock);
component.taskDetails.endDate = new Date('2017-10-03T17:03:57.311+0000');
fixture.detectChanges();
@@ -331,7 +330,7 @@ describe('TaskDetailsComponent', () => {
component.showHeaderContent = true;
component.ngOnChanges({ taskId: new SimpleChange('123', '456', true) });
component.taskPeople = [fakeUser];
component.taskDetails = new TaskDetailsModel(taskDetailsMock);
component.taskDetails = new TaskRepresentation(taskDetailsMock);
component.taskDetails.endDate = null;
fixture.detectChanges();
@@ -343,7 +342,7 @@ describe('TaskDetailsComponent', () => {
component.showHeaderContent = true;
component.ngOnChanges({ taskId: new SimpleChange('123', '456', true) });
component.taskPeople = [fakeUser];
component.taskDetails = new TaskDetailsModel(taskDetailsMock);
component.taskDetails = new TaskRepresentation(taskDetailsMock);
component.taskDetails.endDate = new Date('2017-10-03T17:03:57.311+0000');
fixture.detectChanges();
@@ -355,7 +354,7 @@ describe('TaskDetailsComponent', () => {
component.showHeaderContent = true;
component.ngOnChanges({ taskId: new SimpleChange('123', '456', true) });
component.taskPeople = [];
component.taskDetails = new TaskDetailsModel(taskDetailsMock);
component.taskDetails = new TaskRepresentation(taskDetailsMock);
fixture.detectChanges();
expect(component.showComments).toBe(true);
@@ -365,7 +364,7 @@ describe('TaskDetailsComponent', () => {
component.showComments = false;
component.ngOnChanges({ taskId: new SimpleChange('123', '456', true) });
component.taskPeople = [];
component.taskDetails = new TaskDetailsModel(taskDetailsMock);
component.taskDetails = new TaskRepresentation(taskDetailsMock);
fixture.detectChanges();
expect(component.showComments).toBeFalse();

View File

@@ -39,12 +39,11 @@ import {
} from '@angular/core';
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
import { Observable, Observer, of, Subject } from 'rxjs';
import { TaskDetailsModel } from '../models/task-details.model';
import { TaskListService } from './../services/tasklist.service';
import { catchError, share, takeUntil } from 'rxjs/operators';
import { TaskFormComponent } from './task-form/task-form.component';
import { PeopleProcessService } from '../../common/services/people-process.service';
import { LightUserRepresentation, TaskQueryRepresentation } from '@alfresco/js-api';
import { LightUserRepresentation, TaskQueryRepresentation, TaskRepresentation } from '@alfresco/js-api';
@Component({
selector: 'adf-task-details',
@@ -132,7 +131,7 @@ export class TaskDetailsComponent implements OnInit, OnChanges, OnDestroy {
/** Emitted when a checklist task is created. */
@Output()
taskCreated = new EventEmitter<TaskDetailsModel>();
taskCreated = new EventEmitter<TaskRepresentation>();
/** Emitted when a checklist task is deleted. */
@Output()
@@ -161,7 +160,7 @@ export class TaskDetailsComponent implements OnInit, OnChanges, OnDestroy {
@Output()
unClaimedTask = new EventEmitter<string>();
taskDetails: TaskDetailsModel;
taskDetails: TaskRepresentation;
taskFormName: string = null;
taskPeople: LightUserRepresentation[] = [];
noTaskDetailsTemplateComponent: TemplateRef<any>;
@@ -256,7 +255,7 @@ export class TaskDetailsComponent implements OnInit, OnChanges, OnDestroy {
this.formLoaded.emit(form);
}
onChecklistTaskCreated(task: TaskDetailsModel): void {
onChecklistTaskCreated(task: TaskRepresentation): void {
this.taskCreated.emit(task);
}
@@ -376,7 +375,7 @@ export class TaskDetailsComponent implements OnInit, OnChanges, OnDestroy {
this.taskListService.getTasks(requestNode).subscribe(
(response) => {
if (response && response.length > 0) {
this.taskDetails = new TaskDetailsModel(response[0]);
this.taskDetails = new TaskRepresentation(response[0]);
} else {
this.reset();
}

View File

@@ -41,12 +41,12 @@ import {
taskDetailsWithOutFormMock,
taskFormMock
} from '../../../mock/task/task-details.mock';
import { TaskDetailsModel } from '../../models/task-details.model';
import { ProcessTestingModule } from '../../../testing/process.testing.module';
import { By } from '@angular/platform-browser';
import { TaskFormService } from '../../../form/services/task-form.service';
import { TaskService } from '../../../form/services/task.service';
import { PeopleProcessService } from '../../../common/services/people-process.service';
import { TaskRepresentation } from '@alfresco/js-api';
describe('TaskFormComponent', () => {
let component: TaskFormComponent;
@@ -282,7 +282,7 @@ describe('TaskFormComponent', () => {
it('Should be able to show completed message and cancel button for the completed task without form', async () => {
completedTaskDetailsMock.formKey = null;
component.taskDetails = new TaskDetailsModel(completedTaskDetailsMock);
component.taskDetails = new TaskRepresentation(completedTaskDetailsMock);
fixture.detectChanges();
await fixture.whenStable();
const completeButtonElement = fixture.debugElement.nativeElement.querySelector('#adf-no-form-complete-button');
@@ -297,7 +297,7 @@ describe('TaskFormComponent', () => {
it('Should not display complete button to the completed task without form', async () => {
completedTaskDetailsMock.formKey = null;
component.taskDetails = new TaskDetailsModel(completedTaskDetailsMock);
component.taskDetails = new TaskRepresentation(completedTaskDetailsMock);
fixture.detectChanges();
await fixture.whenStable();
const completeButtonElement = fixture.debugElement.nativeElement.querySelector('#adf-no-form-complete-button');
@@ -312,7 +312,7 @@ describe('TaskFormComponent', () => {
});
it('Should be able to show no form message if the task does not attached a form', async () => {
component.taskDetails = new TaskDetailsModel(taskDetailsWithOutFormMock);
component.taskDetails = new TaskRepresentation(taskDetailsWithOutFormMock);
fixture.detectChanges();
await fixture.whenStable();
const completeButtonElement = fixture.debugElement.nativeElement.querySelector('#adf-no-form-complete-button');
@@ -326,7 +326,7 @@ describe('TaskFormComponent', () => {
});
it('Should be able display complete button to a task without form', async () => {
component.taskDetails = new TaskDetailsModel(taskDetailsWithOutFormMock);
component.taskDetails = new TaskRepresentation(taskDetailsWithOutFormMock);
fixture.detectChanges();
await fixture.whenStable();
const completeButtonElement = fixture.debugElement.nativeElement.querySelector('#adf-no-form-complete-button');
@@ -336,7 +336,7 @@ describe('TaskFormComponent', () => {
it('Should be able to complete a task with no form when complete button is clicked', async () => {
fixture.detectChanges();
component.taskDetails = new TaskDetailsModel(taskDetailsWithOutFormMock);
component.taskDetails = new TaskRepresentation(taskDetailsWithOutFormMock);
fixture.detectChanges();
await fixture.whenStable();
const completeButtonElement = fixture.debugElement.nativeElement.querySelector('#adf-no-form-complete-button');
@@ -347,7 +347,7 @@ describe('TaskFormComponent', () => {
it('Should emit error event in case complete task service fails', async () => {
const errorSpy: jasmine.Spy = spyOn(component.error, 'emit');
completeTaskSpy.and.returnValue(throwError({ message: 'servce failed' }));
component.taskDetails = new TaskDetailsModel(taskDetailsWithOutFormMock);
component.taskDetails = new TaskRepresentation(taskDetailsWithOutFormMock);
fixture.detectChanges();
await fixture.whenStable();
const formSelector = element.querySelector('adf-form');
@@ -361,7 +361,7 @@ describe('TaskFormComponent', () => {
it('Should be able to emit cancel event on task with no-form when cancel button is clicked', async () => {
const cancelSpy = spyOn(component.cancel, 'emit');
getTaskDetailsSpy.and.returnValue(of(taskDetailsWithOutFormMock));
component.taskDetails = new TaskDetailsModel(taskDetailsWithOutFormMock);
component.taskDetails = new TaskRepresentation(taskDetailsWithOutFormMock);
fixture.detectChanges();
await fixture.whenStable();
const cancelButtonElement = fixture.debugElement.nativeElement.querySelector('#adf-no-form-cancel-button');
@@ -370,7 +370,7 @@ describe('TaskFormComponent', () => {
});
it('Should display the template in a process task with no Form', async () => {
component.taskDetails = new TaskDetailsModel(taskDetailsWithOutFormMock);
component.taskDetails = new TaskRepresentation(taskDetailsWithOutFormMock);
fixture.detectChanges();
await fixture.whenStable();
let formMessage = fixture.debugElement.nativeElement.querySelector('.adf-empty-content__title');
@@ -383,7 +383,7 @@ describe('TaskFormComponent', () => {
expect(subMessage.innerText).toContain('ADF_TASK_FORM.EMPTY_FORM.SUBTITLE');
completeButtonElement.click();
component.taskDetails = new TaskDetailsModel(completedProcessTaskWithoutForm);
component.taskDetails = new TaskRepresentation(completedProcessTaskWithoutForm);
fixture.detectChanges();
await fixture.whenStable();
@@ -394,8 +394,8 @@ describe('TaskFormComponent', () => {
expect(formMessage.innerText).toContain('ADF_TASK_FORM.COMPLETED_TASK.TITLE');
expect(subMessage.innerText).toContain('ADF_TASK_FORM.COMPLETED_TASK.SUBTITLE');
expect(cancelButton).not.toBeNull();
expect(cancelButton['disabled']).toEqual(false, 'cancel button not visible for completed task');
expect(completeButtonElement).toBeNull('complete button shown for completed task');
expect(cancelButton['disabled']).toEqual(false);
expect(completeButtonElement).toBeNull();
expect(taskListService.completeTask).toHaveBeenCalled();
});
});
@@ -407,7 +407,7 @@ describe('TaskFormComponent', () => {
});
it('Should display empty template in case standalone task does not attached a form', async () => {
component.taskDetails = new TaskDetailsModel(standaloneTaskWithoutForm);
component.taskDetails = new TaskRepresentation(standaloneTaskWithoutForm);
fixture.detectChanges();
await fixture.whenStable();
const taskStandAlone = element.querySelector('adf-task-standalone');
@@ -418,7 +418,7 @@ describe('TaskFormComponent', () => {
it('Should be able display attach form button for a standalone task without form', async () => {
const showAttachFormSpy = spyOn(component.showAttachForm, 'emit');
component.taskDetails = new TaskDetailsModel(standaloneTaskWithoutForm);
component.taskDetails = new TaskRepresentation(standaloneTaskWithoutForm);
fixture.detectChanges();
await fixture.whenStable();
const attacheFormButton = fixture.debugElement.nativeElement.querySelector('#adf-no-form-attach-form-button');
@@ -452,7 +452,7 @@ describe('TaskFormComponent', () => {
expect(formMessage.innerText).toContain('ADF_TASK_LIST.STANDALONE_TASK.NO_FORM_MESSAGE');
completeButtonElement.click();
component.taskDetails = new TaskDetailsModel(completedStandaloneTaskWithoutForm);
component.taskDetails = new TaskRepresentation(completedStandaloneTaskWithoutForm);
fixture.detectChanges();
await fixture.whenStable();
@@ -460,8 +460,8 @@ describe('TaskFormComponent', () => {
completeButtonElement = fixture.debugElement.nativeElement.querySelector('#adf-no-form-complete-button');
attacheFormButton = fixture.debugElement.nativeElement.querySelector('#adf-no-form-attach-form-button');
expect(formMessage.innerText).toContain('ADF_TASK_LIST.STANDALONE_TASK.COMPLETE_TASK_MESSAGE');
expect(attacheFormButton).toBeNull('attach form button shown for completed task');
expect(completeButtonElement).toBeNull('complete button shown for completed task');
expect(attacheFormButton).toBeNull();
expect(completeButtonElement).toBeNull();
expect(taskListService.completeTask).toHaveBeenCalled();
});
});

View File

@@ -17,9 +17,8 @@
import { Component, OnInit, Input, Output, EventEmitter, SimpleChanges, ViewEncapsulation, OnChanges } from '@angular/core';
import { FormModel, ContentLinkModel, FormFieldValidator, FormOutcomeEvent, TranslationService, FormFieldModel } from '@alfresco/adf-core';
import { TaskDetailsModel } from '../../models/task-details.model';
import { TaskListService } from '../../services/tasklist.service';
import { UserRepresentation } from '@alfresco/js-api';
import { TaskRepresentation, UserRepresentation } from '@alfresco/js-api';
import { Observable } from 'rxjs';
import { PeopleProcessService } from '../../../common';
@@ -119,7 +118,7 @@ export class TaskFormComponent implements OnInit, OnChanges {
@Output()
taskUnclaimed = new EventEmitter<string>();
taskDetails: TaskDetailsModel;
taskDetails: TaskRepresentation;
currentLoggedUser: UserRepresentation;
loading: boolean = false;
internalReadOnlyForm: boolean = false;

View File

@@ -27,12 +27,11 @@ import {
claimedByGroupMemberMock,
taskDetailsWithOutCandidateGroup
} from '../../mock';
import { TaskDetailsModel } from '../models/task-details.model';
import { TaskListService } from './../services/tasklist.service';
import { TaskHeaderComponent } from './task-header.component';
import { ProcessTestingModule } from '../../testing/process.testing.module';
import { PeopleProcessService } from '../../common/services/people-process.service';
import { TaskRepresentation } from '@alfresco/js-api';
describe('TaskHeaderComponent', () => {
let service: TaskListService;
@@ -64,7 +63,7 @@ describe('TaskHeaderComponent', () => {
service = TestBed.inject(TaskListService);
peopleProcessService = TestBed.inject(PeopleProcessService);
spyOn(peopleProcessService, 'getCurrentUserInfo').and.returnValue(of(fakeBpmAssignedUser));
component.taskDetails = new TaskDetailsModel(taskDetailsMock);
component.taskDetails = new TaskRepresentation(taskDetailsMock);
appConfigService = TestBed.inject(AppConfigService);
});
@@ -133,12 +132,12 @@ describe('TaskHeaderComponent', () => {
await fixture.whenStable();
const datePicker = fixture.debugElement.query(By.css(`[data-automation-id="datepicker-dueDate"]`));
expect(datePicker).not.toBeNull('Datepicker should be in DOM');
expect(datePicker).not.toBeNull();
});
describe('Claiming', () => {
it('should be able display the claim/release button if showClaimRelease set to true', async () => {
component.taskDetails = new TaskDetailsModel(claimableTaskDetailsMock);
component.taskDetails = new TaskRepresentation(claimableTaskDetailsMock);
component.showClaimRelease = true;
component.refreshData();
@@ -150,7 +149,7 @@ describe('TaskHeaderComponent', () => {
});
it('should not be able display the claim/release button if showClaimRelease set to false', async () => {
component.taskDetails = new TaskDetailsModel(claimableTaskDetailsMock);
component.taskDetails = new TaskRepresentation(claimableTaskDetailsMock);
component.showClaimRelease = false;
component.refreshData();
@@ -162,7 +161,7 @@ describe('TaskHeaderComponent', () => {
});
it('should display the claim button if no assignee', async () => {
component.taskDetails = new TaskDetailsModel(claimableTaskDetailsMock);
component.taskDetails = new TaskRepresentation(claimableTaskDetailsMock);
component.refreshData();
@@ -174,7 +173,7 @@ describe('TaskHeaderComponent', () => {
});
it('should display the claim button if the task is claimable', async () => {
component.taskDetails = new TaskDetailsModel(claimableTaskDetailsMock);
component.taskDetails = new TaskRepresentation(claimableTaskDetailsMock);
component.refreshData();
fixture.detectChanges();
@@ -186,7 +185,7 @@ describe('TaskHeaderComponent', () => {
});
it('should not display the claim/requeue button if the task is not claimable ', async () => {
component.taskDetails = new TaskDetailsModel(taskDetailsWithOutCandidateGroup);
component.taskDetails = new TaskRepresentation(taskDetailsWithOutCandidateGroup);
component.refreshData();
fixture.detectChanges();
@@ -202,7 +201,7 @@ describe('TaskHeaderComponent', () => {
});
it('should display the requeue button if task is claimed by the current logged-in user', async () => {
component.taskDetails = new TaskDetailsModel(claimedTaskDetailsMock);
component.taskDetails = new TaskRepresentation(claimedTaskDetailsMock);
component.refreshData();
fixture.detectChanges();
@@ -214,7 +213,7 @@ describe('TaskHeaderComponent', () => {
});
it('should not display the requeue button to logged in user if task is claimed by other candidate member', async () => {
component.taskDetails = new TaskDetailsModel(claimedByGroupMemberMock);
component.taskDetails = new TaskRepresentation(claimedByGroupMemberMock);
component.refreshData();
fixture.detectChanges();
@@ -226,7 +225,7 @@ describe('TaskHeaderComponent', () => {
});
it('should display the claim button if the task is claimable by candidates members', async () => {
component.taskDetails = new TaskDetailsModel(claimableTaskDetailsMock);
component.taskDetails = new TaskRepresentation(claimableTaskDetailsMock);
component.refreshData();
fixture.detectChanges();
@@ -239,7 +238,7 @@ describe('TaskHeaderComponent', () => {
});
it('should not display the requeue button if the task is completed', async () => {
component.taskDetails = new TaskDetailsModel(completedTaskDetailsMock);
component.taskDetails = new TaskRepresentation(completedTaskDetailsMock);
component.refreshData();
fixture.detectChanges();

View File

@@ -26,9 +26,9 @@ import {
CardViewIntItemModel,
CardViewItemLengthValidator
} from '@alfresco/adf-core';
import { TaskDetailsModel } from '../models/task-details.model';
import { PeopleProcessService } from '../../common/services/people-process.service';
import { TaskDescriptionValidator } from '../validators/task-description.validator';
import { TaskRepresentation } from '@alfresco/js-api';
@Component({
selector: 'adf-task-header',
@@ -43,7 +43,7 @@ export class TaskHeaderComponent implements OnChanges, OnInit {
/** (required) Details related to the task. */
@Input()
taskDetails: TaskDetailsModel;
taskDetails: TaskRepresentation;
/** Toggles display of the claim/release button. */
@Input()

View File

@@ -15,14 +15,13 @@
* limitations under the License.
*/
import { TaskDetailsModel } from './task-details.model';
import { TaskRepresentation } from '@alfresco/js-api';
export class TaskDetailsEvent {
private _value: TaskDetailsModel;
private _value: TaskRepresentation;
private _defaultPrevented: boolean = false;
get value(): TaskDetailsModel {
get value(): TaskRepresentation {
return this._value;
}
@@ -30,7 +29,7 @@ export class TaskDetailsEvent {
return this._defaultPrevented;
}
constructor(value: TaskDetailsModel) {
constructor(value: TaskRepresentation) {
this._value = value;
}

View File

@@ -1,111 +0,0 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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.
*/
/**
* This object represent the details of a task.
*/
import { LightUserRepresentation, TaskRepresentation } from '@alfresco/js-api';
import { UserGroupModel } from './user-group.model';
export class TaskDetailsModel implements TaskRepresentation {
id?: string;
name?: string;
assignee?: LightUserRepresentation;
priority?: number;
adhocTaskCanBeReassigned?: boolean;
category?: string;
created?: Date;
description?: string;
parentName?: string;
dueDate?: Date;
duration?: number;
endDate?: Date;
executionId?: string;
formKey?: string;
initiatorCanCompleteTask?: boolean;
managerOfCandidateGroup?: boolean;
memberOfCandidateGroup?: boolean;
memberOfCandidateUsers?: boolean;
involvedGroups?: UserGroupModel[];
involvedPeople?: LightUserRepresentation[];
parentTaskId?: string;
parentTaskName?: string;
processDefinitionCategory?: string;
processDefinitionDeploymentId?: string;
processDefinitionDescription?: string;
processDefinitionId?: string;
processDefinitionKey?: string;
processDefinitionName?: string;
processDefinitionVersion?: number = 0;
processInstanceId?: string;
processInstanceName?: string;
processInstanceStartUserId?: string;
taskDefinitionKey?: string;
constructor(obj?: any) {
if (obj) {
this.id = obj.id || null;
this.name = obj.name || null;
this.priority = obj.priority;
this.assignee = obj.assignee;
this.adhocTaskCanBeReassigned = obj.adhocTaskCanBeReassigned;
this.category = obj.category || null;
this.created = obj.created || null;
this.description = obj.description || null;
this.dueDate = obj.dueDate || null;
this.duration = obj.duration || null;
this.endDate = obj.endDate || null;
this.executionId = obj.executionId || null;
this.formKey = obj.formKey || null;
this.initiatorCanCompleteTask = !!obj.initiatorCanCompleteTask;
this.managerOfCandidateGroup = !!obj.managerOfCandidateGroup;
this.memberOfCandidateGroup = !!obj.memberOfCandidateGroup;
this.memberOfCandidateUsers = !!obj.memberOfCandidateUsers;
this.involvedGroups = obj.involvedGroups;
this.involvedPeople = obj.involvedPeople;
this.parentTaskId = obj.parentTaskId || null;
this.parentTaskName = obj.parentTaskName || null;
this.processDefinitionCategory = obj.processDefinitionCategory || null;
this.processDefinitionDeploymentId = obj.processDefinitionDeploymentId || null;
this.processDefinitionDescription = obj.processDefinitionDescription || null;
this.processDefinitionId = obj.processDefinitionId || null;
this.processDefinitionKey = obj.processDefinitionKey || null;
this.processDefinitionName = obj.processDefinitionName || null;
this.processDefinitionVersion = obj.processDefinitionVersion || 0;
this.processInstanceId = obj.processInstanceId || null;
this.processInstanceName = obj.processInstanceName || null;
this.processInstanceStartUserId = obj.processInstanceStartUserId || null;
this.taskDefinitionKey = obj.taskDefinitionKey || null;
}
}
getFullName(): string {
let fullName: string = '';
if (this.assignee) {
const firstName: string = this.assignee.firstName ? this.assignee.firstName : '';
const lastName: string = this.assignee.lastName ? this.assignee.lastName : '';
fullName = `${firstName} ${lastName}`;
}
return fullName.trim();
}
isCompleted(): boolean {
return !!this.endDate;
}
}

View File

@@ -36,7 +36,6 @@ export * from './services/task-filter.service';
export * from './models/form.model';
export * from './models/task-details.event';
export * from './models/task-details.model';
export * from './models/user-event.model';
export * from './models/user-group.model';

View File

@@ -16,7 +16,7 @@
*/
import { AlfrescoApiService } from '@alfresco/adf-core';
import { Injectable } from '@angular/core';
import { inject, Injectable } from '@angular/core';
import { Observable, forkJoin, from } from 'rxjs';
import { map } from 'rxjs/operators';
import { UserFiltersApi, UserTaskFilterRepresentation } from '@alfresco/js-api';
@@ -25,14 +25,14 @@ import { UserFiltersApi, UserTaskFilterRepresentation } from '@alfresco/js-api';
providedIn: 'root'
})
export class TaskFilterService {
private apiService = inject(AlfrescoApiService);
private _userFiltersApi: UserFiltersApi;
get userFiltersApi(): UserFiltersApi {
this._userFiltersApi = this._userFiltersApi ?? new UserFiltersApi(this.apiService.getInstance());
return this._userFiltersApi;
}
constructor(private apiService: AlfrescoApiService) {}
/**
* Creates and returns the default filters for a process app.
*

View File

@@ -20,7 +20,6 @@ import { Injectable } from '@angular/core';
import { Observable, from, of } from 'rxjs';
import { map, catchError, flatMap, filter } from 'rxjs/operators';
import { Form } from '../models/form.model';
import { TaskDetailsModel } from '../models/task-details.model';
import {
TaskUpdateRepresentation,
ModelsApi,
@@ -29,7 +28,8 @@ import {
ChecklistsApi,
ResultListDataRepresentationTaskRepresentation,
TaskQueryRepresentation,
UserTaskFilterRepresentation
UserTaskFilterRepresentation,
TaskRepresentation
} from '@alfresco/js-api';
@Injectable({
@@ -121,8 +121,8 @@ export class TaskListService {
* @param taskId ID of the target task.
* @returns Task details
*/
getTaskDetails(taskId: string): Observable<TaskDetailsModel> {
return from(this.tasksApi.getTask(taskId)).pipe(map((details) => new TaskDetailsModel(details)));
getTaskDetails(taskId: string): Observable<TaskRepresentation> {
return from(this.tasksApi.getTask(taskId));
}
/**
@@ -131,8 +131,8 @@ export class TaskListService {
* @param id ID of the target task
* @returns Array of checklist task details
*/
getTaskChecklist(id: string): Observable<TaskDetailsModel[]> {
return from(this.checklistsApi.getChecklist(id)).pipe(map((response) => response.data.map((checklist) => new TaskDetailsModel(checklist))));
getTaskChecklist(id: string): Observable<TaskRepresentation[]> {
return from(this.checklistsApi.getChecklist(id)).pipe(map((response) => response.data));
}
/**
@@ -167,8 +167,8 @@ export class TaskListService {
* @param task The task to add
* @returns The subtask that was added
*/
addTask(task: TaskDetailsModel): Observable<TaskDetailsModel> {
return from(this.checklistsApi.addSubtask(task.parentTaskId, task)).pipe(map((response) => new TaskDetailsModel(response)));
addTask(task: TaskRepresentation): Observable<TaskRepresentation> {
return from(this.checklistsApi.addSubtask(task.parentTaskId, task));
}
/**
@@ -207,8 +207,8 @@ export class TaskListService {
* @param task Details of the new task
* @returns Details of the newly created task
*/
createNewTask(task: TaskDetailsModel): Observable<TaskDetailsModel> {
return from(this.tasksApi.createNewTask(task)).pipe(map((response) => new TaskDetailsModel(response)));
createNewTask(task: TaskRepresentation): Observable<TaskRepresentation> {
return from(this.tasksApi.createNewTask(task));
}
/**
@@ -218,9 +218,9 @@ export class TaskListService {
* @param requestNode User or group to assign the task to
* @returns Details of the assigned task
*/
assignTask(taskId: string, requestNode: any): Observable<TaskDetailsModel> {
assignTask(taskId: string, requestNode: any): Observable<TaskRepresentation> {
const assignee = { assignee: requestNode.id };
return from(this.taskActionsApi.assignTask(taskId, assignee)).pipe(map((response) => new TaskDetailsModel(response)));
return from(this.taskActionsApi.assignTask(taskId, assignee));
}
/**
@@ -230,10 +230,10 @@ export class TaskListService {
* @param userId ID of the user to assign the task to
* @returns Details of the assigned task
*/
assignTaskByUserId(taskId: string, userId: string): Observable<TaskDetailsModel> {
assignTaskByUserId(taskId: string, userId: string): Observable<TaskRepresentation> {
const assignee = { assignee: userId };
return from(this.taskActionsApi.assignTask(taskId, assignee)).pipe(map((response) => new TaskDetailsModel(response)));
return from(this.taskActionsApi.assignTask(taskId, assignee));
}
/**
@@ -242,7 +242,7 @@ export class TaskListService {
* @param taskId ID of the task to claim
* @returns Details of the claimed task
*/
claimTask(taskId: string): Observable<TaskDetailsModel> {
claimTask(taskId: string): Observable<TaskRepresentation> {
return from(this.taskActionsApi.claimTask(taskId));
}
@@ -252,7 +252,7 @@ export class TaskListService {
* @param taskId ID of the task to unclaim
* @returns Null response notifying when the operation is complete
*/
unclaimTask(taskId: string): Observable<TaskDetailsModel> {
unclaimTask(taskId: string): Observable<TaskRepresentation> {
return from(this.taskActionsApi.unclaimTask(taskId));
}
@@ -263,8 +263,8 @@ export class TaskListService {
* @param updated Data to update the task (as a `TaskUpdateRepresentation` instance).
* @returns Updated task details
*/
updateTask(taskId: string, updated: TaskUpdateRepresentation): Observable<TaskDetailsModel> {
return from(this.tasksApi.updateTask(taskId, updated)).pipe(map((result) => result as TaskDetailsModel));
updateTask(taskId: string, updated: TaskUpdateRepresentation): Observable<TaskRepresentation> {
return from(this.tasksApi.updateTask(taskId, updated));
}
/**