mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Select the first filter as default
This commit is contained in:
@@ -14,7 +14,8 @@
|
|||||||
<div class="mdl-grid">
|
<div class="mdl-grid">
|
||||||
<div class="mdl-cell mdl-cell--2-col task-column mdl-shadow--2dp">
|
<div class="mdl-cell mdl-cell--2-col task-column mdl-shadow--2dp">
|
||||||
<span>Task Filters</span>
|
<span>Task Filters</span>
|
||||||
<activiti-filters [appId]="appId" (filterClick)="onTaskFilterClick($event)" #activitifilter></activiti-filters>
|
<activiti-filters [appId]="appId" (filterClick)="onTaskFilterClick($event)" (onSuccess)="onSuccessTaskFilterList($event)"
|
||||||
|
#activitifilter></activiti-filters>
|
||||||
</div>
|
</div>
|
||||||
<div class="mdl-cell mdl-cell--3-col task-column mdl-shadow--2dp">
|
<div class="mdl-cell mdl-cell--3-col task-column mdl-shadow--2dp">
|
||||||
<span>Task List</span>
|
<span>Task List</span>
|
||||||
@@ -38,7 +39,8 @@
|
|||||||
<span>Process Filters</span>
|
<span>Process Filters</span>
|
||||||
<activiti-start-process-instance [appId]="appId"></activiti-start-process-instance>
|
<activiti-start-process-instance [appId]="appId"></activiti-start-process-instance>
|
||||||
<activiti-process-instance-filters [appId]="appId"
|
<activiti-process-instance-filters [appId]="appId"
|
||||||
(filterClick)="onProcessFilterClick($event)"></activiti-process-instance-filters>
|
(filterClick)="onProcessFilterClick($event)" (onSuccess)="onSuccessProcessFilterList($event)"
|
||||||
|
#activitiprocessfilter></activiti-process-instance-filters>
|
||||||
</div>
|
</div>
|
||||||
<div class="mdl-cell mdl-cell--3-col task-column">
|
<div class="mdl-cell mdl-cell--3-col task-column">
|
||||||
<span>Process List</span>
|
<span>Process List</span>
|
||||||
|
@@ -53,6 +53,9 @@ export class ActivitiDemoComponent implements AfterViewChecked {
|
|||||||
@ViewChild('activititasklist')
|
@ViewChild('activititasklist')
|
||||||
activititasklist: any;
|
activititasklist: any;
|
||||||
|
|
||||||
|
@ViewChild('activitiprocessfilter')
|
||||||
|
activitiprocessfilter: any;
|
||||||
|
|
||||||
@ViewChild('activitiprocesslist')
|
@ViewChild('activitiprocesslist')
|
||||||
activitiprocesslist: any;
|
activitiprocesslist: any;
|
||||||
|
|
||||||
@@ -120,6 +123,10 @@ export class ActivitiDemoComponent implements AfterViewChecked {
|
|||||||
this.taskFilter = event;
|
this.taskFilter = event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onSuccessTaskFilterList(event: any) {
|
||||||
|
this.taskFilter = this.activitifilter.getCurrentFilter();
|
||||||
|
}
|
||||||
|
|
||||||
onSuccessTaskList(event: UserTaskFilterRepresentationModel) {
|
onSuccessTaskList(event: UserTaskFilterRepresentationModel) {
|
||||||
this.currentTaskId = this.activititasklist.getCurrentTaskId();
|
this.currentTaskId = this.activititasklist.getCurrentTaskId();
|
||||||
}
|
}
|
||||||
@@ -128,6 +135,10 @@ export class ActivitiDemoComponent implements AfterViewChecked {
|
|||||||
this.processFilter = event;
|
this.processFilter = event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onSuccessProcessFilterList(event: any) {
|
||||||
|
this.processFilter = this.activitiprocessfilter.getCurrentFilter();
|
||||||
|
}
|
||||||
|
|
||||||
onSuccessProcessList(event: any) {
|
onSuccessProcessList(event: any) {
|
||||||
this.currentProcessInstanceId = this.activitiprocesslist.getCurrentProcessId();
|
this.currentProcessInstanceId = this.activitiprocesslist.getCurrentProcessId();
|
||||||
}
|
}
|
||||||
|
@@ -107,6 +107,7 @@ export class ActivitiProcessFilters implements OnInit, OnChanges {
|
|||||||
res.forEach((filter) => {
|
res.forEach((filter) => {
|
||||||
this.filterObserver.next(filter);
|
this.filterObserver.next(filter);
|
||||||
});
|
});
|
||||||
|
this.selectFirstFilter();
|
||||||
this.onSuccess.emit(res);
|
this.onSuccess.emit(res);
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
@@ -120,6 +121,7 @@ export class ActivitiProcessFilters implements OnInit, OnChanges {
|
|||||||
this.activiti.getDeployedApplications(this.appName).subscribe(
|
this.activiti.getDeployedApplications(this.appName).subscribe(
|
||||||
application => {
|
application => {
|
||||||
this.filterByAppId(application.id);
|
this.filterByAppId(application.id);
|
||||||
|
this.selectFirstFilter();
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
@@ -136,6 +138,33 @@ export class ActivitiProcessFilters implements OnInit, OnChanges {
|
|||||||
this.filterClick.emit(filter);
|
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
|
* Reset the filters properties
|
||||||
*/
|
*/
|
||||||
|
@@ -106,6 +106,7 @@ export class ActivitiFilters implements OnInit, OnChanges {
|
|||||||
(res: FilterRepresentationModel[]) => {
|
(res: FilterRepresentationModel[]) => {
|
||||||
res.forEach((filter) => {
|
res.forEach((filter) => {
|
||||||
this.filterObserver.next(filter);
|
this.filterObserver.next(filter);
|
||||||
|
this.selectFirstFilter();
|
||||||
});
|
});
|
||||||
this.onSuccess.emit(res);
|
this.onSuccess.emit(res);
|
||||||
},
|
},
|
||||||
@@ -120,6 +121,7 @@ export class ActivitiFilters implements OnInit, OnChanges {
|
|||||||
this.activiti.getDeployedApplications(this.appName).subscribe(
|
this.activiti.getDeployedApplications(this.appName).subscribe(
|
||||||
application => {
|
application => {
|
||||||
this.filterByAppId(application.id);
|
this.filterByAppId(application.id);
|
||||||
|
this.selectFirstFilter();
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
@@ -136,6 +138,33 @@ export class ActivitiFilters implements OnInit, OnChanges {
|
|||||||
this.filterClick.emit(filter);
|
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
|
* Reset the filters properties
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user