feat: use autocomplete on "New Address" button
This commit is contained in:
parent
ae505b769c
commit
553918f36b
2 changed files with 20 additions and 6 deletions
|
|
@ -109,6 +109,9 @@ def get_bootinfo():
|
|||
bootinfo.subscription_conf = add_subscription_conf()
|
||||
bootinfo.marketplace_apps = get_marketplace_apps()
|
||||
bootinfo.changelog_feed = get_changelog_feed_items()
|
||||
bootinfo.address_autocomplete_enabled = frappe.db.get_single_value(
|
||||
"Address Autocomplete Settings", "enabled"
|
||||
)
|
||||
|
||||
return bootinfo
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ $.extend(frappe.contacts, {
|
|||
$(frm.fields_dict["address_html"].wrapper)
|
||||
.html(frappe.render_template("address_list", frm.doc.__onload))
|
||||
.find(".btn-address")
|
||||
.on("click", () => new_record("Address", frm.doc));
|
||||
.on("click", () => new_record("Address", frm));
|
||||
}
|
||||
|
||||
// render contact
|
||||
|
|
@ -20,7 +20,7 @@ $.extend(frappe.contacts, {
|
|||
$(frm.fields_dict["contact_html"].wrapper)
|
||||
.html(frappe.render_template("contact_list", frm.doc.__onload))
|
||||
.find(".btn-contact")
|
||||
.on("click", () => new_record("Contact", frm.doc));
|
||||
.on("click", () => new_record("Contact", frm));
|
||||
}
|
||||
},
|
||||
get_last_doc: function (frm) {
|
||||
|
|
@ -59,12 +59,23 @@ $.extend(frappe.contacts, {
|
|||
},
|
||||
});
|
||||
|
||||
function new_record(doctype, source_doc) {
|
||||
function new_record(doctype, frm) {
|
||||
frappe.dynamic_link = {
|
||||
doctype: source_doc.doctype,
|
||||
doc: source_doc,
|
||||
doctype: frm.doc.doctype,
|
||||
doc: frm.doc,
|
||||
fieldname: "name",
|
||||
};
|
||||
|
||||
return frappe.new_doc(doctype);
|
||||
if (frappe.boot.address_autocomplete_enabled === 1 && doctype === "Address") {
|
||||
new frappe.ui.AddressAutocompleteDialog({
|
||||
title: __("New Address"),
|
||||
link_doctype: frm.doc.doctype,
|
||||
link_name: frm.doc.name,
|
||||
after_insert: function (doc) {
|
||||
frm.reload_doc();
|
||||
},
|
||||
}).show();
|
||||
} else {
|
||||
frappe.new_doc(doctype);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue