[ADF-5280] [Cloud] Tasks - Created Date filter (#6254)

* Created date filter transation

* created date range model

* createdDateRange property

* add createdDate filter data

* update tests
This commit is contained in:
Cilibiu Bogdan
2020-10-19 13:09:43 +03:00
committed by GitHub
parent eaa9a2c1f7
commit 8c62754d4b
6 changed files with 113 additions and 1 deletions

View File

@@ -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",

View File

@@ -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', () => {

View File

@@ -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',

View File

@@ -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;
}

View File

@@ -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,

View File

@@ -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;