CMXX - Dealers
This commit is contained in:
@@ -1163,4 +1163,44 @@ function decodeVIN(){
|
||||
console.log(error)
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function toggleClosed(day, skipToggle = false) {
|
||||
const checkbox = document.getElementById(`closed_${day}`);
|
||||
const startInput = document.getElementById(`start_${day}`);
|
||||
const endInput = document.getElementById(`end_${day}`);
|
||||
|
||||
if (checkbox.checked) {
|
||||
// If closed, disable time inputs and set hidden field for null value
|
||||
startInput.disabled = true;
|
||||
endInput.disabled = true;
|
||||
|
||||
// Remove the time inputs from form submission
|
||||
startInput.name = "";
|
||||
endInput.name = "";
|
||||
|
||||
// Add a hidden field to explicitly set the day to null
|
||||
if (!document.getElementById(`null_${day}`)) {
|
||||
const hiddenField = document.createElement('input');
|
||||
hiddenField.type = 'hidden';
|
||||
hiddenField.id = `null_${day}`;
|
||||
hiddenField.name = `opening_hours[${day}]`;
|
||||
hiddenField.value = 'null';
|
||||
checkbox.parentNode.appendChild(hiddenField);
|
||||
}
|
||||
} else {
|
||||
// If open, enable time inputs
|
||||
startInput.disabled = false;
|
||||
endInput.disabled = false;
|
||||
|
||||
// Restore the time input names for form submission
|
||||
startInput.name = `opening_hours[${day}][start]`;
|
||||
endInput.name = `opening_hours[${day}][end]`;
|
||||
|
||||
// Remove the hidden null field if it exists
|
||||
const hiddenField = document.getElementById(`null_${day}`);
|
||||
if (hiddenField) {
|
||||
hiddenField.parentNode.removeChild(hiddenField);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user