Current Path : /var/www/www-root/data/www/monolith-realty.ru/bitrix/js/ui/userfield/dist/ |
Current File : /var/www/www-root/data/www/monolith-realty.ru/bitrix/js/ui/userfield/dist/userfield.bundle.min.js |
this.BX=this.BX||{};this.BX.UI=this.BX.UI||{};(function(e,t){"use strict";class s{constructor(e,s){this.progress=false;this.deleted=false;this.setData(e);if(t.Type.isPlainObject(s)){if(t.Type.isString(s.languageId)){this.setLanguageId(s.languageId)}this.moduleId=s.moduleId}this.actions={get:"main.userFieldConfig.get",add:"main.userFieldConfig.add",update:"main.userFieldConfig.update",delete:"main.userFieldConfig.delete"}}load(){return new Promise(((e,s)=>{const i=[];if(this.progress){i.push("Another action is in progress");s(i);return}if(!this.isSaved()){i.push("Cant load UserField without id");s(i);return}const a=this.actions.get;if(!t.Type.isString(a)||a.length<=0){i.push("UserField load action is not specified");s(i);return}this.progress=true;t.ajax.runAction(a,{data:{id:this.getId(),moduleId:this.moduleId}}).then((t=>{this.progress=false;this.setData(t.data.field);e(t)})).catch((e=>{this.progress=false;e.errors.forEach((({message:e})=>{i.push(e)}));s(i)}))}))}save(){return new Promise(((e,s)=>{const i=[];if(this.progress){i.push("Another action is in progress");s(i);return}let a;let r;if(this.isSaved()){a=this.actions.update;r={id:this.getId(),field:this.getData(),moduleId:this.moduleId}}else{a=this.actions.add;r={field:this.getData(),moduleId:this.moduleId}}if(!t.Type.isString(a)||a.length<=0){i.push("UserField action is not specified");s(i);return}this.progress=true;t.ajax.runAction(a,{data:r}).then((t=>{this.progress=false;this.setData(t.data.field);e(t)})).catch((e=>{this.progress=false;e.errors.forEach((({message:e})=>{if(t.Type.isPlainObject(e)&&e.text){i.push(e.text)}else{i.push(e)}}));s(i)}))}))}delete(){return new Promise(((e,s)=>{const i=[];if(this.progress){i.push("Another action is in progress");s(i);return}if(!this.isSaved()){i.push("Cant delete UserField without id");s(i);return}const a=this.actions.delete;if(!t.Type.isString(a)||a.length<=0){i.push("UserField action is not specified");s(i);return}this.progress=true;t.ajax.runAction(a,{data:{id:this.getId(),moduleId:this.moduleId}}).then((()=>{this.deleted=true;this.progress=false;e()})).catch((e=>{this.progress=false;e.errors.forEach((({message:e})=>{i.push(e)}));s(i)}))}))}setLanguageId(e){this.languageId=e;return this}setModuleId(e){this.moduleId=e;return this}getLanguageId(){if(!this.languageId){return t.Loc.getMessage("LANGUAGE_ID")}return this.languageId}getId(){return t.Text.toInteger(this.data.id)}isSaved(){return this.getId()>0}setData(e){this.data=e;return this}getData(){return this.data}getName(){return this.data.fieldName}setName(e){if(this.isSaved()){console.error("Changing name is not available on saved UserField");return this}this.data.fieldName=e;return this}getEntityId(){return this.data.entityId}getUserTypeId(){return this.data.userTypeId}setUserTypeId(e){if(this.isSaved()){console.error("Changing userTypeId is not available on saved UserField");return this}this.data.userTypeId=e;return this}getEnumeration(){if(!t.Type.isArray(this.data.enum)){this.data.enum=[]}return this.data.enum}setEnumeration(e){this.data.enum=e;return this}static getTitleFieldNames(){return["editFormLabel","listColumnLabel","listFilterLabel"]}getTitle(){const e=s.getTitleFieldNames();const i=e.length;const a=this.getLanguageId();for(let s=0;s<i;s++){if(this.data[e[s]]&&t.Type.isString(this.data[e[s]][a])&&this.data[e[s]][a].length>0){return this.data[e[s]][a]}}return this.getName()}setTitle(e,s){if(t.Type.isString(e)&&e.length>0){if(!s){s=this.getLanguageId()}if(!this.data["editFormLabel"]){this.data["editFormLabel"]={}}this.data["editFormLabel"][s]=e;if(this.getUserTypeId()==="boolean"){if(!this.data.settings){this.data.settings={}}this.data.settings.LABEL_CHECKBOX=e}}return this}isMultiple(){return this.data.multiple==="Y"}isMandatory(){return this.data.mandatory==="Y"}setIsMandatory(e){this.data.mandatory=t.Text.toBoolean(e)?"Y":"N"}setIsMultiple(e){if(this.isSaved()){console.error("Changing multiple is not available on saved UserField");return this}this.data.multiple=t.Text.toBoolean(e)===true?"Y":"N";return this}getDetailUrl(){return this.data.detailUrl}isDeleted(){return this.deleted}serialize(){return JSON.stringify({data:this.data,languageId:this.languageId,moduleId:this.moduleId,progress:this.progress,deleted:this.deleted})}static unserialize(e){const t=JSON.parse(e);const i=new s(t.data,{languageId:t.languageId,moduleId:t.moduleId});i.progress=t.progress;i.deleted=t.deleted;return i}}e.UserField=s})(this.BX.UI.UserField=this.BX.UI.UserField||{},BX); //# sourceMappingURL=userfield.bundle.map.js