UI - Fixing scheduler options

2785-UI-tag-reset-edit
dgtlmoon 3 weeks ago
parent 179ca171d4
commit f00b8e4efb

@ -30,12 +30,13 @@ $(document).ready(function () {
}) })
const timezoneInput = $('#application-timezone'); const timezoneInput = $('#application-timezone');
if(timezoneInput.length) {
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
if (!timezoneInput.val().trim()) { if (!timezoneInput.val().trim()) {
timezoneInput.val(timezone); timezoneInput.val(timezone);
timezoneInput.after('<div class="timezone-message">The timezone was set from your browser, <strong>be sure to press save!</strong></div>'); timezoneInput.after('<div class="timezone-message">The timezone was set from your browser, <strong>be sure to press save!</strong></div>');
} }
}
}); });

@ -24,16 +24,28 @@ $(document).ready(function () {
toggleVisibility('#time_schedule_limit-enabled, #requests-time_schedule_limit-enabled', '#schedule-day-limits-wrapper', true) toggleVisibility('#time_schedule_limit-enabled, #requests-time_schedule_limit-enabled', '#schedule-day-limits-wrapper', true)
$('#schedule-day-limits-wrapper').on('change click blur', 'input, checkbox, select', function() { setInterval(() => {
let success = true;
try {
// Show the current local time according to either placeholder or entered TZ name
if (timezone_text_widget.val().length) { if (timezone_text_widget.val().length) {
document.getElementById('local-time-in-tz').textContent = $('#local-time-in-tz').text(getTimeInTimezone(timezone_text_widget.val()));
getTimeInTimezone(timezone_text_widget.val());
} else { } else {
// So maybe use what is in the placeholder (which will be the default settings) // So maybe use what is in the placeholder (which will be the default settings)
document.getElementById('local-time-in-tz').textContent = $('#local-time-in-tz').text(getTimeInTimezone(timezone_text_widget.attr('placeholder')));
getTimeInTimezone(timezone_text_widget.attr('placeholder'));
} }
} catch (error) {
success = false;
$('#local-time-in-tz').text("");
console.error(timezone_text_widget.val())
}
$(timezone_text_widget).toggleClass('error', !success);
}, 500);
$('#schedule-day-limits-wrapper').on('change click blur', 'input, checkbox, select', function() {
let allOk = true; let allOk = true;
// Controls setting the warning that the time could overlap into the next day // Controls setting the warning that the time could overlap into the next day
@ -63,14 +75,13 @@ $(document).ready(function () {
}); });
warning_text.toggle(!allOk) warning_text.toggle(!allOk)
}, 500); });
$('table[id*="time_schedule_limit-saturday"], table[id*="time_schedule_limit-sunday"]').addClass("weekend-day") $('table[id*="time_schedule_limit-saturday"], table[id*="time_schedule_limit-sunday"]').addClass("weekend-day")
// Presets [weekend] [business hours] etc // Presets [weekend] [business hours] etc
$(document).on('click', '[data-template].set-schedule', function () { $(document).on('click', '[data-template].set-schedule', function () {
// Get the value of the 'data-template' attribute // Get the value of the 'data-template' attribute
switch ($(this).attr('data-template')) { switch ($(this).attr('data-template')) {
case 'business-hours': case 'business-hours':
$('.day-schedule table:not(.weekend-day) input[type="time"]').val('09:00') $('.day-schedule table:not(.weekend-day) input[type="time"]').val('09:00')
@ -87,16 +98,11 @@ $(document).ready(function () {
$('.day-schedule .weekend-day input[id*="-enabled"]').prop('checked', true); $('.day-schedule .weekend-day input[id*="-enabled"]').prop('checked', true);
break; break;
case 'reset': case 'reset':
$('.day-schedule .day-schedule input[type="time"]').val('00:00')
$('.day-schedule .day-schedule select[id*="-duration-hours"]').val('24'); $('.day-schedule input[type="time"]').val('00:00')
$('.day-schedule .day-schedule select[id*="-duration-minutes"]').val('0'); $('.day-schedule select[id*="-duration-hours"]').val('24');
$('.day-schedule .day-schedule input[id*="-enabled"]').prop('checked', true); $('.day-schedule select[id*="-duration-minutes"]').val('0');
break; $('.day-schedule input[id*="-enabled"]').prop('checked', true);
case 'once-per-day':
$('.day-schedule .day-schedule input[type="time"]').val('00:00')
$('.day-schedule .day-schedule select[id*="-duration-hours"]').val('24');
$('.day-schedule .day-schedule select[id*="-duration-minutes"]').val('0');
$('.day-schedule .day-schedule input[id*="-enabled"]').prop('checked', true);
break; break;
} }
}); });

@ -79,7 +79,7 @@
padding-left: 0.5rem; padding-left: 0.5rem;
padding-right: 0.5rem; padding-right: 0.5rem;
} }
#timespan-warning { #timespan-warning, input[id*='time_schedule_limit-timezone'].error {
color: #ff0000; color: #ff0000;
} }
.day-schedule.warning table { .day-schedule.warning table {

Loading…
Cancel
Save