From 54f34bdce8ca690fa589b5fb8ffee2cd1a8747a9 Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Mon, 10 May 2021 17:07:44 +0530 Subject: [PATCH] fix: fetching of child items --- .../js/frappe/form/multi_select_dialog.js | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/frappe/public/js/frappe/form/multi_select_dialog.js b/frappe/public/js/frappe/form/multi_select_dialog.js index 760aa3123b..036fad3f4b 100644 --- a/frappe/public/js/frappe/form/multi_select_dialog.js +++ b/frappe/public/js/frappe/form/multi_select_dialog.js @@ -75,8 +75,9 @@ frappe.ui.form.MultiSelectDialog = class MultiSelectDialog { primary_action: () => { let filters_data = this.get_custom_filters(); const data_values = cur_dialog.get_values(); // to pass values of data fields - const filtered_children = this.get_checked_child_names(); - this.action(this.get_checked_values(), { + const filtered_children = this.get_selected_child_names(); + const selected_documents = [...this.get_checked_values(), ...this.get_parent_name_of_selected_children()]; + this.action(selected_documents, { ...this.args, ...data_values, ...filters_data, @@ -330,7 +331,21 @@ frappe.ui.form.MultiSelectDialog = class MultiSelectDialog { }); } - get_checked_child_names() { + get_parent_name_of_selected_children() { + if (!this.child_datatable.datamanager.rows.length) return []; + + let parent_names = this.child_datatable.rowmanager.checkMap.reduce((parent_names, checked, index) => { + if (checked == 1) { + const parent_name = this.child_results[index].parent; + parent_names.push(parent_name); + } + return parent_names; + }, []); + + return parent_names; + } + + get_selected_child_names() { if (!this.child_datatable.datamanager.rows.length) return []; let checked_names = this.child_datatable.rowmanager.checkMap.reduce((checked_names, checked, index) => {