"use strict";(self["webpackChunkcarabi_x2"]=self["webpackChunkcarabi_x2"]||[]).push([[8339],{4620:function(e,i,t){t.r(i),t.d(i,{default:function(){return r}});var o=function(){var e=this,i=e._self._c;return i("div",{staticClass:"field-content"},[e.loading?i("span",{staticClass:"field_value field-content--value",staticStyle:{"min-height":"17px"}},[e._v(" Загрузка... ")]):e.saving?i("span",{staticClass:"field_value field-content--value",staticStyle:{"min-height":"17px"}},[e._v(" Сохранение... ")]):e.inline?e._e():i("span",{staticClass:"field_value field-content--value",staticStyle:{"min-height":"17px"}},[e._v(" Редактируется... ")]),e.loading?e._e():i(e.fieldComponent,{ref:"editor",tag:"component",attrs:{value:e.value,field:e.field},on:{close:function(i){return e.$emit("close")},change:e.changeValue,"document-open":function(i){return e.documentOpen(i)}}})],1)},s=[],n=t(2643);const l=["simple","textModal","mediaModal","multiPhone","externalLinkModal","externalLinkQuery"];var d={name:"PropEditor",components:{},props:{cardId:Number,field:Object},data(){return{inline:!1,fieldName:null,fieldComponent:null,clickFlag:!1,loading:!0,saving:!1,value:null}},computed:{},created(){},async mounted(){this.fields=await t.e(6756).then(t.bind(t,6104)),this.fields=this.fields.default;let e=this.fields.getComponent(this.field);if(console.log("curComponent",e),"buttonsYesNo"===e.name&&(e.name="autoYesNo",e.component=()=>t.e(2700).then(t.bind(t,1439)),e.inline=!1),this.fieldName=e.name,this.fieldComponent=e.component,this.inline=e.inline,!this.processDocProp())return console.log("processDocProp - close without open"),void this.$emit("close");if(!this.fieldComponent)throw this.$emit("close"),"Тип данных не реализован";this.value=await this.fields.loadValue(this.field),this.loading=!1,await this.$nextTick(),this.bodyClick=e=>{this.bodyClickMethod(e)},this.bodyMouseDown=e=>{this.bodyMouseDownMethod(e)},this.clickTarget=null,this.inline&&setTimeout((()=>{document.body.addEventListener("click",this.bodyClick),document.body.addEventListener("mousedown",this.bodyMouseDown)}),0),this.$emit("start")},beforeDestroy(){document.body.removeEventListener("click",this.bodyClick),document.body.removeEventListener("mousedown",this.bodyMouseDown)},methods:{processDocProp(){return this.field.VIEW_FIELD?(console.log("processDocProp - its a view field"),!1):17===this.field.DOCPROP_KIND?(console.log("processDocProp - counter readonly"),!1):"ADDRESS"===this.field.DOCPROP_PRESENTATION?(this.fieldComponent=()=>t.e(2540).then(t.bind(t,2321)),this.fieldName="addressModal",!0):"DADATA"===this.field.DOCPROP_PRESENTATION?(this.fieldComponent=()=>t.e(6640).then(t.bind(t,4541)),this.fieldName="fieldDadata",!0):9===this.field.DOCPROP_KIND&&"1"===this.field.DOCPROP_SQL?(console.log("processDocProp - open/create document"),this.$emit("property-open"),!1):12===this.field.DOCPROP_KIND?(console.log("processDocProp - open backref"),this.$emit("property-open"),!1):(16===this.field.DOCPROP_KIND&&(this.fieldComponent=()=>t.e(7918).then(t.bind(t,3334)),this.fieldName="mediaModal"),"XML_FILTER"===this.field.DOCPROP_PRESENTATION&&(this.fieldComponent=()=>t.e(4747).then(t.bind(t,8547)),this.fieldName="xmlFilterModal"),"EXTERNAL_FILE"===this.field.DOCPROP_PRESENTATION&&(this.fieldComponent=()=>t.e(5226).then(t.bind(t,6718)),this.fieldName="externalLinkQuery"),["DOC_KIND_PATH","DOC_PROP_PATH"].includes(this.field.DOCPROP_PRESENTATION)&&(this.fieldComponent=()=>t.e(6693).then(t.bind(t,4338)),this.fieldName="docPathModal"),!this.field.DOCPROP_READONY||-1!==l.indexOf(this.fieldName)||(console.log("processDocProp - field is readonly"),!1))},save(){this.saving||this.$refs.editor&&this.$refs.editor.save()},cancel(){this.$refs.editor.cancel()},async changeValue(e){try{this.saving=!0,console.log("changeValue",e);await this.fields.saveValue(this.field,e.value,this.cardId);this.$emit("change")}catch(i){this.saving=!1,this.$emit("close"),(0,n.Qg)(i)}},bodyMouseDownMethod(e){this.clickTarget=e.target},bodyClickMethod(e){this.clickTarget&&(this.clickFlag?this.clickFlag=!1:this.$refs.editor.$el.contains(this.clickTarget)?console.log("bodyClick contains",this.clickTarget):this.$refs.editor.checkClick&&this.$refs.editor.checkClick(this.clickTarget)?console.log("bodyClick checkBodyClick"):(console.log("bodyClick editorClose"),this.save()))},documentOpen(e){this.$emit("document-open",e)}}},c=d,a=t(1656),h=(0,a.A)(c,o,s,!1,null,null,null),r=h.exports}}]);
//# sourceMappingURL=PropEditor.85a5bf63.js.map