diff --git a/frappe/boot.py b/frappe/boot.py index c53d6bcc66..ad729746fe 100644 --- a/frappe/boot.py +++ b/frappe/boot.py @@ -11,7 +11,6 @@ from frappe.core.doctype.navbar_settings.navbar_settings import get_app_logo, ge from frappe.desk.doctype.route_history.route_history import frequently_visited_links from frappe.desk.form.load import get_meta_bundle from frappe.email.inbox import get_email_accounts -from frappe.geo.country_info import get_all from frappe.model.base_document import get_controller from frappe.query_builder import DocType from frappe.query_builder.functions import Count @@ -68,7 +67,6 @@ def get_bootinfo(): bootinfo.home_folder = frappe.db.get_value("File", {"is_home_folder": 1}) bootinfo.navbar_settings = get_navbar_settings() bootinfo.notification_settings = get_notification_settings() - get_country_codes(bootinfo) set_time_zone(bootinfo) # ipinfo @@ -393,11 +391,6 @@ def get_notification_settings(): return frappe.get_cached_doc("Notification Settings", frappe.session.user) -def get_country_codes(bootinfo): - country_codes = get_all() - bootinfo.country_codes = frappe._dict(country_codes) - - @frappe.whitelist() def get_link_title_doctypes(): dts = frappe.get_all("DocType", {"show_title_field_in_link": 1}) diff --git a/frappe/public/js/frappe/form/controls/phone.js b/frappe/public/js/frappe/form/controls/phone.js index 83096f23a1..16ee56b841 100644 --- a/frappe/public/js/frappe/form/controls/phone.js +++ b/frappe/public/js/frappe/form/controls/phone.js @@ -1,14 +1,27 @@ - +import localforage from "localforage"; import PhonePicker from '../../phone_picker/phone_picker'; frappe.ui.form.ControlPhone = class ControlPhone extends frappe.ui.form.ControlData { - make_input() { + async make_input() { + await this.setup_country_codes(); super.make_input(); this.setup_country_code_picker(); this.input_events(); } + async setup_country_codes() { + const key = "country_code_info" + let data = await localforage.getItem(key); + if (data) { + this.country_codes = data; + } else { + const data = await frappe.xcall("frappe.geo.country_info.get_country_timezone_info"); + this.country_codes = data?.country_info; + localforage.setItem(key, this.country_codes); + } + } + input_events() { this.$input.keydown((e) => { const key_code = e.keyCode; @@ -24,8 +37,8 @@ frappe.ui.form.ControlPhone = class ControlPhone extends frappe.ui.form.ControlD if (!country) { return this.reset_input(); } - const country_code = frappe.boot.country_codes[country].code; - const country_isd = frappe.boot.country_codes[country].isd; + const country_code = this.country_codes[country].code; + const country_isd = this.country_codes[country].isd; this.set_flag(country_code); this.$icon = this.selected_icon.find('svg'); this.$flag = this.selected_icon.find('img'); @@ -69,7 +82,7 @@ frappe.ui.form.ControlPhone = class ControlPhone extends frappe.ui.form.ControlD let picker_wrapper = $('