Skip to content

Commit

Permalink
better handling of dummy and null values
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Mar 26, 2020
1 parent 1333e86 commit 2a14508
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/model/StringColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,10 @@ export default class StringColumn extends ValueColumn<string> {
if (filter === this.currentFilter) {
return;
}
if (this.currentFilter && filter && this.currentFilter.filterMissing === filter.filterMissing && this.currentFilter.filter === filter.filter) {
const current = this.currentFilter || {filter: null, filterMissing: false};
const target = filter || {filter: null, filterMissing: false};
if (current.filterMissing === target.filterMissing && (current.filter === target.filter ||
(current.filter instanceof RegExp && target.filter instanceof RegExp && current.filter.source === target.filter.source))) {
return;
}
this.fire([StringColumn.EVENT_FILTER_CHANGED, Column.EVENT_DIRTY_VALUES, Column.EVENT_DIRTY], this.currentFilter, this.currentFilter = filter);
Expand Down
8 changes: 6 additions & 2 deletions src/ui/dialogs/StringFilterDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ export default class StringFilterDialog extends ADialog {

private updateFilter(filter: string | RegExp | null, filterMissing: boolean) {
updateFilterState(this.attachment, this.column, filterMissing || filter != null);
this.column.setFilter({filter, filterMissing});
if (filter == null && !filterMissing) {
this.column.setFilter(null);
} else {
this.column.setFilter({filter, filterMissing});
}
}

protected reset() {
Expand All @@ -40,7 +44,7 @@ export default class StringFilterDialog extends ADialog {

protected cancel() {
if (this.before) {
this.updateFilter(this.before.filter, this.before.filterMissing);
this.updateFilter(this.before.filter === '' ? null : this.before.filter, this.before.filterMissing);
} else {
this.updateFilter(null, false);
}
Expand Down

0 comments on commit 2a14508

Please sign in to comment.