Skip to content

Commit

Permalink
Fix datepicker onclear event and check blank filters
Browse files Browse the repository at this point in the history
  • Loading branch information
fateeand committed Nov 12, 2023
1 parent 10e998e commit 30e0374
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
[showButtonBar]="showTodayButton"
[inline]="true"
(onSelect)="onSelectCalendarDate($event)"
(onClearClick)="onClearCalendarDate()"
[showOtherMonths]="false"
[minDate]="minDate"
[maxDate]="maxDate">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,12 @@ export class CpsDatepickerComponent
this.error = message || 'Unknown error';
}

onSelectCalendarDate(dateVal: Date) {
this.toggleCalendar(false);
this._dateToString(dateVal);
onClearCalendarDate() {
this.onSelectCalendarDate(null);
}

onSelectCalendarDate(dateVal: Date | null) {
this.toggleCalendar(false);
this.writeValue(dateVal);
this.onChange(dateVal);
this.valueChanged.emit(dateVal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class TableColumnFilterConstraintComponent implements OnChanges {
onValueChange(value: any) {
(<any>this.filterConstraint).value = value;

if (value === '' || !this.hasApplyButton) {
if (this._tableInstance.isFilterBlank(value) || !this.hasApplyButton) {
this._tableInstance._filter();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,16 @@ export class TableColumnFilterComponent implements OnInit, OnDestroy {
}

private _updateFilterApplied(value: any) {
const curFilter = value.filters[<string>this.field];
if (curFilter) {
if (Array.isArray(curFilter)) {
this.isFilterApplied = (<FilterMetadata[]>curFilter).some(
(meta) => !!meta.value
const fieldFilter = value.filters[<string>this.field];
if (fieldFilter) {
if (Array.isArray(fieldFilter)) {
this.isFilterApplied = (<FilterMetadata[]>fieldFilter).some(
(meta) => !this._tableInstance.isFilterBlank(meta.value)
);
} else {
this.isFilterApplied = !!curFilter.value;
this.isFilterApplied = !this._tableInstance.isFilterBlank(
fieldFilter.value
);
}
} else {
this.isFilterApplied = false;
Expand Down

0 comments on commit 30e0374

Please sign in to comment.