mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
Merge pull request #717 from Alfresco/dev-mvitale-673
Add first task selection on filter change
This commit is contained in:
commit
de099e505e
@ -18,7 +18,8 @@
|
||||
<div class="mdl-cell mdl-cell--3-col task-column mdl-shadow--2dp">
|
||||
<span>Task List</span>
|
||||
<activiti-tasklist *ngIf="isTaskListSelected()" [taskFilter]="taskFilter" [schemaColumn]="taskSchemaColumns"
|
||||
(rowClick)="onTaskRowClick($event)" #activititasklist></activiti-tasklist>
|
||||
(rowClick)="onTaskRowClick($event)" (onSuccess)="onSuccessTaskList($event)"
|
||||
#activititasklist></activiti-tasklist>
|
||||
</div>
|
||||
<div class="mdl-cell mdl-cell--7-col task-column mdl-shadow--2dp">
|
||||
<span>Task Details</span>
|
||||
|
@ -85,6 +85,11 @@ export class ActivitiDemoComponent implements AfterViewChecked {
|
||||
this.activititasklist.load(this.taskFilter.filter);
|
||||
}
|
||||
|
||||
onSuccessTaskList(event: any) {
|
||||
this.currentTaskId = this.activititasklist.getCurrentTaskId();
|
||||
this.activitidetails.loadDetails(this.currentTaskId);
|
||||
}
|
||||
|
||||
onProcessFilterClick(event: any) {
|
||||
this.processFilter = event.filter;
|
||||
this.activitiprocesslist.load(this.processFilter);
|
||||
|
@ -110,6 +110,17 @@ export class ActivitiTaskDetails implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the task detail to undefined
|
||||
*/
|
||||
reset() {
|
||||
this.taskDetails = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the activiti task details
|
||||
* @param taskId
|
||||
*/
|
||||
loadDetails(taskId: string) {
|
||||
this.taskForm = null;
|
||||
this.taskPeople = [];
|
||||
@ -142,10 +153,13 @@ export class ActivitiTaskDetails implements OnInit {
|
||||
}
|
||||
);
|
||||
} else {
|
||||
this.taskDetails = null;
|
||||
this.reset();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete the activiti task
|
||||
*/
|
||||
onComplete() {
|
||||
this.activitiTaskList.completeTask(this.taskId).subscribe(
|
||||
(res) => {
|
||||
@ -154,14 +168,26 @@ export class ActivitiTaskDetails implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emit the form saved event
|
||||
* @param data
|
||||
*/
|
||||
formSavedEmitter(data: any) {
|
||||
this.formSaved.emit(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emit the form completed event
|
||||
* @param data
|
||||
*/
|
||||
formCompletedEmitter(data: any) {
|
||||
this.formCompleted.emit(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emit the form loaded event
|
||||
* @param data
|
||||
*/
|
||||
formLoadedEmitter(data: any) {
|
||||
this.formLoaded.emit(data);
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ export class ActivitiTaskList implements OnInit {
|
||||
this.activiti.getTasks(filterParam).subscribe(
|
||||
(response) => {
|
||||
this.renderTasks(response.data);
|
||||
this.selectFirstTask();
|
||||
this.onSuccess.emit(response);
|
||||
}, (error) => {
|
||||
console.error(error);
|
||||
@ -115,6 +116,25 @@ export class ActivitiTaskList implements OnInit {
|
||||
this.tasks = new ObjectDataTableAdapter(tasks, this.data.getColumns());
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the first task of a tasklist if present
|
||||
*/
|
||||
private selectFirstTask() {
|
||||
if (!this.isTaskListEmpty()) {
|
||||
this.currentTaskId = this.tasks.getRows()[0].getValue('id');
|
||||
} else {
|
||||
this.currentTaskId = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current task
|
||||
* @returns {string}
|
||||
*/
|
||||
getCurrentTaskId(): string {
|
||||
return this.currentTaskId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the tasks list is empty
|
||||
* @returns {ObjectDataTableAdapter|boolean}
|
||||
|
Loading…
x
Reference in New Issue
Block a user