diff --git a/frappe/public/js/frappe/data_import/data_exporter.js b/frappe/public/js/frappe/data_import/data_exporter.js
index 4ff41ab355..540af89179 100644
--- a/frappe/public/js/frappe/data_import/data_exporter.js
+++ b/frappe/public/js/frappe/data_import/data_exporter.js
@@ -91,12 +91,13 @@ frappe.data_import.DataExporter = class DataExporter {
],
primary_action_label: __("Export"),
primary_action: (values) => this.export_records(values),
- on_page_show: () => this.select_mandatory(),
+ on_page_show: () => this.setup_on_page_show(),
});
this.make_filter_area();
this.make_select_all_buttons();
this.update_record_count_message();
+ this.setup_search_input();
this.dialog.show();
}
@@ -303,6 +304,29 @@ frappe.data_import.DataExporter = class DataExporter {
};
});
}
+
+ setup_search_input() {
+ const $wrapper = this.dialog.get_field("select_all_buttons").$wrapper;
+
+ // prevent duplicate search inputs
+ if (this.dialog.$wrapper.find(".filters-search").length) return;
+
+ $wrapper.before(`
+
+
+
+ `);
+ }
+
+ setup_on_page_show() {
+ frappe.utils.setup_search(this.dialog.$body, ".unit-checkbox", ".label-area");
+ this.select_mandatory();
+ }
};
export function get_columns_for_picker(doctype) {
diff --git a/frappe/public/js/frappe/utils/utils.js b/frappe/public/js/frappe/utils/utils.js
index 7a68aa206f..20727e9577 100644
--- a/frappe/public/js/frappe/utils/utils.js
+++ b/frappe/public/js/frappe/utils/utils.js
@@ -979,25 +979,54 @@ Object.assign(frappe.utils, {
const $search_input = $wrapper.find('[data-element="search"]').show();
$search_input.focus().val("");
const $elements = $wrapper.find(el_class).show();
+ const $multichecks = $wrapper.find('[data-fieldtype="MultiCheck"]');
+
+ let $no_results = $wrapper.find(".no-results-message");
+ if (!$no_results.length) {
+ $no_results = $(`
+
+ ${__("No values to show")}
+
+ `).appendTo($wrapper);
+ }
+
+ $no_results.hide();
+
+ const matches_filter = ($el, filter) => {
+ const $text_el = $el.find(text_class);
+ const text = $text_el.text().toLowerCase();
+
+ let name = "";
+ if (data_attr && $text_el.attr(data_attr)) {
+ name = $text_el.attr(data_attr).toLowerCase();
+ }
+
+ return text.includes(filter) || name.includes(filter);
+ };
$search_input.off("keyup").on("keyup", () => {
- let text_filter = $search_input.val().toLowerCase();
- // Replace trailing and leading spaces
- text_filter = text_filter.replace(/^\s+|\s+$/g, "");
- for (let i = 0; i < $elements.length; i++) {
- const text_element = $elements.eq(i).find(text_class);
- const text = text_element.text().toLowerCase();
+ const text_filter = $search_input.val().toLowerCase().trim();
+ let any_visible = false;
- let name = "";
- if (data_attr && text_element.attr(data_attr)) {
- name = text_element.attr(data_attr).toLowerCase();
- }
+ $elements.each(function () {
+ const match = matches_filter($(this), text_filter);
+ $(this).toggle(match);
+ if (match) any_visible = true;
+ });
- if (text.includes(text_filter) || name.includes(text_filter)) {
- $elements.eq(i).css("display", "");
- } else {
- $elements.eq(i).css("display", "none");
- }
+ if ($multichecks.length) {
+ $multichecks.show();
+
+ $multichecks.each(function () {
+ const has_visible = $(this).find(el_class + ":visible").length;
+ $(this).toggle(!!has_visible);
+ });
+ }
+
+ if (text_filter) {
+ $no_results.toggle(!any_visible);
+ } else {
+ $no_results.hide();
}
});
},