mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Fix the activiti processes using the appId
This commit is contained in:
@@ -15,11 +15,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
||||
import {Component, OnInit, Input, Output, EventEmitter, OnChanges, SimpleChanges } from '@angular/core';
|
||||
import { AlfrescoPipeTranslate, AlfrescoTranslationService, CONTEXT_MENU_DIRECTIVES, CONTEXT_MENU_PROVIDERS } from 'ng2-alfresco-core';
|
||||
import { ALFRESCO_DATATABLE_DIRECTIVES, ObjectDataTableAdapter, DataRowEvent } from 'ng2-alfresco-datatable';
|
||||
import { ActivitiProcessService } from '../services/activiti-process.service';
|
||||
import { FilterModel } from '../models/filter.model';
|
||||
import { UserProcessInstanceFilterRepresentationModel, TaskQueryRequestRepresentationModel } from '../models/filter.model';
|
||||
|
||||
declare let __moduleName: string;
|
||||
|
||||
@@ -38,14 +38,14 @@ declare let __moduleName: string;
|
||||
pipes: [ AlfrescoPipeTranslate ],
|
||||
providers: [ CONTEXT_MENU_PROVIDERS, ActivitiProcessService ]
|
||||
})
|
||||
export class ActivitiProcessInstanceListComponent implements OnInit {
|
||||
export class ActivitiProcessInstanceListComponent implements OnInit, OnChanges {
|
||||
|
||||
errorMessage: string;
|
||||
data: ObjectDataTableAdapter;
|
||||
currentProcessInstanceId: string;
|
||||
|
||||
@Input()
|
||||
filter: FilterModel;
|
||||
filter: UserProcessInstanceFilterRepresentationModel;
|
||||
|
||||
@Input()
|
||||
schemaColumn: any[] = [
|
||||
@@ -76,15 +76,26 @@ export class ActivitiProcessInstanceListComponent implements OnInit {
|
||||
this.schemaColumn
|
||||
);
|
||||
if (this.filter) {
|
||||
this.load(this.filter);
|
||||
let requestNode = this.convertProcessInstanceToTaskQuery(this.filter);
|
||||
this.load(requestNode);
|
||||
}
|
||||
}
|
||||
|
||||
load(filter: FilterModel) {
|
||||
this.processService.getProcessInstances(filter)
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
let filter = changes['filter'];
|
||||
if (filter && filter.currentValue) {
|
||||
let requestNode = this.convertProcessInstanceToTaskQuery(filter.currentValue);
|
||||
this.load(requestNode);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
load(requestNode: TaskQueryRequestRepresentationModel) {
|
||||
this.processService.getProcessInstances(requestNode)
|
||||
.subscribe(
|
||||
(processInstances) => {
|
||||
this.renderProcessInstances(processInstances);
|
||||
this.selectFirstProcess();
|
||||
this.onSuccess.emit(processInstances);
|
||||
},
|
||||
error => {
|
||||
@@ -93,10 +104,6 @@ export class ActivitiProcessInstanceListComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
reload() {
|
||||
this.load(this.filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the process list
|
||||
*
|
||||
@@ -110,6 +117,25 @@ export class ActivitiProcessInstanceListComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the first process of a process list if present
|
||||
*/
|
||||
private selectFirstProcess() {
|
||||
if (!this.isListEmpty()) {
|
||||
this.currentProcessInstanceId = this.data.getRows()[0].getValue('id');
|
||||
} else {
|
||||
this.currentProcessInstanceId = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current process
|
||||
* @returns {string}
|
||||
*/
|
||||
getCurrentProcessId(): string {
|
||||
return this.currentProcessInstanceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the list is empty
|
||||
* @returns {ObjectDataTableAdapter|boolean}
|
||||
@@ -144,4 +170,13 @@ export class ActivitiProcessInstanceListComponent implements OnInit {
|
||||
});
|
||||
return tasks;
|
||||
}
|
||||
|
||||
private convertProcessInstanceToTaskQuery(processFilter: UserProcessInstanceFilterRepresentationModel) {
|
||||
let requestNode = {appDefinitionId: processFilter.appId,
|
||||
processDefinitionKey: processFilter.filter.processDefinitionKey,
|
||||
text: processFilter.filter.name,
|
||||
state: processFilter.filter.state,
|
||||
sort: processFilter.filter.sort};
|
||||
return new TaskQueryRequestRepresentationModel(requestNode);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user