fix: filter apply and remove
This commit is contained in:
parent
051a56ed10
commit
2da3cb3fb0
2 changed files with 18 additions and 10 deletions
|
|
@ -389,6 +389,15 @@ frappe.views.BaseList = class BaseList {
|
|||
// for child classes
|
||||
}
|
||||
|
||||
get_filter_value(fieldname) {
|
||||
const filter = this.get_filters_for_args().filter(f => f[1] == fieldname)[0];
|
||||
if (!filter) return;
|
||||
return {
|
||||
'like': filter[3].replace(/^%?|%$/g, ''),
|
||||
'not set': null
|
||||
}[filter[2]] || filter[3];
|
||||
}
|
||||
|
||||
get_filters_for_args() {
|
||||
// filters might have a fifth param called hidden,
|
||||
// we don't want to pass that server side
|
||||
|
|
@ -397,11 +406,6 @@ frappe.views.BaseList = class BaseList {
|
|||
: [];
|
||||
}
|
||||
|
||||
get_filter_value(fieldname) {
|
||||
return this.get_filters_for_args().filter(f => f[1] == fieldname)[0] &&
|
||||
this.get_filters_for_args().filter(f => f[1] == fieldname)[0][3];
|
||||
}
|
||||
|
||||
get_args() {
|
||||
return {
|
||||
doctype: this.doctype,
|
||||
|
|
@ -636,11 +640,12 @@ class FilterArea {
|
|||
const fields_dict = this.list_view.page.fields_dict;
|
||||
|
||||
if (fieldname in fields_dict) {
|
||||
return fields_dict[fieldname].set_value("");
|
||||
fields_dict[fieldname].set_value("");
|
||||
}
|
||||
|
||||
let filter = this.filter_list.get_filter(fieldname);
|
||||
if (filter) filter.remove();
|
||||
this.filter_list.apply();
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,8 +75,7 @@ frappe.ui.FilterGroup = class {
|
|||
});
|
||||
|
||||
this.filter_button.on('hidden.bs.popover', (e) => {
|
||||
this.update_filters();
|
||||
this.on_change();
|
||||
this.apply();
|
||||
});
|
||||
|
||||
// REDESIGN-TODO: (Temporary) Review and find best solution for this
|
||||
|
|
@ -95,6 +94,11 @@ frappe.ui.FilterGroup = class {
|
|||
});
|
||||
}
|
||||
|
||||
apply() {
|
||||
this.update_filters();
|
||||
this.on_change();
|
||||
}
|
||||
|
||||
update_filter_button() {
|
||||
const filters_applied = this.filters.length > 0;
|
||||
const button_label = filters_applied
|
||||
|
|
@ -127,8 +131,7 @@ frappe.ui.FilterGroup = class {
|
|||
|
||||
this.wrapper.find('.apply-filters').on('click', () => {
|
||||
this.toggle_empty_filters(false);
|
||||
this.update_filters();
|
||||
this.on_change();
|
||||
this.apply();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue