[ACA-3623] Process definition name filter in task list (#5871)

* [ACA-3623] Process definition name filter in task list

* Added unit test

* Aligning with changes in process list

* Added all option
This commit is contained in:
Mercy Chrysolite 2020-09-14 13:01:19 +05:30 committed by GitHub
parent 0d607ba0bd
commit a64e13bec5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 123 additions and 41 deletions

View File

@ -48,40 +48,40 @@ when the process list is empty:
### Properties
| Name | Type | Default value | Description |
| ---- | ---- | ------------- | ----------- |
| actionsPosition | `string` | "right" | Position of the actions dropdown menu. Can be "left" or "right". |
| appName | `string` | "" | The name of the application. |
| appVersion | `number` | | The release version of the application. |
| businessKey | `string` | "" | Filter the processes to display only the ones with this businessKey value. |
| id | `string` | "" | Filter the processes to display only the ones with this ID. |
| initiator | `string` | "" | Name of the initiator of the process. |
| lastModifiedFrom | `string` | "" | Filter the processes. Display only process with lastModifiedTo equal to the supplied date. |
| lastModifiedTo | `string` | "" | Filter the processes. Display only process with lastModifiedTo equal to the supplied date. |
| multiselect | `boolean` | false | Toggles multiple row selection and renders checkboxes at the beginning of each row |
| name | `string` | "" | Filter the processes to display only the ones with this name. |
| presetColumn | `string` | | Custom preset column schema in JSON format. |
| processDefinitionId | `string` | "" | Filter the processes to display only the ones with this process definition ID. |
| processDefinitionKey | `string` | "" | Filter the processes to display only the ones with this process definition key. |
| processDefinitionName | `string` | "" | Filter the processes to display only the ones with this process definition name. |
| selectionMode | `string` | "single" | Row selection mode. Can be "none", "single" or "multiple". For multiple mode, you can use Cmd (macOS) or Ctrl (Win) modifier key to toggle selection for multiple rows. |
| showActions | `boolean` | false | Toggles the data actions column. |
| showContextMenu | `boolean` | false | Toggles custom context menu for the component. |
| sorting | [`ProcessListCloudSortingModel`](../../../lib/process-services-cloud/src/lib/process/process-list/models/process-list-sorting.model.ts)`[]` | | Array of objects specifying the sort order and direction for the list. The sort parameters are for BE sorting. |
| status | `string` | "" | Filter the processes to display only the ones with this status. |
| stickyHeader | `boolean` | false | Toggles the sticky header mode. |
| Name | Type | Default value | Description |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| actionsPosition | `string` | "right" | Position of the actions dropdown menu. Can be "left" or "right". |
| appName | `string` | "" | The name of the application. |
| appVersion | `number` | | The release version of the application. |
| businessKey | `string` | "" | Filter the processes to display only the ones with this businessKey value. |
| id | `string` | "" | Filter the processes to display only the ones with this ID. |
| initiator | `string` | "" | Name of the initiator of the process. |
| lastModifiedFrom | `string` | "" | Filter the processes. Display only process with lastModifiedTo equal to the supplied date. |
| lastModifiedTo | `string` | "" | Filter the processes. Display only process with lastModifiedTo equal to the supplied date. |
| multiselect | `boolean` | false | Toggles multiple row selection and renders checkboxes at the beginning of each row |
| name | `string` | "" | Filter the processes to display only the ones with this name. |
| presetColumn | `string` | | Custom preset column schema in JSON format. |
| processDefinitionId | `string` | "" | Filter the processes to display only the ones with this process definition ID. |
| processDefinitionKey | `string` | "" | Filter the processes to display only the ones with this process definition key. |
| processDefinitionName | `string` | "" | Filter the processes to display only the ones with this process definition name. |
| selectionMode | `string` | "single" | Row selection mode. Can be "none", "single" or "multiple". For multiple mode, you can use Cmd (macOS) or Ctrl (Win) modifier key to toggle selection for multiple rows. |
| showActions | `boolean` | false | Toggles the data actions column. |
| showContextMenu | `boolean` | false | Toggles custom context menu for the component. |
| sorting | [`ProcessListCloudSortingModel`](../../../lib/process-services-cloud/src/lib/process/process-list/models/process-list-sorting.model.ts)`[]` | | Array of objects specifying the sort order and direction for the list. The sort parameters are for BE sorting. |
| status | `string` | "" | Filter the processes to display only the ones with this status. |
| stickyHeader | `boolean` | false | Toggles the sticky header mode. |
### Events
| Name | Type | Description |
| ---- | ---- | ----------- |
| error | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<any>` | Emitted when an error occurs while loading the list of process instances from the server. |
| executeRowAction | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`DataRowActionEvent`](../../../lib/core/datatable/components/data-row-action.event.ts)`>` | Emitted when the user executes a row action. |
| rowClick | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<string>` | Emitted when a row in the process list is clicked. |
| rowsSelected | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<any[]>` | Emitted when rows are selected/unselected. |
| showRowActionsMenu | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`DataCellEvent`](../../../lib/core/datatable/components/data-cell.event.ts)`>` | Emitted before the actions menu is displayed for a row. |
| showRowContextMenu | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`DataCellEvent`](../../../lib/core/datatable/components/data-cell.event.ts)`>` | Emitted before the context menu is displayed for a row. |
| success | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<any>` | Emitted when the list of process instances has been loaded successfully from the server. |
| Name | Type | Description |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| error | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<any>` | Emitted when an error occurs while loading the list of process instances from the server. |
| executeRowAction | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`DataRowActionEvent`](../../../lib/core/datatable/components/data-row-action.event.ts)`>` | Emitted when the user executes a row action. |
| rowClick | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<string>` | Emitted when a row in the process list is clicked. |
| rowsSelected | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<any[]>` | Emitted when rows are selected/unselected. |
| showRowActionsMenu | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`DataCellEvent`](../../../lib/core/datatable/components/data-cell.event.ts)`>` | Emitted before the actions menu is displayed for a row. |
| showRowContextMenu | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`DataCellEvent`](../../../lib/core/datatable/components/data-cell.event.ts)`>` | Emitted before the context menu is displayed for a row. |
| success | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<any>` | Emitted when the list of process instances has been loaded successfully from the server. |
## Details

View File

@ -15,19 +15,18 @@ Gets process definitions and starts processes.
- **createProcess**(appName: `string`, payload: [`ProcessPayloadCloud`](../../../lib/process-services-cloud/src/lib/process/start-process/models/process-payload-cloud.model.ts)): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`ProcessInstanceCloud`](../../../lib/process-services-cloud/src/lib/process/start-process/models/process-instance-cloud.model.ts)`>`<br/>
Create a process based on a process definition, name, form values or variables.
- _appName:_ `string` - name of the [Application](../../../lib/testing/src/lib/core/structure/application.ts)
- _appName:_ `string` - name of the Application
- _payload:_ [`ProcessPayloadCloud`](../../../lib/process-services-cloud/src/lib/process/start-process/models/process-payload-cloud.model.ts) - Details of the process (definition key, name, variables, etc)
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`ProcessInstanceCloud`](../../../lib/process-services-cloud/src/lib/process/start-process/models/process-instance-cloud.model.ts)`>` - Details of the process instance just created
- **deleteProcess**(appName: `string`, processInstanceId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<void>`<br/>
Delete an existing process instance
- _appName:_ `string` - name of the [Application](../../../lib/testing/src/lib/core/structure/application.ts)
- _appName:_ `string` - name of the Application
- _processInstanceId:_ `string` - process instance to update
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<void>` -
- **getBasePath**(appName: `string`): `string`<br/>
- _appName:_ `string` -
- **Returns** `string` -
- **getProcessDefinitions**(appName: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`ProcessDefinitionCloud`](../../../lib/process-services-cloud/src/lib/models/process-definition-cloud.model.ts)`[]>`<br/>
Gets the process definitions associated with an app.
- _appName:_ `string` - Name of the target app
@ -40,12 +39,12 @@ Gets process definitions and starts processes.
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`ProcessInstanceCloud`](../../../lib/process-services-cloud/src/lib/process/start-process/models/process-instance-cloud.model.ts)`>` - Details of the process instance just started
- **startProcess**(appName: `string`, payload: [`ProcessPayloadCloud`](../../../lib/process-services-cloud/src/lib/process/start-process/models/process-payload-cloud.model.ts)): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`ProcessInstanceCloud`](../../../lib/process-services-cloud/src/lib/process/start-process/models/process-instance-cloud.model.ts)`>`<br/>
Starts a process based on a process definition, name, form values or variables.
- _appName:_ `string` - name of the [Application](../../../lib/testing/src/lib/core/structure/application.ts)
- _appName:_ `string` - name of the Application
- _payload:_ [`ProcessPayloadCloud`](../../../lib/process-services-cloud/src/lib/process/start-process/models/process-payload-cloud.model.ts) - Details of the process (definition key, name, variables, etc)
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`ProcessInstanceCloud`](../../../lib/process-services-cloud/src/lib/process/start-process/models/process-instance-cloud.model.ts)`>` - Details of the process instance just started
- **updateProcess**(appName: `string`, processInstanceId: `string`, payload: [`ProcessPayloadCloud`](../../../lib/process-services-cloud/src/lib/process/start-process/models/process-payload-cloud.model.ts)): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`ProcessInstanceCloud`](../../../lib/process-services-cloud/src/lib/process/start-process/models/process-instance-cloud.model.ts)`>`<br/>
Update an existing process instance
- _appName:_ `string` - name of the [Application](../../../lib/testing/src/lib/core/structure/application.ts)
- _appName:_ `string` - name of the Application
- _processInstanceId:_ `string` - process instance to update
- _payload:_ [`ProcessPayloadCloud`](../../../lib/process-services-cloud/src/lib/process/start-process/models/process-payload-cloud.model.ts) - Details of the process (definition key, name, variables, etc)
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`ProcessInstanceCloud`](../../../lib/process-services-cloud/src/lib/process/start-process/models/process-instance-cloud.model.ts)`>` - Details of the process instance just started

