mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACA-3626] Cloud Task - completed date filter (#6185)
* completedDate task filter * translation key * update TaskFilterCloudModel * update TaskQueryCloudRequestModel * add completed date inputs * update TaskQueryCloudRequestModel request params * update tests
This commit is contained in:
@@ -160,7 +160,8 @@
|
|||||||
"DUE_DATE": "DueDate",
|
"DUE_DATE": "DueDate",
|
||||||
"SORT": "Sort",
|
"SORT": "Sort",
|
||||||
"START_DATE": "StartDate",
|
"START_DATE": "StartDate",
|
||||||
"COMPLETED_BY": "Completed By"
|
"COMPLETED_BY": "Completed By",
|
||||||
|
"COMPLETED_DATE": "CompletedDate"
|
||||||
},
|
},
|
||||||
"DIALOG": {
|
"DIALOG": {
|
||||||
"TITLE": "Save filter as",
|
"TITLE": "Save filter as",
|
||||||
|
@@ -528,6 +528,64 @@ describe('EditTaskFilterCloudComponent', () => {
|
|||||||
});
|
});
|
||||||
component.onFilterChange();
|
component.onFilterChange();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should set the correct completed date range when date range option is changed', (done) => {
|
||||||
|
component.appName = 'fake';
|
||||||
|
component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedDateRange'];
|
||||||
|
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
|
||||||
|
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const startedDateTypeControl: AbstractControl = component.editTaskFilterForm.get('completedDateType');
|
||||||
|
startedDateTypeControl.setValue(DateCloudFilterType.TODAY);
|
||||||
|
const dateFilter = {
|
||||||
|
startFrom: moment().startOf('day').toDate(),
|
||||||
|
startTo: moment().endOf('day').toDate()
|
||||||
|
};
|
||||||
|
|
||||||
|
component.filterChange.subscribe(() => {
|
||||||
|
expect(component.changedTaskFilter.completedFrom).toEqual(dateFilter.startFrom.toISOString());
|
||||||
|
expect(component.changedTaskFilter.completedTo).toEqual(dateFilter.startTo.toISOString());
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
component.onFilterChange();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should update form on date range when completed value is updated', (done) => {
|
||||||
|
component.appName = 'fake';
|
||||||
|
component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedDateRange'];
|
||||||
|
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
|
||||||
|
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const dateFilter = {
|
||||||
|
startDate: moment().startOf('day').toDate(),
|
||||||
|
endDate: moment().endOf('day').toDate()
|
||||||
|
};
|
||||||
|
|
||||||
|
const startedDateTypeControl: AbstractControl = component.editTaskFilterForm.get('completedDateType');
|
||||||
|
startedDateTypeControl.setValue(DateCloudFilterType.RANGE);
|
||||||
|
|
||||||
|
component.onDateRangeFilterChanged(dateFilter, {
|
||||||
|
key: 'completedDateType',
|
||||||
|
label: '',
|
||||||
|
type: 'date-range',
|
||||||
|
value: '',
|
||||||
|
attributes: {
|
||||||
|
dateType: 'completedDateType',
|
||||||
|
from: '_completedFrom',
|
||||||
|
to: '_completedTo'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
component.filterChange.subscribe(() => {
|
||||||
|
expect(component.changedTaskFilter.completedFrom).toEqual(dateFilter.startDate.toISOString());
|
||||||
|
expect(component.changedTaskFilter.completedTo).toEqual(dateFilter.endDate.toISOString());
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
component.onFilterChange();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('sort properties', () => {
|
describe('sort properties', () => {
|
||||||
|
@@ -328,6 +328,17 @@ export class EditTaskFilterCloudComponent extends BaseEditTaskFilterCloudCompone
|
|||||||
DateCloudFilterType.NEXT_7_DAYS,
|
DateCloudFilterType.NEXT_7_DAYS,
|
||||||
DateCloudFilterType.RANGE
|
DateCloudFilterType.RANGE
|
||||||
]
|
]
|
||||||
|
}),
|
||||||
|
new TaskFilterProperties({
|
||||||
|
label: 'ADF_CLOUD_EDIT_TASK_FILTER.LABEL.COMPLETED_DATE',
|
||||||
|
type: 'date-range',
|
||||||
|
key: 'completedDateRange',
|
||||||
|
attributes: { dateType: 'completedDateType', from: '_completedFrom', to: '_completedTo'},
|
||||||
|
value: {
|
||||||
|
completedDateType: this.taskFilter.completedDateType || null,
|
||||||
|
_completedFrom: this.taskFilter.completedFrom || null,
|
||||||
|
_completedTo: this.taskFilter.completedTo || null
|
||||||
|
}
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@@ -45,7 +45,11 @@ export class TaskFilterCloudModel {
|
|||||||
lastModifiedFrom: Date;
|
lastModifiedFrom: Date;
|
||||||
lastModifiedTo: Date;
|
lastModifiedTo: Date;
|
||||||
completedBy: string;
|
completedBy: string;
|
||||||
|
completedDateType: DateCloudFilterType;
|
||||||
|
completedDate: Date;
|
||||||
|
|
||||||
|
private _completedFrom: string;
|
||||||
|
private _completedTo: string;
|
||||||
private _dueDateFrom: string;
|
private _dueDateFrom: string;
|
||||||
private _dueDateTo: string;
|
private _dueDateTo: string;
|
||||||
private dateRangeFilterService = new DateRangeFilterService();
|
private dateRangeFilterService = new DateRangeFilterService();
|
||||||
@@ -79,6 +83,10 @@ export class TaskFilterCloudModel {
|
|||||||
this.lastModifiedFrom = obj.lastModifiedFrom || null;
|
this.lastModifiedFrom = obj.lastModifiedFrom || null;
|
||||||
this.lastModifiedTo = obj.lastModifiedTo || null;
|
this.lastModifiedTo = obj.lastModifiedTo || null;
|
||||||
this.completedBy = obj.completedBy || null;
|
this.completedBy = obj.completedBy || null;
|
||||||
|
this.completedDateType = obj.completedDateType || null;
|
||||||
|
this.completedFrom = obj._completedFrom || null;
|
||||||
|
this.completedTo = obj._completedTo || null;
|
||||||
|
this.completedDate = obj.completedDate || null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,6 +112,28 @@ export class TaskFilterCloudModel {
|
|||||||
return this.getEndDate(this.dueDateType);
|
return this.getEndDate(this.dueDateType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set completedFrom(completedFrom: string) {
|
||||||
|
this._completedFrom = completedFrom;
|
||||||
|
}
|
||||||
|
|
||||||
|
set completedTo(completedTo: string) {
|
||||||
|
this._completedTo = completedTo;
|
||||||
|
}
|
||||||
|
|
||||||
|
get completedFrom(): string {
|
||||||
|
if (this.isDateRangeType(this.completedDateType)) {
|
||||||
|
return this._completedFrom;
|
||||||
|
}
|
||||||
|
return this.getStartDate(this.completedDateType);
|
||||||
|
}
|
||||||
|
|
||||||
|
get completedTo(): string {
|
||||||
|
if (this.isDateRangeType(this.completedDateType)) {
|
||||||
|
return this._completedTo;
|
||||||
|
}
|
||||||
|
return this.getEndDate(this.completedDateType);
|
||||||
|
}
|
||||||
|
|
||||||
private getStartDate(key: DateCloudFilterType) {
|
private getStartDate(key: DateCloudFilterType) {
|
||||||
return this.dateRangeFilterService.getDateRange(key).startDate?.toISOString();
|
return this.dateRangeFilterService.getDateRange(key).startDate?.toISOString();
|
||||||
}
|
}
|
||||||
|
@@ -107,6 +107,18 @@ export class TaskListCloudComponent extends BaseTaskListCloudComponent {
|
|||||||
@Input()
|
@Input()
|
||||||
standalone: boolean = false;
|
standalone: boolean = false;
|
||||||
|
|
||||||
|
/** Filter the tasks. Display only tasks with completedDate equal to the supplied date. */
|
||||||
|
@Input()
|
||||||
|
completedDate: string = '';
|
||||||
|
|
||||||
|
/** Filter the tasks. Display only tasks with completedFrom equal to the supplied date. */
|
||||||
|
@Input()
|
||||||
|
completedFrom: string = '';
|
||||||
|
|
||||||
|
/** Filter the tasks. Display only tasks with completedTo equal to the supplied date. */
|
||||||
|
@Input()
|
||||||
|
completedTo: string = '';
|
||||||
|
|
||||||
constructor(private taskListCloudService: TaskListCloudService,
|
constructor(private taskListCloudService: TaskListCloudService,
|
||||||
appConfigService: AppConfigService,
|
appConfigService: AppConfigService,
|
||||||
userPreferences: UserPreferencesService) {
|
userPreferences: UserPreferencesService) {
|
||||||
@@ -150,7 +162,10 @@ export class TaskListCloudComponent extends BaseTaskListCloudComponent {
|
|||||||
skipCount: this.skipCount,
|
skipCount: this.skipCount,
|
||||||
sorting: this.sorting,
|
sorting: this.sorting,
|
||||||
standalone: this.standalone,
|
standalone: this.standalone,
|
||||||
completedBy: this.completedBy
|
completedBy: this.completedBy,
|
||||||
|
completedFrom: this.completedFrom,
|
||||||
|
completedTo: this.completedTo,
|
||||||
|
completedDate: this.completedDate
|
||||||
};
|
};
|
||||||
return new TaskQueryCloudRequestModel(requestNode);
|
return new TaskQueryCloudRequestModel(requestNode);
|
||||||
}
|
}
|
||||||
|
@@ -43,6 +43,9 @@ export class TaskQueryCloudRequestModel {
|
|||||||
maxItems: number;
|
maxItems: number;
|
||||||
skipCount: number;
|
skipCount: number;
|
||||||
sorting?: TaskListCloudSortingModel[];
|
sorting?: TaskListCloudSortingModel[];
|
||||||
|
completedDate?: Date;
|
||||||
|
completedFrom?: string;
|
||||||
|
completedTo?: string;
|
||||||
|
|
||||||
constructor(obj?: any) {
|
constructor(obj?: any) {
|
||||||
if (obj) {
|
if (obj) {
|
||||||
@@ -71,6 +74,9 @@ export class TaskQueryCloudRequestModel {
|
|||||||
this.maxItems = obj.maxItems;
|
this.maxItems = obj.maxItems;
|
||||||
this.skipCount = obj.skipCount;
|
this.skipCount = obj.skipCount;
|
||||||
this.sorting = obj.sorting;
|
this.sorting = obj.sorting;
|
||||||
|
this.completedFrom = obj.completedFrom;
|
||||||
|
this.completedTo = obj.completedTo;
|
||||||
|
this.completedDate = obj.completedDate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user