artabro/wire/modules/Process/ProcessTemplate/ProcessTemplateFieldCreator.min.js

1 line
2.8 KiB
JavaScript
Raw Permalink Normal View History

2024-08-27 11:35:37 +02:00
function TemplateFieldAddDialog(){var $a=$(this);var fieldReady=false;var $iframe=pwModalWindow($a.attr("href"),{},"large");$iframe.on("load",function(){var $button;var buttons=[];var $icontents=$iframe.contents();var n=0;$icontents.find("#breadcrumbs ul.nav, #Inputfield_submit_save_field_copy").hide();$icontents.find("#content form button.ui-button[type=submit]").each(function(){var text=$(this).text();var skip=false;$button=$(this);for(var i=0;i<buttons.length;i++){if(buttons[i].text==text||text.length<1)skip=true}if(!skip){buttons[n]={text:text,class:$button.hasClass("ui-priority-secondary")?"ui-priority-secondary":"",click:function(){$button.trigger("click");fieldReady=true}};n++}$button.hide()});if(fieldReady){buttons[n]={text:$("#fieldgroup_fields").attr("data-closeAddLabel"),class:$button&&$button.hasClass("ui-priority-secondary")?"ui-priority-secondary":"",click:function(){setTimeout(function(){buttonClicked()},500)}}}$iframe.setButtons(buttons);function buttonClicked(){var newFieldId=$icontents.find("#Inputfield_id").last().val();var $options=$("#fieldgroup_fields option");var numOptions=$options.length;$iframe.dialog("close");$options.eq(1).before($("<option></option>").val(newFieldId).text($icontents.find("#Inputfield_name").val()));$('#fieldgroup_fields option[value="'+newFieldId+'"]').attr("id","asm0option"+numOptions).attr("data-desc",$icontents.find("#field_label").val()).attr("data-status",$icontents.find("#Inputfield_type option:selected").text());$("#asmSelect0 option").eq(1).before($("<option></option>").val(newFieldId).text($icontents.find("#Inputfield_name").val()));$("#asmSelect0").find("option:selected").prop("selected",false);$('#asmSelect0 option[value="'+newFieldId+'"]').attr("rel","asm0option"+numOptions).attr("selected","selected").addClass("asmOptionDisabled").prop("disabled","disabled");var name=$icontents.find("#Inputfield_name").val();var type=$icontents.find("#Inputfield_type option:selected").val();if(type==="FieldtypeFieldsetOpen"||type==="FieldtypeFieldsetTabOpen"){name=name+"_END";var numOptions1=numOptions+1;var newFieldId1=parseInt(newFieldId)+1+"";$options.eq(1).before($("<option></option>").val(newFieldId1).text(name));var dataStatus="";var dataDesc="";$('#fieldgroup_fields option[value="'+newFieldId1+'"]').attr("id","asm0option"+numOptions1).attr("data-desc",dataDesc).attr("data-status",dataStatus);$("#asmSelect0 option").eq(1).after($("<option></option>").val(newFieldId1).text(name));$('#asmSelect0 option[value="'+newFieldId1+'"]').attr("rel","asm0option"+numOptions1).addClass("asmOptionDisabled").prop("disabled",true);$("#fieldgroup_fields").trigger("rebuild")}$('#asmSelect0 option[value="'+newFieldId+'"]').trigger("change").prop("selected",false)}});return false}$(document).ready(function(){$("#wrap_fieldgroup_fields p.description a").on("click",TemplateFieldAddDialog)});