Commit e3abf0a4 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Merge branch 'S13797_checkboxlist_dynamic_update' into 'develop'

checkboxList dynamic update

See merge request !426
parents d47a67b5 90fff872
Pipeline #7088 passed with stage
in 1 minute and 54 seconds
......@@ -1230,6 +1230,7 @@ var QfqNS = QfqNS || {};
*/
n.QfqForm.prototype.applyFormConfiguration = function (configuration) {
var arrayLength = configuration.length;
var countElementArray = 0;
for (var i = 0; i < arrayLength; i++) {
var configurationItem = configuration[i];
var formElementName = configurationItem["form-element"];
......@@ -1238,47 +1239,63 @@ var QfqNS = QfqNS || {};
continue;
}
try {
var element = n.Element.getElement(formElementName);
// Cleaner way to set states for tinymce
// This triggers the event on the unaccesable textarea
// The tinymce registers a listener on the textarea
// See helper/tinyMCE.js for details
if(element.$element.hasClass('qfq-tinymce')) {
element.$element.trigger("blur", [configurationItem]);
}
var element = $('[name="' + QfqNS.escapeJqueryIdSelector(formElementName) + '"]:not([type="hidden"])');
// checkboxes without being in form groups aren't triggered over dynamic update, we need to handle them separately.
// for checkboxes with itemList (multiple) we need the countElementArray to trigger the right box
if($(element).attr('type') !== undefined){
if($(element).attr('type').toLowerCase() ==='checkbox'){
if(element.length > 1 && element.length !== countElementArray){
element = element[countElementArray];
countElementArray++;
}
if (configurationItem.value !== undefined) {
$(element).prop('checked',configurationItem.value);
}
}
}else {
// For all other form-elements the general script is used.
element = n.Element.getElement(formElementName);
// Cleaner way to set states for tinymce
// This triggers the event on the unaccesable textarea
// The tinymce registers a listener on the textarea
// See helper/tinyMCE.js for details
if (element.$element.hasClass('qfq-tinymce')) {
element.$element.trigger("blur", [configurationItem]);
}
if (configurationItem.value !== undefined) {
element.setValue(configurationItem.value);
}
if (configurationItem.value !== undefined) {
element.setValue(configurationItem.value);
}
if (configurationItem.readonly !== undefined) {
// Readonly and disabled is the same in our domain
element.setEnabled(!configurationItem.readonly);
}
if (configurationItem.readonly !== undefined) {
// Readonly and disabled is the same in our domain
element.setEnabled(!configurationItem.readonly);
}
if (configurationItem.disabled !== undefined) {
// Readonly and disabled is the same in our domain
element.setEnabled(!configurationItem.disabled);
}
if (configurationItem.disabled !== undefined) {
// Readonly and disabled is the same in our domain
element.setEnabled(!configurationItem.disabled);
}
if (configurationItem.hidden !== undefined) {
element.setHidden(configurationItem.hidden);
}
if (configurationItem.hidden !== undefined) {
element.setHidden(configurationItem.hidden);
}
if (configurationItem.required !== undefined) {
element.setRequired(configuration.required);
if(element.$element) {
if(element.$element.is("select")) {
element.$element.prop('required', configurationItem.required);
element.$element.attr('data-required', 'yes');
}
if(element.$element.is("input[type=hidden]")) {
console.log("Update Hidden");
element.$element.prop("required", configurationItem.required);
}
if (configurationItem.required !== undefined) {
element.setRequired(configuration.required);
if (element.$element) {
if (element.$element.is("select")) {
element.$element.prop('required', configurationItem.required);
element.$element.attr('data-required', 'yes');
}
if (element.$element.is("input[type=hidden]")) {
console.log("Update Hidden");
element.$element.prop("required", configurationItem.required);
}
}
}
countElementArray = 0;
}
} catch (e) {
n.Log.error(e.message);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment