mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-] update library to use new js-api 3.0.0 (#4097)
This commit is contained in:
committed by
Eugenio Romano
parent
2acd1b4e26
commit
3ef7d3b7ea
@@ -104,8 +104,8 @@ export class AttachFormComponent implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
private loadFormsTask(): void {
|
||||
this.taskService.getFormList().subscribe((res: Form[]) => {
|
||||
this.forms = res;
|
||||
this.taskService.getFormList().subscribe((form: Form[]) => {
|
||||
this.forms = form;
|
||||
},
|
||||
(err) => {
|
||||
this.error.emit(err);
|
||||
|
@@ -108,9 +108,9 @@ export class ChecklistComponent implements OnChanges {
|
||||
assignee: { id: this.assignee }
|
||||
});
|
||||
this.activitiTaskList.addTask(newTask).subscribe(
|
||||
(res: TaskDetailsModel) => {
|
||||
this.checklist.push(res);
|
||||
this.checklistTaskCreated.emit(res);
|
||||
(taskDetailsModel: TaskDetailsModel) => {
|
||||
this.checklist.push(taskDetailsModel);
|
||||
this.checklistTaskCreated.emit(taskDetailsModel);
|
||||
this.taskName = '';
|
||||
},
|
||||
(error) => {
|
||||
|
@@ -145,27 +145,19 @@ describe('TaskDetailsComponent', () => {
|
||||
expect(fixture.nativeElement.innerText).toBe('ADF_TASK_LIST.DETAILS.MESSAGES.NONE');
|
||||
});
|
||||
|
||||
it('shoud display a form when the task has an associated form', (done) => {
|
||||
it('should display a form when the task has an associated form', async(() => {
|
||||
component.taskId = '123';
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.query(By.css('adf-form'))).not.toBeNull();
|
||||
done();
|
||||
});
|
||||
});
|
||||
expect(fixture.debugElement.query(By.css('adf-form'))).not.toBeNull();
|
||||
}));
|
||||
|
||||
it('shoud display a form in readonly when the task has an associated form and readOnlyForm is true', (done) => {
|
||||
it('should display a form in readonly when the task has an associated form and readOnlyForm is true', async((done) => {
|
||||
component.readOnlyForm = true;
|
||||
component.taskId = '123';
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.query(By.css('adf-form'))).not.toBeNull();
|
||||
expect(fixture.debugElement.query(By.css('.adf-readonly-form'))).not.toBeNull();
|
||||
done();
|
||||
});
|
||||
});
|
||||
expect(fixture.debugElement.query(By.css('adf-form'))).not.toBeNull();
|
||||
expect(fixture.debugElement.query(By.css('.adf-readonly-form'))).not.toBeNull();
|
||||
}));
|
||||
|
||||
it('should not display a form when the task does not have an associated form', async(() => {
|
||||
component.taskId = '123';
|
||||
|
@@ -43,7 +43,7 @@ import { TaskQueryRequestRepresentationModel } from '../models/filter.model';
|
||||
import { TaskDetailsModel } from '../models/task-details.model';
|
||||
import { TaskListService } from './../services/tasklist.service';
|
||||
import { AttachFileWidgetComponent, AttachFolderWidgetComponent } from '../../content-widget';
|
||||
import { UserRepresentation } from 'alfresco-js-api';
|
||||
import { UserRepresentation } from '@alfresco/js-api';
|
||||
import { share } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
|
@@ -264,7 +264,7 @@ describe('TaskListComponent', () => {
|
||||
expect(component.rows[0]['processInstanceId']).toEqual(2511);
|
||||
expect(component.rows[0]['endDate']).toBeDefined();
|
||||
expect(component.rows[1]['name']).toEqual('No name');
|
||||
expect(component.rows[1]['endDate']).toBeNull();
|
||||
expect(component.rows[1]['endDate']).toBeUndefined();
|
||||
done();
|
||||
});
|
||||
|
||||
|
@@ -124,7 +124,7 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
|
||||
|
||||
/** Starting point of the */
|
||||
@Input()
|
||||
start: number = 0;
|
||||
start: number;
|
||||
|
||||
/** Emitted when a task in the list is clicked */
|
||||
@Output()
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TaskQueryRequestRepresentation, UserTaskFilterRepresentation } from 'alfresco-js-api';
|
||||
import { TaskFilterRepresentation, UserTaskFilterRepresentation, TaskQueryRepresentation } from '@alfresco/js-api';
|
||||
|
||||
export class AppDefinitionRepresentationModel {
|
||||
defaultAppId: string;
|
||||
@@ -57,37 +57,13 @@ export class FilterParamsModel {
|
||||
}
|
||||
}
|
||||
|
||||
export class FilterParamRepresentationModel {
|
||||
processDefinitionId: string;
|
||||
processDefinitionKey: string;
|
||||
name: string;
|
||||
state: string;
|
||||
sort: string;
|
||||
assignment: string;
|
||||
dueAfter: Date;
|
||||
dueBefore: Date;
|
||||
|
||||
constructor(obj?: any) {
|
||||
if (obj) {
|
||||
this.processDefinitionId = obj.processDefinitionId || null;
|
||||
this.processDefinitionKey = obj.processDefinitionKey || null;
|
||||
this.name = obj.name || null;
|
||||
this.state = obj.state || null;
|
||||
this.sort = obj.sort || null;
|
||||
this.assignment = obj.assignment || null;
|
||||
this.dueAfter = obj.dueAfter || null;
|
||||
this.dueBefore = obj.dueBefore || null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class FilterRepresentationModel implements UserTaskFilterRepresentation {
|
||||
id: number;
|
||||
appId: number;
|
||||
name: string;
|
||||
recent: boolean;
|
||||
icon: string;
|
||||
filter: FilterParamRepresentationModel;
|
||||
filter: TaskFilterRepresentation;
|
||||
index: number;
|
||||
|
||||
constructor(obj?: any) {
|
||||
@@ -97,7 +73,7 @@ export class FilterRepresentationModel implements UserTaskFilterRepresentation {
|
||||
this.name = obj.name || null;
|
||||
this.recent = !!obj.recent;
|
||||
this.icon = obj.icon || null;
|
||||
this.filter = new FilterParamRepresentationModel(obj.filter);
|
||||
this.filter = new UserTaskFilterRepresentation(obj.filter);
|
||||
this.index = obj.index;
|
||||
}
|
||||
}
|
||||
@@ -107,38 +83,6 @@ export class FilterRepresentationModel implements UserTaskFilterRepresentation {
|
||||
}
|
||||
}
|
||||
|
||||
export class TaskQueryRequestRepresentationModel implements TaskQueryRequestRepresentation {
|
||||
appDefinitionId: string;
|
||||
dueAfter: string;
|
||||
dueBefore: string;
|
||||
processInstanceId: string;
|
||||
processDefinitionId: string;
|
||||
text: string;
|
||||
assignment: string;
|
||||
state: string;
|
||||
start: string;
|
||||
sort: string;
|
||||
page: number;
|
||||
size: number;
|
||||
taskId: string;
|
||||
includeProcessInstance: boolean;
|
||||
export class TaskQueryRequestRepresentationModel extends TaskQueryRepresentation {
|
||||
|
||||
constructor(obj?: any) {
|
||||
if (obj) {
|
||||
this.appDefinitionId = obj.appDefinitionId || null;
|
||||
this.dueAfter = obj.dueAfter || null;
|
||||
this.dueBefore = obj.dueBefore || null;
|
||||
this.processInstanceId = obj.processInstanceId || null;
|
||||
this.processDefinitionId = obj.processDefinitionId || null;
|
||||
this.text = obj.text || null;
|
||||
this.assignment = obj.assignment || null;
|
||||
this.state = obj.state || null;
|
||||
this.start = obj.start || null;
|
||||
this.sort = obj.sort || null;
|
||||
this.page = obj.page || 0;
|
||||
this.size = obj.size || 25;
|
||||
this.taskId = obj.taskId || null;
|
||||
this.includeProcessInstance = obj.includeProcessInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -19,43 +19,43 @@
|
||||
* This object represent the details of a task.
|
||||
*/
|
||||
import { UserProcessModel } from '@alfresco/adf-core';
|
||||
import { TaskRepresentation } from 'alfresco-js-api';
|
||||
import { TaskRepresentation } from '@alfresco/js-api';
|
||||
import { UserGroupModel } from './user-group.model';
|
||||
|
||||
export class TaskDetailsModel implements TaskRepresentation {
|
||||
id: string;
|
||||
name: string;
|
||||
assignee: UserProcessModel;
|
||||
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: UserProcessModel [];
|
||||
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;
|
||||
id?: string;
|
||||
name?: string;
|
||||
assignee?: UserProcessModel;
|
||||
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?: UserProcessModel [];
|
||||
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) {
|
||||
|
@@ -17,13 +17,21 @@
|
||||
|
||||
import { TaskDetailsModel } from './task-details.model';
|
||||
|
||||
export class TaskListModel {
|
||||
size: number;
|
||||
total: number;
|
||||
start: number;
|
||||
length: number;
|
||||
data: TaskDetailsModel[] = [];
|
||||
export class TaskListModel {
|
||||
size?: number;
|
||||
total?: number;
|
||||
start?: number;
|
||||
length?: number;
|
||||
data?: TaskDetailsModel[] = [];
|
||||
|
||||
constructor() {
|
||||
constructor(input?: any) {
|
||||
if (input) {
|
||||
Object.assign(this, input);
|
||||
if (input.data) {
|
||||
this.data = input.data.map((item: any) => {
|
||||
return new TaskDetailsModel(item);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -20,11 +20,11 @@
|
||||
*/
|
||||
|
||||
export class UserGroupModel {
|
||||
id: number;
|
||||
name: string;
|
||||
externalId: string;
|
||||
status: string;
|
||||
groups: any = {};
|
||||
id?: number;
|
||||
name?: string;
|
||||
externalId?: string;
|
||||
status?: string;
|
||||
groups?: any = {};
|
||||
|
||||
constructor(obj?: any) {
|
||||
this.id = obj && obj.id;
|
||||
|
@@ -142,7 +142,7 @@ describe('Activiti Task filter Service', () => {
|
||||
'status': 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({
|
||||
appId: 1001, id: '111', name: 'Involved Tasks', icon: 'fake-icon', recent: false
|
||||
appId: 1001, id: 111, name: 'Involved Tasks', icon: 'fake-icon', recent: false
|
||||
})
|
||||
});
|
||||
|
||||
@@ -150,7 +150,7 @@ describe('Activiti Task filter Service', () => {
|
||||
'status': 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({
|
||||
appId: 1001, id: '222', name: 'My Tasks', icon: 'fake-icon', recent: false
|
||||
appId: 1001, id: 222, name: 'My Tasks', icon: 'fake-icon', recent: false
|
||||
})
|
||||
});
|
||||
|
||||
@@ -158,7 +158,7 @@ describe('Activiti Task filter Service', () => {
|
||||
'status': 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({
|
||||
appId: 1001, id: '333', name: 'Queued Tasks', icon: 'fake-icon', recent: false
|
||||
appId: 1001, id: 333, name: 'Queued Tasks', icon: 'fake-icon', recent: false
|
||||
})
|
||||
});
|
||||
|
||||
@@ -166,7 +166,7 @@ describe('Activiti Task filter Service', () => {
|
||||
'status': 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({
|
||||
appId: 1001, id: '444', name: 'Completed Tasks', icon: 'fake-icon', recent: false
|
||||
appId: 1001, id: 444, name: 'Completed Tasks', icon: 'fake-icon', recent: false
|
||||
})
|
||||
});
|
||||
});
|
||||
|
@@ -390,7 +390,7 @@ describe('Activiti TaskList Service', () => {
|
||||
|
||||
it('should assign task to a userId', (done) => {
|
||||
let testTaskId = '8888';
|
||||
service.assignTaskByUserId(testTaskId, fakeUser2.id).subscribe((res: TaskDetailsModel) => {
|
||||
service.assignTaskByUserId(testTaskId, fakeUser2.id.toString()).subscribe((res: TaskDetailsModel) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(res.id).toEqual(testTaskId);
|
||||
expect(res.name).toEqual('FakeNameTask');
|
||||
|
@@ -23,6 +23,10 @@ import { FilterRepresentationModel, TaskQueryRequestRepresentationModel } from '
|
||||
import { Form } from '../models/form.model';
|
||||
import { TaskDetailsModel } from '../models/task-details.model';
|
||||
import { TaskListModel } from '../models/task-list.model';
|
||||
import {
|
||||
TaskQueryRepresentation,
|
||||
AssigneeIdentifierRepresentation
|
||||
} from '@alfresco/js-api';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -85,7 +89,7 @@ export class TaskListService {
|
||||
* @returns List of tasks
|
||||
*/
|
||||
getTasks(requestNode: TaskQueryRequestRepresentationModel): Observable<TaskListModel> {
|
||||
return from<TaskListModel>(this.callApiTasksFiltered(requestNode))
|
||||
return from(this.callApiTasksFiltered(requestNode))
|
||||
.pipe(
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
@@ -318,8 +322,8 @@ export class TaskListService {
|
||||
* @param userId ID of the user to assign the task to
|
||||
* @returns Details of the assigned task
|
||||
*/
|
||||
assignTaskByUserId(taskId: string, userId: number): Observable<TaskDetailsModel> {
|
||||
const assignee = { assignee: userId };
|
||||
assignTaskByUserId(taskId: string, userId: string): Observable<TaskDetailsModel> {
|
||||
const assignee = <AssigneeIdentifierRepresentation> { assignee: userId };
|
||||
return from(this.callApiAssignTask(taskId, assignee))
|
||||
.pipe(
|
||||
map((response: TaskDetailsModel) => {
|
||||
@@ -392,35 +396,35 @@ export class TaskListService {
|
||||
);
|
||||
}
|
||||
|
||||
private callApiTasksFiltered(requestNode: TaskQueryRequestRepresentationModel) {
|
||||
private callApiTasksFiltered(requestNode: TaskQueryRepresentation): Promise<TaskListModel> {
|
||||
return this.apiService.taskApi.listTasks(requestNode);
|
||||
}
|
||||
|
||||
private callApiTaskDetails(taskId: string) {
|
||||
private callApiTaskDetails(taskId: string): Promise<TaskDetailsModel> {
|
||||
return this.apiService.taskApi.getTask(taskId);
|
||||
}
|
||||
|
||||
private callApiAddTask(task: TaskDetailsModel) {
|
||||
private callApiAddTask(task: TaskDetailsModel): Promise<TaskDetailsModel> {
|
||||
return this.apiService.taskApi.addSubtask(task.parentTaskId, task);
|
||||
}
|
||||
|
||||
private callApiDeleteTask(taskId: string) {
|
||||
private callApiDeleteTask(taskId: string): Promise<any> {
|
||||
return this.apiService.taskApi.deleteTask(taskId);
|
||||
}
|
||||
|
||||
private callApiDeleteForm(taskId: string) {
|
||||
private callApiDeleteForm(taskId: string): Promise<any> {
|
||||
return this.apiService.taskApi.removeForm(taskId);
|
||||
}
|
||||
|
||||
private callApiTaskChecklist(taskId: string) {
|
||||
private callApiTaskChecklist(taskId: string): Promise<TaskListModel> {
|
||||
return this.apiService.taskApi.getChecklist(taskId);
|
||||
}
|
||||
|
||||
private callApiCreateTask(task: TaskDetailsModel) {
|
||||
private callApiCreateTask(task: TaskDetailsModel): Promise<TaskDetailsModel> {
|
||||
return this.apiService.taskApi.createNewTask(task);
|
||||
}
|
||||
|
||||
private callApiAssignTask(taskId: string, requestNode: any) {
|
||||
private callApiAssignTask(taskId: string, requestNode: AssigneeIdentifierRepresentation): Promise<TaskDetailsModel> {
|
||||
return this.apiService.taskApi.assignTask(taskId, requestNode);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user