diff --git a/hal-core/resource/resource/web/api/openapi.json b/hal-core/resource/resource/web/api/openapi.json index 1fd17ddc..796d91da 100644 --- a/hal-core/resource/resource/web/api/openapi.json +++ b/hal-core/resource/resource/web/api/openapi.json @@ -170,7 +170,7 @@ "min", "hour", "day", - "week", + "week" ] }, "in": "query", diff --git a/hal-core/resource/resource/web/js/hal.js b/hal-core/resource/resource/web/js/hal.js index 0781738f..22be52e3 100644 --- a/hal-core/resource/resource/web/js/hal.js +++ b/hal-core/resource/resource/web/js/hal.js @@ -153,8 +153,9 @@ function initDynamicModalForm(modalId, formTemplateId = null, templateID = null) if (formTemplateId != null) { dynamicConf[formTemplateId] = []; $("#" + templateID + " div").each(function(){ - dynamicConf[formTemplateId][$(this).attr("id")] = $(this).html(); + dynamicConf[formTemplateId][$(this).prop("id")] = $(this).html(); }); + // Update dynamic inputs $("#" + modalId + " select[name=type]").change(function(){ $("#" + modalId + " #" + formTemplateId).html(dynamicConf[formTemplateId][$(this).val()]); @@ -170,26 +171,36 @@ function initDynamicModalForm(modalId, formTemplateId = null, templateID = null) if (formTemplateId != null) modal.find("#" + formTemplateId).empty(); // clear form div - // select dynamic form - var selector = modal.find("select[name=type]"); - selector.val(button.data("type")); - selector.change(); // Update dynamic inputs // set dynamic form data $.each(button.attr(), function(fieldName, value) { if(fieldName.startsWith("data-")) { - fieldName = fieldName.substring(5); + fieldName = fieldName.substring(5); // remove prefix data- + // case insensitive search - input = modal.find("input").filter(function() { - return this.name.toLowerCase() == fieldName; + var input = modal.find("input, select").filter(function() { + if (this.name.toLowerCase() == fieldName) { + if (this.type == "hidden" && modal.find("input[type=checkbox][name=" + fieldName + "]") != null) + return false; // Workaround for the default(false) boolean input + return true; + } + return false; }); - if (input.attr("type") == "checkbox") { // special handling for checkboxes - input.attr("value", "true"); - if (value=="true") input.attr("checked", "true"); - else input.removeAttr("checked"); - // Add default false value as a unchecked checkbox is not included in the post - input.parent().prepend(""); - } else { - input.val(value); + + if (input != null) { + if (input.prop("type") == "checkbox") { // special handling for checkboxes + input.prop("value", "true"); + input.prop("checked", value == "true"); + + if (modal.find("input[type=hidden][name=" + fieldName + "]") == null) { + // Add default false value as a unchecked checkbox is not included in the post + input.parent().prepend(""); + } + } else { + input.val(value); + + if (input.prop("tagName") == "SELECT") + input.change(); // required for select elements to update properly + } } } }); diff --git a/hal-core/resource/resource/web/trigger.tmpl b/hal-core/resource/resource/web/trigger.tmpl index 13b594b0..b14aed79 100644 --- a/hal-core/resource/resource/web/trigger.tmpl +++ b/hal-core/resource/resource/web/trigger.tmpl @@ -14,15 +14,23 @@