diff --git a/demo-shell-ng2/app/components/activiti/activiti-demo.component.html b/demo-shell-ng2/app/components/activiti/activiti-demo.component.html index 74a467dadb..c7d1065331 100644 --- a/demo-shell-ng2/app/components/activiti/activiti-demo.component.html +++ b/demo-shell-ng2/app/components/activiti/activiti-demo.component.html @@ -14,7 +14,8 @@
Task Filters - +
Task List @@ -38,7 +39,8 @@ Process Filters + (filterClick)="onProcessFilterClick($event)" (onSuccess)="onSuccessProcessFilterList($event)" + #activitiprocessfilter>
Process List diff --git a/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts b/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts index 0a8a0e3a87..202cf792d5 100644 --- a/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts +++ b/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts @@ -53,6 +53,9 @@ export class ActivitiDemoComponent implements AfterViewChecked { @ViewChild('activititasklist') activititasklist: any; + @ViewChild('activitiprocessfilter') + activitiprocessfilter: any; + @ViewChild('activitiprocesslist') activitiprocesslist: any; @@ -120,6 +123,10 @@ export class ActivitiDemoComponent implements AfterViewChecked { this.taskFilter = event; } + onSuccessTaskFilterList(event: any) { + this.taskFilter = this.activitifilter.getCurrentFilter(); + } + onSuccessTaskList(event: UserTaskFilterRepresentationModel) { this.currentTaskId = this.activititasklist.getCurrentTaskId(); } @@ -128,6 +135,10 @@ export class ActivitiDemoComponent implements AfterViewChecked { this.processFilter = event; } + onSuccessProcessFilterList(event: any) { + this.processFilter = this.activitiprocessfilter.getCurrentFilter(); + } + onSuccessProcessList(event: any) { this.currentProcessInstanceId = this.activitiprocesslist.getCurrentProcessId(); } diff --git a/ng2-components/ng2-activiti-processlist/src/components/activiti-filters.component.ts b/ng2-components/ng2-activiti-processlist/src/components/activiti-filters.component.ts index 1bba2ba77c..1ab8b8bb26 100644 --- a/ng2-components/ng2-activiti-processlist/src/components/activiti-filters.component.ts +++ b/ng2-components/ng2-activiti-processlist/src/components/activiti-filters.component.ts @@ -107,6 +107,7 @@ export class ActivitiProcessFilters implements OnInit, OnChanges { res.forEach((filter) => { this.filterObserver.next(filter); }); + this.selectFirstFilter(); this.onSuccess.emit(res); }, (err) => { @@ -120,6 +121,7 @@ export class ActivitiProcessFilters implements OnInit, OnChanges { this.activiti.getDeployedApplications(this.appName).subscribe( application => { this.filterByAppId(application.id); + this.selectFirstFilter(); }, (err) => { console.log(err); @@ -136,6 +138,33 @@ export class ActivitiProcessFilters implements OnInit, OnChanges { this.filterClick.emit(filter); } + /** + * Select the first filter of a list if present + */ + private selectFirstFilter() { + if (!this.isFilterListEmpty()) { + this.currentFilter = this.filters[0]; + } else { + this.currentFilter = null; + } + } + + /** + * Return the current task + * @returns {FilterRepresentationModel} + */ + getCurrentFilter(): FilterRepresentationModel { + return this.currentFilter; + } + + /** + * Check if the filter list is empty + * @returns {boolean} + */ + isFilterListEmpty(): boolean { + return this.filters === undefined || (this.filters && this.filters.length === 0); + } + /** * Reset the filters properties */ diff --git a/ng2-components/ng2-activiti-tasklist/src/components/activiti-filters.component.ts b/ng2-components/ng2-activiti-tasklist/src/components/activiti-filters.component.ts index 0b2562fab9..af745679ba 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/activiti-filters.component.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/activiti-filters.component.ts @@ -106,6 +106,7 @@ export class ActivitiFilters implements OnInit, OnChanges { (res: FilterRepresentationModel[]) => { res.forEach((filter) => { this.filterObserver.next(filter); + this.selectFirstFilter(); }); this.onSuccess.emit(res); }, @@ -120,6 +121,7 @@ export class ActivitiFilters implements OnInit, OnChanges { this.activiti.getDeployedApplications(this.appName).subscribe( application => { this.filterByAppId(application.id); + this.selectFirstFilter(); }, (err) => { console.log(err); @@ -136,6 +138,33 @@ export class ActivitiFilters implements OnInit, OnChanges { this.filterClick.emit(filter); } + /** + * Select the first filter of a list if present + */ + private selectFirstFilter() { + if (!this.isFilterListEmpty()) { + this.currentFilter = this.filters[0]; + } else { + this.currentFilter = null; + } + } + + /** + * Return the current task + * @returns {FilterRepresentationModel} + */ + getCurrentFilter(): FilterRepresentationModel { + return this.currentFilter; + } + + /** + * Check if the filter list is empty + * @returns {boolean} + */ + isFilterListEmpty(): boolean { + return this.filters === undefined || (this.filters && this.filters.length === 0); + } + /** * Reset the filters properties */