mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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:
@@ -161,7 +161,8 @@
|
|||||||
"SORT": "Sort",
|
"SORT": "Sort",
|
||||||
"START_DATE": "StartDate",
|
"START_DATE": "StartDate",
|
||||||
"COMPLETED_BY": "Completed By",
|
"COMPLETED_BY": "Completed By",
|
||||||
"COMPLETED_DATE": "CompletedDate"
|
"COMPLETED_DATE": "CompletedDate",
|
||||||
|
"CREATED_DATE": "CreatedDate"
|
||||||
},
|
},
|
||||||
"DIALOG": {
|
"DIALOG": {
|
||||||
"TITLE": "Save filter as",
|
"TITLE": "Save filter as",
|
||||||
|
@@ -674,6 +674,64 @@ describe('EditTaskFilterCloudComponent', () => {
|
|||||||
});
|
});
|
||||||
component.onFilterChange();
|
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', () => {
|
describe('sort properties', () => {
|
||||||
|
@@ -341,6 +341,17 @@ export class EditTaskFilterCloudComponent extends BaseEditTaskFilterCloudCompone
|
|||||||
_completedTo: this.taskFilter.completedTo || null
|
_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({
|
new TaskFilterProperties({
|
||||||
label: 'ADF_CLOUD_EDIT_TASK_FILTER.LABEL.COMPLETED_BY',
|
label: 'ADF_CLOUD_EDIT_TASK_FILTER.LABEL.COMPLETED_BY',
|
||||||
type: 'people',
|
type: 'people',
|
||||||
|
@@ -46,6 +46,7 @@ export class TaskFilterCloudModel {
|
|||||||
lastModifiedFrom: string;
|
lastModifiedFrom: string;
|
||||||
lastModifiedTo: string;
|
lastModifiedTo: string;
|
||||||
completedDateType: DateCloudFilterType;
|
completedDateType: DateCloudFilterType;
|
||||||
|
createdDateType: DateCloudFilterType;
|
||||||
completedDate: Date;
|
completedDate: Date;
|
||||||
completedBy: IdentityUserModel;
|
completedBy: IdentityUserModel;
|
||||||
|
|
||||||
@@ -53,6 +54,8 @@ export class TaskFilterCloudModel {
|
|||||||
private _completedTo: string;
|
private _completedTo: string;
|
||||||
private _dueDateFrom: string;
|
private _dueDateFrom: string;
|
||||||
private _dueDateTo: string;
|
private _dueDateTo: string;
|
||||||
|
private _createdFrom: string;
|
||||||
|
private _createdTo: string;
|
||||||
private dateRangeFilterService = new DateRangeFilterService();
|
private dateRangeFilterService = new DateRangeFilterService();
|
||||||
|
|
||||||
constructor(obj?: any) {
|
constructor(obj?: any) {
|
||||||
@@ -88,6 +91,9 @@ export class TaskFilterCloudModel {
|
|||||||
this.completedFrom = obj._completedFrom || null;
|
this.completedFrom = obj._completedFrom || null;
|
||||||
this.completedTo = obj._completedTo || null;
|
this.completedTo = obj._completedTo || null;
|
||||||
this.completedDate = obj.completedDate || 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);
|
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) {
|
private getStartDate(key: DateCloudFilterType) {
|
||||||
return this.dateRangeFilterService.getDateRange(key).startDate;
|
return this.dateRangeFilterService.getDateRange(key).startDate;
|
||||||
}
|
}
|
||||||
|
@@ -43,6 +43,14 @@ export class TaskListCloudComponent extends BaseTaskListCloudComponent {
|
|||||||
@Input()
|
@Input()
|
||||||
createdDate: string = '';
|
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. */
|
/** Filter the tasks. Display only tasks with dueDate equal to the supplied date. */
|
||||||
@Input()
|
@Input()
|
||||||
dueDate: string = '';
|
dueDate: string = '';
|
||||||
@@ -158,6 +166,8 @@ export class TaskListCloudComponent extends BaseTaskListCloudComponent {
|
|||||||
status: this.status,
|
status: this.status,
|
||||||
dueDate: this.dueDate,
|
dueDate: this.dueDate,
|
||||||
createdDate: this.createdDate,
|
createdDate: this.createdDate,
|
||||||
|
createdFrom: this.createdFrom,
|
||||||
|
createdTo: this.createdTo,
|
||||||
maxItems: this.size,
|
maxItems: this.size,
|
||||||
skipCount: this.skipCount,
|
skipCount: this.skipCount,
|
||||||
sorting: this.sorting,
|
sorting: this.sorting,
|
||||||
|
@@ -23,6 +23,8 @@ export class TaskQueryCloudRequestModel {
|
|||||||
assignee?: string;
|
assignee?: string;
|
||||||
claimedDate?: string;
|
claimedDate?: string;
|
||||||
createdDate?: Date;
|
createdDate?: Date;
|
||||||
|
createdFrom?: string;
|
||||||
|
createdTo?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
dueDate?: null;
|
dueDate?: null;
|
||||||
lastModifiedFrom?: null;
|
lastModifiedFrom?: null;
|
||||||
@@ -54,6 +56,8 @@ export class TaskQueryCloudRequestModel {
|
|||||||
this.assignee = obj.assignee;
|
this.assignee = obj.assignee;
|
||||||
this.claimedDate = obj.claimedDate;
|
this.claimedDate = obj.claimedDate;
|
||||||
this.createdDate = obj.createdDate;
|
this.createdDate = obj.createdDate;
|
||||||
|
this.createdFrom = obj.createdFrom;
|
||||||
|
this.createdTo = obj.createdTo;
|
||||||
this.description = obj.description;
|
this.description = obj.description;
|
||||||
this.dueDate = obj.dueDate;
|
this.dueDate = obj.dueDate;
|
||||||
this.lastModifiedFrom = obj.lastModifiedFrom;
|
this.lastModifiedFrom = obj.lastModifiedFrom;
|
||||||
|
Reference in New Issue
Block a user