mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-5085] Adding possibility to search for future dates search-date-range component (#5525)
* [ADF-5085] Remove maxDate and set the max of the from date to the to date * [ADF-5085] Add maxDate optional setting * [ADF-5085] Add unit test for maxDate * [ADF-5085] Add documentation for maxDate setting * [ADF-5085] Unit tests for default and today value * [ADF-5085] Refactor
This commit is contained in:
@@ -54,9 +54,8 @@ export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy
|
||||
id: string;
|
||||
settings?: SearchWidgetSettings;
|
||||
context?: SearchQueryBuilderService;
|
||||
maxDate: any;
|
||||
datePickerDateFormat = DEFAULT_FORMAT_DATE;
|
||||
|
||||
maxDate: any;
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
constructor(private dateAdapter: DateAdapter<Moment>,
|
||||
@@ -102,7 +101,13 @@ export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy
|
||||
to: this.to
|
||||
});
|
||||
|
||||
this.maxDate = this.dateAdapter.today().startOf('day');
|
||||
if (this.settings && this.settings.maxDate) {
|
||||
if (this.settings.maxDate === 'today') {
|
||||
this.maxDate = this.dateAdapter.today().endOf('day');
|
||||
} else {
|
||||
this.maxDate = moment(this.settings.maxDate).endOf('day');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
@@ -161,4 +166,13 @@ export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy
|
||||
event.srcElement.click();
|
||||
}
|
||||
|
||||
getFromMaxDate(): any {
|
||||
let maxDate: string;
|
||||
if (!this.to.value || this.maxDate && (moment(this.maxDate).isBefore(this.to.value))) {
|
||||
maxDate = this.maxDate;
|
||||
} else {
|
||||
maxDate = moment(this.to.value);
|
||||
}
|
||||
return maxDate;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user