generated from jric11/baseProject
Chat's updates for security, db and workflow
Security and workflow regressions / regression (push) Has been cancelled
Security and workflow regressions / regression (push) Has been cancelled
This commit is contained in:
+20
-33
@@ -3,7 +3,7 @@
|
||||
// Setup Dropdowns
|
||||
// ===============
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
|
||||
var $application = $("#APPLICATION_MNEMONIC").val(),
|
||||
$sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}");
|
||||
@@ -26,11 +26,11 @@ $(document).ready(function() {
|
||||
// Save open Accordion
|
||||
// -------------------
|
||||
|
||||
$("#dropdown-accordion").on("shown.bs.collapse hidden.bs.collapse", function(e) {
|
||||
$("#dropdown-accordion").on("shown.bs.collapse hidden.bs.collapse", async function (e) {
|
||||
|
||||
const open = new Array();
|
||||
|
||||
$(".collapse.show").each(function() {
|
||||
$(".collapse.show").each(function () {
|
||||
open.push($(this).attr("id"));
|
||||
});
|
||||
|
||||
@@ -43,7 +43,7 @@ $(document).ready(function() {
|
||||
// Add Button
|
||||
// ----------
|
||||
|
||||
$(".btnAdd").on("click", function() {
|
||||
$(".btnAdd").on("click", async function () {
|
||||
|
||||
$sessionStorage.action = "Dropdowns.addDropdown";
|
||||
$sessionStorage.dropdowntype_serial = $(this).data("dropdowntype-serial");
|
||||
@@ -59,7 +59,7 @@ $(document).ready(function() {
|
||||
// Done Button
|
||||
// -----------
|
||||
|
||||
$(".btnDone").on("click", function() {
|
||||
$(".btnDone").on("click", async function () {
|
||||
|
||||
formSubmit({ action : "" });
|
||||
|
||||
@@ -69,7 +69,7 @@ $(document).ready(function() {
|
||||
// Edit
|
||||
// ----
|
||||
|
||||
$(".dropdown-table tbody td:not('.dropdown_default, .dropdown_active')").on("click touch", function(e) {
|
||||
$(".dropdown-table tbody td:not('.dropdown_default, .dropdown_active')").on("click touch", async function (e) {
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
@@ -87,40 +87,27 @@ $(document).ready(function() {
|
||||
// Process the Default Checkbox
|
||||
// ----------------------------
|
||||
|
||||
$(".dropdown_default").on("click", function(e) {
|
||||
|
||||
// Get the clicked Checkbox's current value.
|
||||
|
||||
var $this = $(e.target),
|
||||
checked = ($this.closest("tr").find("input[name='dropdown_default']").prop("checked"));
|
||||
|
||||
// Uncheck all Checkboxes.
|
||||
|
||||
$this.closest("tbody").find("input[name='dropdown_default']").each(function() {
|
||||
$(this).prop("checked", false);
|
||||
});
|
||||
|
||||
// Toggle the selected Checkbox.
|
||||
|
||||
$this.closest("tr").find("input[name='dropdown_default']").prop("checked", !checked);
|
||||
|
||||
// Update the Dropdowns Table with the chosen Default.
|
||||
|
||||
var dropdown_serial = $(e.target).closest("tr").data("dropdown-serial"),
|
||||
dropdown_dropdowntype = $(e.target).closest("tr").data("dropdown-dropdowntype"),
|
||||
dropdown_checked = !checked;
|
||||
|
||||
formPost({action : "Dropdowns.updateDropdownDefault", dropdown_serial : dropdown_serial, dropdown_dropdowntype : dropdown_dropdowntype, dropdown_checked: dropdown_checked});
|
||||
|
||||
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);}
|
||||
});
|
||||
|
||||
// ---------------------------
|
||||
// Process the Active Checkbox
|
||||
// ---------------------------
|
||||
|
||||
$("input[name='dropdown_active']").on("change", function(e) {
|
||||
$("input[name='dropdown_active']").on("change", async function (e) {
|
||||
|
||||
formPost({ action : "Dropdowns.updateDropdownActive", dropdown_serial : $(this).data("dropdown-serial"), dropdown_checked: $(this).prop("checked") });
|
||||
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")); }
|
||||
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user