diff --git a/lib/process-services-cloud/src/lib/i18n/en.json b/lib/process-services-cloud/src/lib/i18n/en.json index 1a6b2c59c8..e49eb22dc3 100644 --- a/lib/process-services-cloud/src/lib/i18n/en.json +++ b/lib/process-services-cloud/src/lib/i18n/en.json @@ -161,7 +161,8 @@ "SORT": "Sort", "START_DATE": "StartDate", "COMPLETED_BY": "Completed By", - "COMPLETED_DATE": "CompletedDate" + "COMPLETED_DATE": "CompletedDate", + "CREATED_DATE": "CreatedDate" }, "DIALOG": { "TITLE": "Save filter as", diff --git a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-task-filter-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-task-filter-cloud.component.spec.ts index 0fcde42586..209993356b 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-task-filter-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-task-filter-cloud.component.spec.ts @@ -674,6 +674,64 @@ describe('EditTaskFilterCloudComponent', () => { }); component.onFilterChange(); }); + + it('should set the correct created date range when date range option is changed', (done) => { + component.appName = 'fake'; + component.filterProperties = ['appName', 'processInstanceId', 'priority', 'createdDateRange']; + const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); + component.ngOnChanges({ 'id': taskFilterIdChange }); + fixture.detectChanges(); + + const startedDateTypeControl: AbstractControl = component.editTaskFilterForm.get('createdDateType'); + startedDateTypeControl.setValue(DateCloudFilterType.TODAY); + const dateFilter = { + startDate: moment().startOf('day').toISOString(true), + endDate: moment().endOf('day').toISOString(true) + }; + + component.filterChange.subscribe(() => { + expect(component.changedTaskFilter.createdFrom).toEqual(dateFilter.startDate); + expect(component.changedTaskFilter.createdTo).toEqual(dateFilter.endDate); + done(); + }); + component.onFilterChange(); + }); + + it('should update form on date range when createdDate value is updated', (done) => { + component.appName = 'fake'; + component.filterProperties = ['appName', 'processInstanceId', 'priority', 'createdDateRange']; + const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); + component.ngOnChanges({ 'id': taskFilterIdChange }); + fixture.detectChanges(); + + const dateFilter = { + startDate: moment().startOf('day').toISOString(true), + endDate: moment().endOf('day').toISOString(true) + }; + + const startedDateTypeControl: AbstractControl = component.editTaskFilterForm.get('createdDateType'); + startedDateTypeControl.setValue(DateCloudFilterType.RANGE); + + component.onDateRangeFilterChanged(dateFilter, { + key: 'createdDateType', + label: '', + type: 'date-range', + value: '', + attributes: { + dateType: 'createdDateType', + from: '_createdFrom', + to: '_createdTo' + } + }); + + fixture.detectChanges(); + component.filterChange.subscribe(() => { + expect(component.changedTaskFilter.createdFrom).toEqual(dateFilter.startDate); + expect(component.changedTaskFilter.createdTo).toEqual(dateFilter.endDate); + done(); + }); + component.onFilterChange(); + }); }); describe('sort properties', () => { diff --git a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-task-filter-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-task-filter-cloud.component.ts index 2b7862951b..9e18618255 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-task-filter-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-task-filter-cloud.component.ts @@ -341,6 +341,17 @@ export class EditTaskFilterCloudComponent extends BaseEditTaskFilterCloudCompone _completedTo: this.taskFilter.completedTo || null } }), + new TaskFilterProperties({ + label: 'ADF_CLOUD_EDIT_TASK_FILTER.LABEL.CREATED_DATE', + type: 'date-range', + key: 'createdDateRange', + attributes: { dateType: 'createdDateType', from: '_createdFrom', to: '_createdTo'}, + value: { + createdDateType: this.taskFilter.createdDateType || null, + _createdFrom: this.taskFilter.createdFrom || null, + _createdTo: this.taskFilter.createdTo || null + } + }), new TaskFilterProperties({ label: 'ADF_CLOUD_EDIT_TASK_FILTER.LABEL.COMPLETED_BY', type: 'people', diff --git a/lib/process-services-cloud/src/lib/task/task-filters/models/filter-cloud.model.ts b/lib/process-services-cloud/src/lib/task/task-filters/models/filter-cloud.model.ts index 9cdd74d6c5..bc08213b1f 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/models/filter-cloud.model.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/models/filter-cloud.model.ts @@ -46,6 +46,7 @@ export class TaskFilterCloudModel { lastModifiedFrom: string; lastModifiedTo: string; completedDateType: DateCloudFilterType; + createdDateType: DateCloudFilterType; completedDate: Date; completedBy: IdentityUserModel; @@ -53,6 +54,8 @@ export class TaskFilterCloudModel { private _completedTo: string; private _dueDateFrom: string; private _dueDateTo: string; + private _createdFrom: string; + private _createdTo: string; private dateRangeFilterService = new DateRangeFilterService(); constructor(obj?: any) { @@ -88,6 +91,9 @@ export class TaskFilterCloudModel { this.completedFrom = obj._completedFrom || null; this.completedTo = obj._completedTo || null; this.completedDate = obj.completedDate || null; + this.createdDateType = obj.createdDateType || null; + this.createdFrom = obj._createdFrom || null; + this.createdTo = obj._createdTo || null; } } @@ -135,6 +141,28 @@ export class TaskFilterCloudModel { return this.getEndDate(this.completedDateType); } + set createdFrom(createdFrom: string) { + this._createdFrom = createdFrom; + } + + set createdTo(createdTo: string) { + this._createdTo = createdTo; + } + + get createdFrom() { + if (this.isDateRangeType(this.createdDateType)) { + return this._createdFrom; + } + return this.getStartDate(this.createdDateType); + } + + get createdTo() { + if (this.isDateRangeType(this.createdDateType)) { + return this._createdTo; + } + return this.getEndDate(this.createdDateType); + } + private getStartDate(key: DateCloudFilterType) { return this.dateRangeFilterService.getDateRange(key).startDate; } diff --git a/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.ts index 302cf934b7..84d40e6441 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.ts @@ -43,6 +43,14 @@ export class TaskListCloudComponent extends BaseTaskListCloudComponent { @Input() createdDate: string = ''; + /** Filter the tasks. Display only tasks with createdFrom equal to the supplied date. */ + @Input() + createdFrom: string = ''; + + /** Filter the tasks. Display only tasks with createdTo equal to the supplied date. */ + @Input() + createdTo: string = ''; + /** Filter the tasks. Display only tasks with dueDate equal to the supplied date. */ @Input() dueDate: string = ''; @@ -158,6 +166,8 @@ export class TaskListCloudComponent extends BaseTaskListCloudComponent { status: this.status, dueDate: this.dueDate, createdDate: this.createdDate, + createdFrom: this.createdFrom, + createdTo: this.createdTo, maxItems: this.size, skipCount: this.skipCount, sorting: this.sorting, diff --git a/lib/process-services-cloud/src/lib/task/task-list/models/filter-cloud-model.ts b/lib/process-services-cloud/src/lib/task/task-list/models/filter-cloud-model.ts index dc02be9218..bfbdad6ae3 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/models/filter-cloud-model.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/models/filter-cloud-model.ts @@ -23,6 +23,8 @@ export class TaskQueryCloudRequestModel { assignee?: string; claimedDate?: string; createdDate?: Date; + createdFrom?: string; + createdTo?: string; description?: string; dueDate?: null; lastModifiedFrom?: null; @@ -54,6 +56,8 @@ export class TaskQueryCloudRequestModel { this.assignee = obj.assignee; this.claimedDate = obj.claimedDate; this.createdDate = obj.createdDate; + this.createdFrom = obj.createdFrom; + this.createdTo = obj.createdTo; this.description = obj.description; this.dueDate = obj.dueDate; this.lastModifiedFrom = obj.lastModifiedFrom;