View File

@ -45,7 +45,6 @@ Manages task cloud.
- _appName:_ `string` -
- **Returns** `string` -
- **getCandidateGroups**(appName: `string`, taskId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<string[]>`<br/>
Gets candidate groups of the task.
- _appName:_ `string` - Name of the app
@ -56,6 +55,10 @@ Manages task cloud.
- _appName:_ `string` - Name of the app
- _taskId:_ `string` - ID of the task
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<string[]>` - Candidate users
- **getProcessDefinitions**(appName: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`ProcessDefinitionCloud`](../../../lib/process-services-cloud/src/lib/models/process-definition-cloud.model.ts)`[]>`<br/>
Gets the process definitions associated with an app.
- _appName:_ `string` - Name of the target app
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`ProcessDefinitionCloud`](../../../lib/process-services-cloud/src/lib/models/process-definition-cloud.model.ts)`[]>` - Array of process definitions
- **getTaskById**(appName: `string`, taskId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsCloudModel`](../../../lib/process-services-cloud/src/lib/task/start-task/models/task-details-cloud.model.ts)`>`<br/>
Gets details of a task.
- _appName:_ `string` - Name of the app

View File

@ -126,6 +126,7 @@
"LABEL": {
"APP_NAME": "ApplicationName",
"TASK_ID": "Task ID",
"PROCESS_DEF_NAME": "ProcessDefinitionName",
"PROCESS_DEF_ID": "ProcessDefinitionId",
"STATUS": "Status",
"ASSIGNMENT": "Assignee",

View File

@ -22,6 +22,7 @@ import { map } from 'rxjs/operators';
import { TaskDetailsCloudModel, StartTaskCloudResponseModel } from '../start-task/models/task-details-cloud.model';
import { BaseCloudService } from '../../services/base-cloud.service';
import { StartTaskCloudRequestModel } from '../start-task/models/start-task-cloud-request.model';
import { ProcessDefinitionCloud } from '../../models/process-definition-cloud.model';
@Injectable({
providedIn: 'root'
@ -236,6 +237,26 @@ export class TaskCloudService extends BaseCloudService {
}
}
/**
* Gets the process definitions associated with an app.
* @param appName Name of the target app
* @returns Array of process definitions
*/
getProcessDefinitions(appName: string): Observable<ProcessDefinitionCloud[]> {
if (appName || appName === '') {
const url = `${this.getBasePath(appName)}/rb/v1/process-definitions`;
return this.get(url).pipe(
map((res: any) => {
return res.list.entries.map((processDefs) => new ProcessDefinitionCloud(processDefs.entry));
})
);
} else {
this.logService.error('AppName is mandatory for querying task');
return throwError('AppName not configured');
}
}
private isAssignedToMe(assignee: string): boolean {
const currentUser = this.identityUserService.getCurrentUserInfo().username;
return assignee === currentUser;

View File

@ -31,6 +31,7 @@ import { fakeApplicationInstance } from '../../../app/mock/app-model.mock';
import { TaskFiltersCloudModule } from '../task-filters-cloud.module';
import { EditTaskFilterCloudComponent } from './edit-task-filter-cloud.component';
import { TaskFilterCloudService } from '../services/task-filter-cloud.service';
import { TaskCloudService } from '../../services/task-cloud.service';
import { TaskFilterDialogCloudComponent } from './task-filter-dialog-cloud.component';
import { fakeFilter } from '../mock/task-filters-cloud.mock';
import { AbstractControl } from '@angular/forms';
@ -45,6 +46,7 @@ describe('EditTaskFilterCloudComponent', () => {
let dialog: MatDialog;
let getTaskFilterSpy: jasmine.Spy;
let getRunningApplicationsSpy: jasmine.Spy;
let taskService: TaskCloudService;
setupTestBed({
imports: [
@ -63,6 +65,7 @@ describe('EditTaskFilterCloudComponent', () => {
component = fixture.componentInstance;
service = TestBed.inject(TaskFilterCloudService);
appsService = TestBed.inject(AppsProcessCloudService);
taskService = TestBed.inject(TaskCloudService);
dialog = TestBed.inject(MatDialog);
spyOn(dialog, 'open').and.returnValue({ afterClosed: of({
action: TaskFilterDialogCloudComponent.ACTION_SAVE,
@ -90,6 +93,22 @@ describe('EditTaskFilterCloudComponent', () => {
});
});
it('should fetch process definitions when processDefinitionName filter property is set', async(() => {
const processSpy = spyOn(taskService, 'getProcessDefinitions').and.returnValue(of([{ id: 'fake-id', name: 'fake-name' }]));
fixture.detectChanges();
component.filterProperties = ['processDefinitionName'];
fixture.detectChanges();
const taskFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange });
fixture.detectChanges();
const controller = component.editTaskFilterForm.get('processDefinitionName');
fixture.detectChanges();
fixture.whenStable().then(() => {
expect(processSpy).toHaveBeenCalled();
expect(controller).toBeDefined();
});
}));
it('should display filter name as title', async(() => {
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange });

View File

@ -31,6 +31,8 @@ import { TranslationService, UserPreferencesService, UserPreferenceValues } from
import { AppsProcessCloudService } from '../../../app/services/apps-process-cloud.service';
import { ApplicationInstanceModel } from '../../../app/models/application-instance.model';
import { DateCloudFilterType, DateRangeFilter } from '../../../models/date-cloud-filter.model';
import { ProcessDefinitionCloud } from '../../../models/process-definition-cloud.model';
import { TaskCloudService } from '../../services/task-cloud.service';
@Component({
selector: 'adf-cloud-edit-task-filter',
@ -44,6 +46,7 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro
public static ACTION_DELETE = 'delete';
public static APP_RUNNING_STATUS: string = 'RUNNING';
public static APPLICATION_NAME: string = 'appName';
public static PROCESS_DEFINITION_NAME: string = 'processDefinitionName';
public static LAST_MODIFIED: string = 'lastModified';
public static SORT: string = 'sort';
public static ORDER: string = 'order';
@ -116,8 +119,10 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro
EditTaskFilterCloudComponent.ACTION_SAVE,
EditTaskFilterCloudComponent.ACTION_DELETE
];
allProcessDefinitionNamesOption = { label: 'All', value: '' };
private applicationNames: any[] = [];
private processDefinitionNames: any[] = [];
private formHasBeenChanged = false;
editTaskFilterForm: FormGroup;
taskFilterProperties: TaskFilterProperties[] = [];
@ -134,7 +139,8 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro
private taskFilterCloudService: TaskFilterCloudService,
private dateAdapter: DateAdapter<Moment>,
private userPreferencesService: UserPreferencesService,
private appsProcessCloudService: AppsProcessCloudService) {
private appsProcessCloudService: AppsProcessCloudService,
private taskCloudService: TaskCloudService) {
}
ngOnInit() {
@ -227,10 +233,14 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro
createAndFilterProperties() {
this.checkMandatoryFilterProperties();
if (this.checkForApplicationNameProperty()) {
if (this.checkForProperty(EditTaskFilterCloudComponent.APPLICATION_NAME)) {
this.applicationNames = [];
this.getRunningApplications();
}
if (this.checkForProperty(EditTaskFilterCloudComponent.PROCESS_DEFINITION_NAME)) {
this.processDefinitionNames = [];
this.getProcessDefinitions();
}
const defaultProperties = this.createTaskFilterProperties(this.taskFilter);
let filteredProperties = defaultProperties.filter((filterProperty: TaskFilterProperties) => this.isValidProperty(this.filterProperties, filterProperty));
@ -255,8 +265,8 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro
return filterProperties ? filterProperties.indexOf(filterProperty.key) >= 0 : true;
}
checkForApplicationNameProperty(): boolean {
return this.filterProperties ? this.filterProperties.indexOf(EditTaskFilterCloudComponent.APPLICATION_NAME) >= 0 : false;
checkForProperty(property: string): boolean {
return this.filterProperties ? this.filterProperties.indexOf(property) >= 0 : false;
}
hasSortProperty(): boolean {
@ -359,6 +369,19 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro
});
}
getProcessDefinitions() {
this.taskCloudService.getProcessDefinitions(this.appName)
.pipe(takeUntil(this.onDestroy$))
.subscribe((processDefinitions: ProcessDefinitionCloud[]) => {
if (processDefinitions && processDefinitions.length > 0) {
this.processDefinitionNames.push(this.allProcessDefinitionNamesOption);
processDefinitions.map((processDefinition) => {
this.processDefinitionNames.push({ label: processDefinition.name, value: processDefinition.name });
});
}
});
}
executeFilterActions(action: TaskFilterAction): void {
if (action.actionType === EditTaskFilterCloudComponent.ACTION_SAVE) {
this.save(action);
@ -567,6 +590,13 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro
key: 'assignee',
value: currentTaskFilter.assignee || ''
}),
new TaskFilterProperties({
label: 'ADF_CLOUD_EDIT_TASK_FILTER.LABEL.PROCESS_DEF_NAME',
type: 'select',
key: 'processDefinitionName',
value: currentTaskFilter.processDefinitionName || '',
options: this.processDefinitionNames
}),
new TaskFilterProperties({
label: 'ADF_CLOUD_EDIT_TASK_FILTER.LABEL.PROCESS_INSTANCE_ID',
type: 'text',

View File

@ -29,6 +29,7 @@ export class TaskFilterCloudModel {
assignee: string;
order: string;
owner: string;
processDefinitionName?: string;
processDefinitionId: string;
processInstanceId: string;
createdDate: Date;
@ -56,6 +57,7 @@ export class TaskFilterCloudModel {
this.assignee = obj.assignee || null;
this.order = obj.order || null;
this.owner = obj.owner || null;
this.processDefinitionName = obj.processDefinitionName || null;
this.processDefinitionId = obj.processDefinitionId || null;
this.processInstanceId = obj.processInstanceId || null;
this.createdDate = obj.createdDate || null;

View File

@ -90,6 +90,10 @@ export class TaskListCloudComponent extends DataTableSchema implements OnChanges
@Input()
parentTaskId: string = '';
/** Filter the tasks. Display only tasks with processDefinitionName equal to the supplied value. */
@Input()
processDefinitionName: string = '';
/** Filter the tasks. Display only tasks with processDefinitionId equal to the supplied value. */
@Input()
processDefinitionId: string = '';
@ -346,6 +350,7 @@ export class TaskListCloudComponent extends DataTableSchema implements OnChanges
id: this.id,
name: this.name,
parentTaskId: this.parentTaskId,
processDefinitionName: this.processDefinitionName,
processDefinitionId: this.processDefinitionId,
processInstanceId: this.processInstanceId,
owner: this.owner,

View File

@ -36,6 +36,7 @@ export class TaskQueryCloudRequestModel {
standalone?: boolean;
priority?: number;
processDefinitionId?: string;
processDefinitionName?: string;
processInstanceId?: string;
status?: string;
maxItems: number;
@ -62,6 +63,7 @@ export class TaskQueryCloudRequestModel {
this.standalone = obj.standalone;
this.priority = obj.priority;
this.processDefinitionId = obj.processDefinitionId;
this.processDefinitionName = obj.processDefinitionName;
this.processInstanceId = obj.processInstanceId;
this.status = obj.status;
this.maxItems = obj.maxItems;