fix: Load map libraries at build time to avoid async issues during geolocation render
- When gelocation control is built, it awaits loading of libraries - Withi the control everything is await but a layer above where multiple controls are sequentially built this breaks - Form render goes ahead without waiting for the gelocation control - The `onload_post_render` in `Location` cannot find the map wrapper as the control is still being built - Therefore, on a hard load, the control does not show up and appears on soft reload.
This commit is contained in:
parent
de490fc1f7
commit
5f6a6a025a
4 changed files with 10 additions and 15 deletions
|
|
@ -4,7 +4,6 @@ frappe.ui.form.ControlGeolocation = class ControlGeolocation extends frappe.ui.f
|
|||
static horizontal = false;
|
||||
|
||||
async make() {
|
||||
await frappe.require(this.required_libs);
|
||||
super.make();
|
||||
}
|
||||
|
||||
|
|
@ -216,17 +215,4 @@ frappe.ui.form.ControlGeolocation = class ControlGeolocation extends frappe.ui.f
|
|||
this.editableLayers.removeLayer(l);
|
||||
});
|
||||
}
|
||||
|
||||
get required_libs() {
|
||||
return [
|
||||
"assets/frappe/js/lib/leaflet_easy_button/easy-button.css",
|
||||
"assets/frappe/js/lib/leaflet_control_locate/L.Control.Locate.css",
|
||||
"assets/frappe/js/lib/leaflet_draw/leaflet.draw.css",
|
||||
"assets/frappe/js/lib/leaflet/leaflet.css",
|
||||
"assets/frappe/js/lib/leaflet/leaflet.js",
|
||||
"assets/frappe/js/lib/leaflet_easy_button/easy-button.js",
|
||||
"assets/frappe/js/lib/leaflet_draw/leaflet.draw.js",
|
||||
"assets/frappe/js/lib/leaflet_control_locate/L.Control.Locate.js",
|
||||
];
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ You can find the project at: https://github.com/domoritz/leaflet-locatecontrol
|
|||
if (typeof window !== 'undefined' && window.L) {
|
||||
module.exports = factory(L);
|
||||
} else {
|
||||
module.exports = factory(require('leaflet'));
|
||||
module.exports = factory(require('../leaflet/leaflet.js'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
import "./jquery-bootstrap";
|
||||
import "./lib/moment";
|
||||
import "../js/lib/leaflet/leaflet.js";
|
||||
import "../js/lib/leaflet_easy_button/easy-button.js";
|
||||
import "../js/lib/leaflet_draw/leaflet.draw.js";
|
||||
import "../js/lib/leaflet_control_locate/L.Control.Locate.js";
|
||||
import Sortable from "sortablejs";
|
||||
|
||||
window.SetVueGlobals = (app) => {
|
||||
|
|
|
|||
|
|
@ -4,3 +4,8 @@
|
|||
@import "~frappe-charts/dist/frappe-charts.min";
|
||||
@import "~plyr/dist/plyr";
|
||||
@import "./desk/index";
|
||||
|
||||
@import "frappe/public/js/lib/leaflet/leaflet.css";
|
||||
@import "frappe/public/js/lib/leaflet_easy_button/easy-button.css";
|
||||
@import "frappe/public/js/lib/leaflet_control_locate/L.Control.Locate.css";
|
||||
@import "frappe/public/js/lib/leaflet_draw/leaflet.draw.css";
|
||||
Loading…
Add table
Reference in a new issue