fix: defualt timezone not getting selected
This commit is contained in:
parent
d3605d2354
commit
84ae2cc543
@ -24,20 +24,15 @@ async function get_global_variables() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setup_timezone_selector() {
|
function setup_timezone_selector() {
|
||||||
/**
|
|
||||||
* window.timezones is a dictionary with the following structure
|
|
||||||
* { IANA name: Pretty name}
|
|
||||||
* For example : { Asia/Kolkata : "India Time - Asia/Kolkata"}
|
|
||||||
*/
|
|
||||||
let timezones_element = document.getElementById('appointment-timezone');
|
let timezones_element = document.getElementById('appointment-timezone');
|
||||||
let offset = new Date().getTimezoneOffset();
|
let local_timezone = moment.tz.guess()
|
||||||
Object.keys(window.timezones).forEach((timezone) => {
|
window.timezones.forEach(timezone => {
|
||||||
let opt = document.createElement('option');
|
let opt = document.createElement('option');
|
||||||
opt.value = timezone;
|
opt.value = timezone;
|
||||||
if (timezone == moment.tz.guess()) {
|
if (timezone == local_timezone) {
|
||||||
opt.selected = true;
|
opt.selected = true;
|
||||||
}
|
}
|
||||||
opt.innerHTML = window.timezones[timezone]
|
opt.innerHTML = timezone;
|
||||||
timezones_element.appendChild(opt)
|
timezones_element.appendChild(opt)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -25,18 +25,20 @@ def get_appointment_settings():
|
|||||||
|
|
||||||
@frappe.whitelist(allow_guest=True)
|
@frappe.whitelist(allow_guest=True)
|
||||||
def get_timezones():
|
def get_timezones():
|
||||||
from babel.dates import get_timezone, get_timezone_name, Locale
|
import pytz
|
||||||
from frappe.utils.momentjs import get_all_timezones
|
return pytz.all_timezones
|
||||||
|
# from babel.dates import get_timezone, get_timezone_name, Locale
|
||||||
|
# from frappe.utils.momentjs import get_all_timezones
|
||||||
|
|
||||||
translated_dict = {}
|
# translated_dict = {}
|
||||||
locale = Locale.parse(frappe.local.lang, sep="-")
|
# locale = Locale.parse(frappe.local.lang, sep="-")
|
||||||
|
|
||||||
for tz in get_all_timezones():
|
# for tz in get_all_timezones():
|
||||||
timezone_name = get_timezone_name(get_timezone(tz), locale=locale, width='short')
|
# timezone_name = get_timezone_name(get_timezone(tz), locale=locale, width='short')
|
||||||
if timezone_name:
|
# if timezone_name:
|
||||||
translated_dict[tz] = timezone_name + ' - ' + tz
|
# translated_dict[tz] = timezone_name + ' - ' + tz
|
||||||
|
|
||||||
return translated_dict
|
# return translated_dict
|
||||||
|
|
||||||
@frappe.whitelist(allow_guest=True)
|
@frappe.whitelist(allow_guest=True)
|
||||||
def get_appointment_slots(date, timezone):
|
def get_appointment_slots(date, timezone):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user