From ed80e9dff11da3ebb956a69dffe56705737b763d Mon Sep 17 00:00:00 2001 From: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> Date: Mon, 24 Dec 2018 13:06:30 +0530 Subject: [PATCH] [Fix]Quick entry with geolocation field issue fix (#6662) * Quick entry with geolocation field issue fix * Codacy issue fix --- .../public/js/frappe/form/controls/geolocation.js | 13 ++++++++++++- frappe/public/js/frappe/form/quick_entry.js | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/form/controls/geolocation.js b/frappe/public/js/frappe/form/controls/geolocation.js index 7dd0c7f64e..7ba1b0b822 100644 --- a/frappe/public/js/frappe/form/controls/geolocation.js +++ b/frappe/public/js/frappe/form/controls/geolocation.js @@ -12,6 +12,17 @@ frappe.ui.form.ControlGeolocation = frappe.ui.form.ControlCode.extend({ ); this.map_area.prependTo($input_wrapper); this.$wrapper.find('.control-input').addClass("hidden"); + + if ($input_wrapper.is(':visible')) { + this.make_map(); + } else { + $(document).on('quick-entry-dialog-open', () => { + this.make_map(); + }); + } + }, + + make_map() { this.bind_leaflet_map(); this.bind_leaflet_draw_control(); this.bind_leaflet_locate_control(); @@ -19,6 +30,7 @@ frappe.ui.form.ControlGeolocation = frappe.ui.form.ControlCode.extend({ }, format_for_input(value) { + if (!this.map) return; // render raw value from db into map this.clear_editable_layers(); if(value) { @@ -52,7 +64,6 @@ frappe.ui.form.ControlGeolocation = frappe.ui.form.ControlCode.extend({ }, bind_leaflet_map() { - var circleToGeoJSON = L.Circle.prototype.toGeoJSON; L.Circle.include({ toGeoJSON: function() { diff --git a/frappe/public/js/frappe/form/quick_entry.js b/frappe/public/js/frappe/form/quick_entry.js index e7857c3bf7..a0cd22163e 100644 --- a/frappe/public/js/frappe/form/quick_entry.js +++ b/frappe/public/js/frappe/form/quick_entry.js @@ -116,6 +116,10 @@ frappe.ui.form.QuickEntryForm = Class.extend({ this.dialog.onhide = () => frappe.quick_entry = null; this.dialog.show(); + this.dialog.$wrapper.on('shown.bs.modal', function() { + $(document).trigger('quick-entry-dialog-open'); + }); + this.dialog.refresh_dependency(); this.set_defaults();