From e8dc8467a4f839e79500099abacca27c7efabad8 Mon Sep 17 00:00:00 2001 From: venkataakhil Date: Fri, 10 Nov 2023 13:03:00 +0530 Subject: [PATCH] Add saved notification on update of kilometer mapping --- .../kilometer_mapping/kilometer_mapping.js | 75 ++----------------- 1 file changed, 8 insertions(+), 67 deletions(-) diff --git a/smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.js b/smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.js index 3313bed..c4c5a37 100644 --- a/smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.js +++ b/smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.js @@ -56,66 +56,6 @@ frappe.ui.form.on('Kilometer Mapping', { }, validate: function (frm) { - // //custom button - // frm.add_custom_button(__("Duplicate Data"), function () { - // let d = new frappe.ui.Dialog({ - // title: 'Choose the variant', - // fields: [ - // { - // label: 'Variant', - // fieldname: 'variant', - // fieldtype: 'Link', - // options: "Kilometer Mapping" - // }, - // { - // label: '', - // fieldname: 'content_html', - // fieldtype: 'HTML', - // }, - // ], - // size: 'small', - // secondary_action_label: "No", - // primary_action_label: 'Yes', - // primary_action(values) { - // console.log(values); - // if (values) { - - // if (frm.doc.config_kilometer && frm.doc.config_kilometer.length > 0) { - // cur_frm.clear_table("config_kilometer"); - // cur_frm.refresh_fields('config_kilometer'); - // } - // cur_frm.refresh_fields("config_kilometer"); - // frappe.call({ - // "method": "smart_service.transactions.doctype.kilometer_mapping.kilometer_mapping.get_config_kilometer", - // "args": { - // "doc": values.variant, - // "docname": frm.doc.name - // }, - // callback: function (r) { - // if (r.message && r.message.length > 0) { - // cur_frm.refresh_fields("config_kilometer"); - // frm.save() - // frm.refresh() - // } - // } - // }) - // d.hide(); - - // } - - - // }, - // secondary_action(values) { - // d.hide(); - // } - // }); - - // d.show(); - // var res = $(d.fields_dict.content_html.wrapper).empty(); - // var ret = "

Upload the Kilometer

" - // res.append(ret) - // }).css({ "color": "#fff", "background-color": "red" });; - // //end frm.doc.kilometer_filter = "All"; if (frm.doc.kilometer_filter == "All") { @@ -146,9 +86,7 @@ frappe.ui.form.on('Kilometer Mapping', { secondary_action_label: "No", primary_action_label: 'Yes', primary_action(values) { - console.log(values.variant); if (values.variant) { - console.log("calling") cur_frm.refresh_fields("config_kilometer"); frappe.call({ "method": "smart_service.transactions.doctype.kilometer_mapping.kilometer_mapping.get_config_kilometer", @@ -157,10 +95,17 @@ frappe.ui.form.on('Kilometer Mapping', { "docname": frm.doc.name }, callback: function (r) { - if (r.message && r.message.length > 0) { + if (r.message && r.message['status'] == "success") { cur_frm.refresh_fields("config_kilometer"); frm.save() + + frappe.show_alert({ + message: __('Saved'), + indicator: 'green' + }, 5); frm.refresh() + + } } }) @@ -181,10 +126,6 @@ frappe.ui.form.on('Kilometer Mapping', { $('.modal-dialog').find('.custom-actions').html('

Are you sure to update the kilometer mapping?

') } , 300); - - // var res = $(d.fields_dict.content_html.wrapper).empty(); - // var ret="

Are you sure to update the kilometer mapping ?

" - // res.append(ret) }).css({ "color": "#fff", "background-color": "red" });; //end