2026-10-18 17:01:36 +00:00
|
|
|
|
|
|
|
|
// ===============
|
|
|
|
|
// Setup Dropdowns
|
|
|
|
|
// ===============
|
|
|
|
|
|
2026-10-20 06:45:30 -04:00
|
|
|
$(document).ready(function () {
|
2026-10-18 17:01:36 +00:00
|
|
|
|
|
|
|
|
var $application = $("#APPLICATION_MNEMONIC").val(),
|
|
|
|
|
$sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}");
|
|
|
|
|
|
|
|
|
|
// --------------------------------
|
|
|
|
|
// Open previously opened Accordion
|
|
|
|
|
// --------------------------------
|
|
|
|
|
|
|
|
|
|
if ((typeof $sessionStorage.reveal !== "undefined") && ($sessionStorage.reveal !== "")) {
|
|
|
|
|
|
|
|
|
|
var reveal = $sessionStorage.reveal.split("|");
|
|
|
|
|
|
|
|
|
|
reveal.forEach((element) => {
|
|
|
|
|
$("#" + element).collapse("show");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// -------------------
|
|
|
|
|
// Save open Accordion
|
|
|
|
|
// -------------------
|
|
|
|
|
|
2026-10-20 06:45:30 -04:00
|
|
|
$("#dropdown-accordion").on("shown.bs.collapse hidden.bs.collapse", async function (e) {
|
2026-10-18 17:01:36 +00:00
|
|
|
|
|
|
|
|
const open = new Array();
|
|
|
|
|
|
2026-10-20 06:45:30 -04:00
|
|
|
$(".collapse.show").each(function () {
|
2026-10-18 17:01:36 +00:00
|
|
|
open.push($(this).attr("id"));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$sessionStorage.reveal = open.join("|");
|
|
|
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
|
// Add Button
|
|
|
|
|
// ----------
|
|
|
|
|
|
2026-10-20 06:45:30 -04:00
|
|
|
$(".btnAdd").on("click", async function () {
|
2026-10-18 17:01:36 +00:00
|
|
|
|
|
|
|
|
$sessionStorage.action = "Dropdowns.addDropdown";
|
|
|
|
|
$sessionStorage.dropdowntype_serial = $(this).data("dropdowntype-serial");
|
|
|
|
|
$sessionStorage.addDropdown = "Dropdowns.setupDropdowns";
|
|
|
|
|
|
|
|
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
|
|
|
|
|
|
|
|
|
formSubmit($sessionStorage);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// -----------
|
|
|
|
|
// Done Button
|
|
|
|
|
// -----------
|
|
|
|
|
|
2026-10-20 06:45:30 -04:00
|
|
|
$(".btnDone").on("click", async function () {
|
2026-10-18 17:01:36 +00:00
|
|
|
|
|
|
|
|
formSubmit({ action : "" });
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// ----
|
|
|
|
|
// Edit
|
|
|
|
|
// ----
|
|
|
|
|
|
2026-10-20 06:45:30 -04:00
|
|
|
$(".dropdown-table tbody td:not('.dropdown_default, .dropdown_active')").on("click touch", async function (e) {
|
2026-10-18 17:01:36 +00:00
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
|
|
$sessionStorage.action = "Dropdowns.editDropdown";
|
|
|
|
|
$sessionStorage.dropdown_serial = $(this).closest("tr").data("dropdown-serial");
|
|
|
|
|
$sessionStorage.editDropdown = "Dropdowns.setupDropdowns";
|
|
|
|
|
|
|
|
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
|
|
|
|
|
|
|
|
|
formSubmit($sessionStorage);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// ----------------------------
|
|
|
|
|
// Process the Default Checkbox
|
|
|
|
|
// ----------------------------
|
|
|
|
|
|
2026-10-20 06:45:30 -04:00
|
|
|
const savedDefaults=new Map();
|
|
|
|
|
$('input[name="dropdown_default"]').each(function(){savedDefaults.set($(this).closest('tr').data('dropdown-serial'),this.checked);});
|
|
|
|
|
$('input[name="dropdown_default"]').on('change',async function(){
|
|
|
|
|
const box=$(this),row=box.closest('tr'),id=row.data('dropdown-serial'),type=row.data('dropdown-dropdowntype'),checked=this.checked;
|
|
|
|
|
box.prop('disabled',true);
|
|
|
|
|
try{
|
|
|
|
|
await formPost({action:'Dropdowns.updateDropdownDefault',dropdown_serial:id,dropdown_dropdowntype:type,dropdown_checked:checked});
|
|
|
|
|
$('input[name="dropdown_default"]').each(function(){
|
|
|
|
|
const parent=$(this).closest('tr');if(parent.data('dropdown-dropdowntype')===type){const selected=parent.data('dropdown-serial')===id?checked:false;$(this).prop('checked',selected);savedDefaults.set(parent.data('dropdown-serial'),selected);}
|
|
|
|
|
});
|
|
|
|
|
}catch(error){$('input[name="dropdown_default"]').each(function(){$(this).prop('checked',!!savedDefaults.get($(this).closest('tr').data('dropdown-serial')));});}
|
|
|
|
|
finally{box.prop('disabled',false);}
|
2026-10-18 17:01:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// ---------------------------
|
|
|
|
|
// Process the Active Checkbox
|
|
|
|
|
// ---------------------------
|
|
|
|
|
|
2026-10-20 06:45:30 -04:00
|
|
|
$("input[name='dropdown_active']").on("change", async function (e) {
|
2026-10-18 17:01:36 +00:00
|
|
|
|
2026-10-20 06:45:30 -04:00
|
|
|
try { await formPost({ action : "Dropdowns.updateDropdownActive", dropdown_serial : $(this).data("dropdown-serial"), dropdown_checked: $(this).prop("checked") }); } catch(error) { $(this).prop("checked", !$(this).prop("checked")); }
|
2026-10-18 17:01:36 +00:00
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|