YetiForceCompany/YetiForceCRM

View on GitHub
public_html/layouts/basic/modules/Users/resources/Edit.min.js

Summary

Maintainability
A
0 mins
Test Coverage
'use strict';

/*+***********************************************************************************
 * The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 * Contributor(s): YetiForce S.A.
 *************************************************************************************/"use strict";Vtiger_Edit_Js("Users_Edit_Js",{/**
         * Function to register change event for currency separator
         */registerChangeEventForCurrencySeparator:function registerChangeEventForCurrencySeparator(){var form=jQuery("form");jQuery("[name=\"currency_decimal_separator\"]",form).on("change",function(e){var element=jQuery(e.currentTarget),selectedValue=element.val(),groupingSeparatorValue=jQuery("[name=\"currency_grouping_separator\"]",form).data("selectedValue");if(groupingSeparatorValue==selectedValue){var message=app.vtranslate("JS_DECIMAL_SEPARATOR_AND_GROUPING_SEPARATOR_CANT_BE_SAME");Vtiger_Helper_Js.showMessage({text:message,type:"error"});var previousSelectedValue=element.data("selectedValue");element.find("option").removeAttr("selected"),element.find("option[value=\""+previousSelectedValue+"\"]").attr("selected","selected"),element.trigger("change");}else element.data("selectedValue",selectedValue);}),jQuery("[name=\"currency_grouping_separator\"]",form).on("change",function(e){var element=jQuery(e.currentTarget),selectedValue=element.val(),decimalSeparatorValue=jQuery("[name=\"currency_decimal_separator\"]",form).data("selectedValue");if(decimalSeparatorValue==selectedValue){var message=app.vtranslate("JS_DECIMAL_SEPARATOR_AND_GROUPING_SEPARATOR_CANT_BE_SAME");Vtiger_Helper_Js.showMessage({text:message,type:"error"});var previousSelectedValue=element.data("selectedValue");element.find("option").removeAttr("selected"),element.find("option[value=\""+previousSelectedValue+"\"]").attr("selected","selected"),element.trigger("change");}else element.data("selectedValue",selectedValue);});}},{duplicateCheckCache:{},userExistCheckCache:{},passCheckCache:{},//Hold the conditions for a hour format
hourFormatConditionMapping:!1,registerHourFormatChangeEvent:function registerHourFormatChangeEvent(){},getHourValues:function getHourValues(list,currentValue){var options="";for(var key in list)//IE Browser consider the prototype properties also, it should consider has own properties only.
if(list.hasOwnProperty(key)){var conditionValue=list[key];options+="<option value=\""+key+"\"",key==currentValue&&(options+=" selected=\"selected\" "),options+=">"+conditionValue+"</option>";}return options},changeStartHourValuesEvent:function changeStartHourValuesEvent(form){var thisInstance=this;form.on("change","select[name=\"hour_format\"]",function(e){var hourFormatVal=jQuery(e.currentTarget).val(),startHourElement=jQuery("select[name=\"start_hour\"]",form),endHourElement=jQuery("select[name=\"end_hour\"]",form),conditionStartSelected=startHourElement.val(),conditionEndSelected=endHourElement.val();if("undefined"==typeof thisInstance.hourFormatConditionMapping)return !1;var list=thisInstance.hourFormatConditionMapping.hour_format[hourFormatVal].start_hour;startHourElement.html(thisInstance.getHourValues(list,conditionStartSelected)).trigger("change"),endHourElement.html(thisInstance.getHourValues(list,conditionEndSelected)).trigger("change");});},triggerHourFormatChangeEvent:function triggerHourFormatChangeEvent(form){this.hourFormatConditionMapping=$("input[name=\"timeFormatOptions\"]",form).data("value"),this.changeStartHourValuesEvent(form),$("select[name=\"hour_format\"]",form).trigger("change");},/**
         * Function to register recordpresave event
         */registerRecordPreSaveEvent:function registerRecordPreSaveEvent(form){var thisInstance=this;form.on(Vtiger_Edit_Js.recordPreSave,function(e){var record=jQuery("input[name=\"record\"]").val(),progressIndicatorElement=jQuery.progressIndicator({message:app.vtranslate("JS_SAVE_LOADER_INFO"),position:"html",blockInfo:{enabled:!0}});record||jQuery("input[name=\"user_password\"]").val()==jQuery("input[name=\"confirm_password\"]").val()||(app.showNotify(app.vtranslate("JS_REENTER_PASSWORDS")),progressIndicatorElement.progressIndicator({mode:"hide"}),e.preventDefault()),thisInstance.verifyFormData().done(function(data){data.result.message&&(app.showNotify(data.result.message),progressIndicatorElement.progressIndicator({mode:"hide"}),e.preventDefault());}).fail(function(){progressIndicatorElement.progressIndicator({mode:"hide"}),e.preventDefault();});});},verifyFormData:function verifyFormData(){var aDeferred=jQuery.Deferred(),thisInstance=this;return thisInstance.verifyData().done(function(data){aDeferred.resolve(data);},function(){aDeferred.reject();}),aDeferred.promise()},verifyData:function verifyData(){var aDeferred=jQuery.Deferred();return AppConnector.request({async:!1,data:{module:"Users",action:"VerifyData",mode:"recordPreSave",email:jQuery("[name=\"email1\"]").val(),userName:jQuery("input[name=\"user_name\"]").val(),record:jQuery("input[name=\"record\"]").val(),password:jQuery("input[name=\"user_password\"]").val()}}).done(function(data){data.result?aDeferred.resolve(data):aDeferred.reject(data);}),aDeferred.promise()},registerValidatePassword:function registerValidatePassword(form){form.on("click",".js-validate-password",function(e){AppConnector.request({module:app.getModuleName(),action:"VerifyData",mode:"validatePassword",record:form.find("[name=\"record\"]").val(),password:form.find("[name=\""+$(e.currentTarget).data("field")+"\"]").val()}).done(function(data){data.success&&data.result&&Vtiger_Helper_Js.showMessage({text:data.result.message,type:data.result.type});});});},registerEvents:function registerEvents(){this._super();var form=this.getForm();this.triggerHourFormatChangeEvent(form),this.registerRecordPreSaveEvent(form),this.registerValidatePassword(form),Users_Edit_Js.registerChangeEventForCurrencySeparator();}});
//# sourceMappingURL=Edit.min.js.map