From 50e5e7a36a755a46158bde83452da0f3d770cc64 Mon Sep 17 00:00:00 2001 From: Deepak Paul Date: Wed, 1 Aug 2018 14:09:53 +0530 Subject: [PATCH] [ADF-3308] ProcessList Component - Provide a way to filter the list by fields (#3629) * [ADF-3308] Removed name input added two inputs * * [ADF-3308] Modified demo component * [ADF-3367] Modified docs * [ADF-3308] Added tests * [ADF-3308] Deprecated processDefinitionKey property --- demo-shell/src/app.config.json | 16 +++- .../process-list-demo.component.html | 30 ++++--- .../process-list-demo.component.ts | 23 +++-- .../process-service.component.html | 1 - .../process-list.component.md | 4 +- lib/process-services/i18n/en.json | 3 +- .../components/process-list.component.spec.ts | 88 ++++++++++++++++++- .../components/process-list.component.ts | 29 ++++-- .../models/filter-process.model.ts | 2 + 9 files changed, 158 insertions(+), 38 deletions(-) diff --git a/demo-shell/src/app.config.json b/demo-shell/src/app.config.json index 7f0ce5d49b..cf5ac5aefa 100644 --- a/demo-shell/src/app.config.json +++ b/demo-shell/src/app.config.json @@ -501,10 +501,22 @@ "sortable": true }, { - "key": "created", + "key": "id", "type": "text", + "title": "ADF_PROCESS_LIST.PROPERTIES.ID", + "sortable": true + }, + { + "key": "processDefinitionId", + "type": "text", + "title": "ADF_PROCESS_LIST.PROPERTIES.PROCESS_DEFINITION_ID", + "sortable": true + }, + { + "key": "started", + "type": "date", "title": "ADF_PROCESS_LIST.PROPERTIES.CREATED", - "cssClass": "hidden", + "format": "timeAgo", "sortable": true } ] diff --git a/demo-shell/src/app/components/process-list-demo/process-list-demo.component.html b/demo-shell/src/app/components/process-list-demo/process-list-demo.component.html index 85cd1a6d3e..c6b1bf52a5 100644 --- a/demo-shell/src/app/components/process-list-demo/process-list-demo.component.html +++ b/demo-shell/src/app/components/process-list-demo/process-list-demo.component.html @@ -15,14 +15,6 @@ - - Process Name - - - ProcessDefinitionId - State + ProcessInstanceId + + + + + Status @@ -60,10 +60,18 @@ + [presetColumn]="presetColumn"> + + + +
{{getStatus(entry.row.obj.ended)}}
+
+
+
{ component.ngOnChanges({'sort': change}); }); - it('should reload the process list when the name parameter changes', (done) => { - const name = 'FakeTaskName'; - let change = new SimpleChange(null, name, true); + it('should reload the process list when the processDefinitionKey parameter changes', (done) => { + const processDefinitionKey = 'SimpleProcess'; + let change = new SimpleChange(null, processDefinitionKey, true); component.success.subscribe((res) => { expect(res).toBeDefined(); @@ -494,7 +494,87 @@ describe('ProcessInstanceListComponent', () => { done(); }); - component.ngOnChanges({'name': change}); + component.ngOnChanges({'processDefinitionKey': change}); + }); + + it('should reload the process list when the processDefinitionKey parameter changes to null', (done) => { + const processDefinitionKey = null; + let change = new SimpleChange('SimpleProcess', processDefinitionKey, false); + + component.success.subscribe((res) => { + expect(res).toBeDefined(); + expect(component.data).toBeDefined(); + expect(component.isListEmpty()).not.toBeTruthy(); + expect(component.data.getRows().length).toEqual(2); + expect(component.data.getRows()[0].getValue('name')).toEqual('Process 773443333'); + done(); + }); + + component.ngOnChanges({'processDefinitionKey': change}); + }); + + it('should reload the process list when the processDefinitionId parameter changes', (done) => { + const processDefinitionId = 'SimpleProcess:1:10'; + let change = new SimpleChange(null, processDefinitionId, true); + + component.success.subscribe((res) => { + expect(res).toBeDefined(); + expect(component.data).toBeDefined(); + expect(component.isListEmpty()).not.toBeTruthy(); + expect(component.data.getRows().length).toEqual(2); + expect(component.data.getRows()[0].getValue('name')).toEqual('Process 773443333'); + done(); + }); + + component.ngOnChanges({'processDefinitionId': change}); + }); + + it('should reload the process list when the processDefinitionId parameter changes to null', (done) => { + const processDefinitionId = null; + let change = new SimpleChange('SimpleProcess:1:10', processDefinitionId, false); + + component.success.subscribe((res) => { + expect(res).toBeDefined(); + expect(component.data).toBeDefined(); + expect(component.isListEmpty()).not.toBeTruthy(); + expect(component.data.getRows().length).toEqual(2); + expect(component.data.getRows()[0].getValue('name')).toEqual('Process 773443333'); + done(); + }); + + component.ngOnChanges({'processDefinitionId': change}); + }); + + it('should reload the process list when the processInstanceId parameter changes', (done) => { + const processInstanceId = '123'; + let change = new SimpleChange(null, processInstanceId, true); + + component.success.subscribe((res) => { + expect(res).toBeDefined(); + expect(component.data).toBeDefined(); + expect(component.isListEmpty()).not.toBeTruthy(); + expect(component.data.getRows().length).toEqual(2); + expect(component.data.getRows()[0].getValue('name')).toEqual('Process 773443333'); + done(); + }); + + component.ngOnChanges({'processInstanceId': change}); + }); + + it('should reload the process list when the processInstanceId parameter changes to null', (done) => { + const processInstanceId = null; + let change = new SimpleChange('123', processInstanceId, false); + + component.success.subscribe((res) => { + expect(res).toBeDefined(); + expect(component.data).toBeDefined(); + expect(component.isListEmpty()).not.toBeTruthy(); + expect(component.data.getRows().length).toEqual(2); + expect(component.data.getRows()[0].getValue('name')).toEqual('Process 773443333'); + done(); + }); + + component.ngOnChanges({'processInstanceId': change}); }); }); }); diff --git a/lib/process-services/process-list/components/process-list.component.ts b/lib/process-services/process-list/components/process-list.component.ts index f1d52e4e88..e0786e2db9 100644 --- a/lib/process-services/process-list/components/process-list.component.ts +++ b/lib/process-services/process-list/components/process-list.component.ts @@ -69,10 +69,20 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit @Input() appId: number; - /** The processDefinitionKey of the process. */ + /** The Definition Key of the process. + * @deprecated 2.4.0 + */ @Input() processDefinitionKey: string; + /** The Definition Id of the process. */ + @Input() + processDefinitionId: string; + + /** The id of the process instance. */ + @Input() + processInstanceId: number|string; + /** Defines the state of the processes. Possible values are `running`, `completed` and `all` */ @Input() state: string; @@ -83,10 +93,6 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit @Input() sort: string; - /** The name of the list. */ - @Input() - name: string; - /** The page number of the processes to fetch. */ @Input() page: number = 0; @@ -191,22 +197,25 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit let appId = changes['appId']; let processDefinitionKey = changes['processDefinitionKey']; + let processDefinitionId = changes['processDefinitionId']; + let processInstanceId = changes['processInstanceId']; let state = changes['state']; let sort = changes['sort']; - let name = changes['name']; let page = changes['page']; let size = changes['size']; if (appId && appId.currentValue) { changed = true; - } else if (processDefinitionKey && processDefinitionKey.currentValue) { + } else if (processDefinitionKey) { + changed = true; + } else if (processDefinitionId) { + changed = true; + } else if (processInstanceId) { changed = true; } else if (state && state.currentValue) { changed = true; } else if (sort && sort.currentValue) { changed = true; - } else if (name && name.currentValue) { - changed = true; } else if (page && page.currentValue !== page.previousValue) { changed = true; } else if (size && size.currentValue !== size.previousValue) { @@ -371,6 +380,8 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit private createRequestNode() { let requestNode = { appDefinitionId: this.appId, + processDefinitionId: this.processDefinitionId, + processInstanceId: this.processInstanceId, state: this.state, sort: this.sort, page: this.page, diff --git a/lib/process-services/process-list/models/filter-process.model.ts b/lib/process-services/process-list/models/filter-process.model.ts index 3464bd229a..8b191ca393 100644 --- a/lib/process-services/process-list/models/filter-process.model.ts +++ b/lib/process-services/process-list/models/filter-process.model.ts @@ -49,6 +49,7 @@ export class FilterProcessRepresentationModel implements UserProcessInstanceFilt export class ProcessFilterParamRepresentationModel implements ProcessFilterRequestRepresentation { processDefinitionId?: number; + processInstanceId?: number|string; appDefinitionId?: number; state?: string; sort?: string; @@ -58,6 +59,7 @@ export class ProcessFilterParamRepresentationModel implements ProcessFilterReque constructor(obj?: any) { this.processDefinitionId = obj.processDefinitionId || null; this.appDefinitionId = obj.appDefinitionId || null; + this.processInstanceId = obj.processInstanceId || null; this.state = obj.state || null; this.sort = obj.sort || null; this.page = obj.page || null;