public_html/layouts/basic/modules/Vtiger/resources/ChangesJsonModal.min.js
'use strict';
/* {[The file is published on the basis of YetiForce Public License 6.5 that can be found in the following directory: licenses/LicenseEN.txt or yetiforce.com]} */"use strict";$.Class("Base_ChangesJsonModal_JS",{},{/**
* Register select field
*/registerSelectField:function registerSelectField(){var _this=this,editInstance=Vtiger_Edit_Js.getInstance(this.module),form=this.container.find("form");this.container.find(".js-changesjson-select").on("change",function(e){var element=$(e.currentTarget),blockElement=element.closest(".js-form-row-container").find(".fieldValue"),fieldElement=blockElement.find("[data-validation-engine],[data-invalid-validation-engine]"),fieldInfo=fieldElement.data("fieldinfo");if(element.prop("checked")?_this.activeFieldValidation(fieldElement):_this.inactiveFieldValidation(fieldElement),void 0!==fieldInfo&&"reference"===fieldInfo.type){var mapFields=editInstance.getMappingRelatedField(fieldInfo.name,editInstance.getReferencedModuleName(blockElement),form);$.each(mapFields,function(key){var checkboxElement=form.find("[id=\"selectRow"+key+"\"]");checkboxElement.length&&checkboxElement.prop("disabled")&&(checkboxElement.prop("disabled",!1),checkboxElement.trigger("click"),checkboxElement.prop("disabled",!0));});}});},/**
* Deactivate field validation
* @param {jQuery}
*/inactiveFieldValidation:function inactiveFieldValidation(field){field.validationEngine("hide");var form=field.closest("form"),invalidFields=form.data("jqv").InvalidFields,fields=[field.get(0)];if(field.attr("data-invalid-validation-engine",field.attr("data-validation-engine")),field.removeAttr("data-validation-engine"),field.is("select")&&field.hasClass("select2")){var selectElement=app.getSelect2ElementFromSelect(field);selectElement.validationEngine("hide"),fields.push(selectElement.get(0));}for(var i in fields){var response=jQuery.inArray(fields[i],invalidFields);"-1"!=response&&invalidFields.splice(response,1);}},/**
* Activate field validation
* @param {jQuery}
*/activeFieldValidation:function activeFieldValidation(field){var validationVal=field.attr("data-invalid-validation-engine");"undefined"==typeof validationVal||(field.attr("data-validation-engine",validationVal),field.removeAttr("data-invalid-validation-engine"));},/**
* Function to inactive field for validation in a form
* this will remove data-validation-engine attr of all the elements
*/inactiveFieldsValidation:function inactiveFieldsValidation(){var editFieldList=this.container.find(".js-edit-field-list").data("value"),form=this.container.find("form");for(var fieldName in editFieldList){var fieldInfo=editFieldList[fieldName],fieldElement=form.find("[name=\""+fieldInfo.name+"\"]");if("reference"==fieldInfo.type?fieldElement=form.find("[name=\""+fieldInfo.name+"_display\"]"):("multipicklist"==fieldInfo.type||"sharedOwner"==fieldInfo.type)&&(fieldElement=form.find("[name=\""+fieldInfo.name+"[]\"]")),!(0==fieldElement.length||fieldElement.closest(".js-form-row-container").find(".js-changesjson-select").prop("checked"))){var elemData=fieldElement.data(),validationVal="validate[]";"validationEngine"in elemData&&(validationVal=elemData.validationEngine,delete elemData.validationEngine),fieldElement.attr("data-invalid-validation-engine",validationVal),fieldElement.removeAttr("data-validation-engine");}}},/**
* Register change tab
*/registerEventForTabClick:function registerEventForTabClick(){var form=this.container.find("form");this.container.on("click","a[data-toggle=\"tab\"]",function(e){form.validationEngine("validate");var invalidFields=form.data("jqv").InvalidFields;0<invalidFields.length&&e.stopPropagation();});},/**
* Register events
* @param {jQuery} container
*/registerEvents:function registerEvents(container){this.container=container,this.module=container.find("[name=\"module\"]").val(),this.container.find("form").validationEngine(app.validationEngineOptions),this.inactiveFieldsValidation(),this.registerEventForTabClick(),this.registerSelectField(),Vtiger_Edit_Js.getInstance(this.module).registerBasicEvents(container);}});
//# sourceMappingURL=ChangesJsonModal.min.js.map