"use strict";(self["webpackChunkcarabi_x2"]=self["webpackChunkcarabi_x2"]||[]).push([[6035,6756],{1643:function(e,t,a){a.r(t),a.d(t,{default:function(){return D}});var n=function(){var e=this,t=e._self._c;return e.loaded?t("HtmlEditor",{attrs:{value:e.value},on:{save:e.save,change:e.change}}):t("Loader")},i=[],l=a(3216),d=a(6104),o={name:"CardPluginHtml",components:{Loader:()=>a.e(8326).then(a.bind(a,1259)),HtmlEditor:()=>a.e(2235).then(a.bind(a,1642))},props:{documentId:Number,info:Object,docModel:Object,pluginId:Number},data(){return{loaded:!1,changed:!1,field:null,value:"",newValue:""}},computed:{cardId(){return this.docModel.rootDocView.documentId}},async mounted(){if(this.field=await l.vd.selectRow("CARD_VIEW_PROPERTIES",{VIEW_GROUP_ID:this.pluginId,DOCUMENT_ID:this.documentId},1),!this.field)throw"Поле для редактора не найдено";this.value=await d["default"].loadValue(this.field)||"",this.loaded=!0},methods:{change(e){this.changed=!0,this.newValue=e,this.$emit("editing",!0)},async save(){this.changed&&(this.loaded=!1,this.$emit("editing",!0),await d["default"].saveValue(this.field,this.newValue,this.cardId),this.value=this.newValue,this.$emit("editing",!1),this.loaded=!0)}}},s=o,u=a(1656),m=(0,u.A)(s,n,i,!1,null,null,null),D=m.exports},6104:function(e,t,a){a.r(t);var n=a(3216);const i={10:"dictionary",9:"document",11:"dictionary"},l={5:"buttonsYesNo",17:"none",31:"dateTimeModal",32:"dateTimeModal",33:"dateTime",34:"dateTimeModal",35:"dateTimeModal",37:"dateTime",38:"dateTime",43:"weekModal"},d=["simple","phone","dateTime","buttonsYesNo"],o={simple:()=>Promise.all([a.e(588),a.e(2775)]).then(a.bind(a,5212)),dateTime:()=>Promise.all([a.e(588),a.e(430)]).then(a.bind(a,3389)),dateTimeModal:()=>Promise.all([a.e(588),a.e(7161)]).then(a.bind(a,1942)),dictionary:()=>a.e(8589).then(a.bind(a,8869)),weekModal:()=>Promise.all([a.e(588),a.e(4355),a.e(2952)]).then(a.bind(a,945)),textModal:()=>a.e(8203).then(a.bind(a,6975)),htmlModal:()=>a.e(8729).then(a.bind(a,2428)),multiPhone:()=>Promise.all([a.e(4355),a.e(5876)]).then(a.bind(a,535)),buttonsYesNo:()=>a.e(7236).then(a.bind(a,4653)),classifSimpleModal:()=>a.e(7467).then(a.bind(a,9210)),classifModal:()=>a.e(177).then(a.bind(a,8776)),document:()=>a.e(8214).then(a.bind(a,1821))};class s{getComponent(e){let t={name:null,component:null,inline:!1};return t.name=this.getComponentName(e),t.name?(t.component=o[t.name],t.inline=-1!==d.indexOf(t.name),t):t}getComponentName(e){console.log("getComponentName",e);let t=null;return 1===e.DOCPROP_KIND?(t="simple",l[e.DOCPROP_OBJECT]&&(t=l[e.DOCPROP_OBJECT]),"4"===e.DOCPROP_OBJECT&&(t="HTML"===e.DOCPROP_PRESENTATION?"htmlModal":"MULTILINE"===e.DOCPROP_PRESENTATION?"textModal":"simple"),"7"===e.DOCPROP_OBJECT&&(t="multiPhone")):20===e.DOCPROP_KIND?t="CLASSIF_OLD"===e.DOCPROP_PRESENTATION?"classifSimpleModal":"classifModal":i[e.DOCPROP_KIND]&&(t=i[e.DOCPROP_KIND]),console.log("componentName",t),t}getDataType(e){let t="single";return 9===e.DOCPROP_KIND?t="document":e.DOCPROP_MULTI&&(t="multi"),t}async checkPermission(e){let t=await n.FH.documents.getDocFieldPermission(e.DOCUMENT_ID,e.DOCPROP_DESCR);return 0===t.DOCPROP_READONY}async loadValue(e){let t=this.getDataType(e),a=null;if("document"===t)a=await n.FH.documents.getRefsByDocprop(e.DOCUMENT_ID,e.DOCPROP_DESCR),a=a.filter((e=>-1!==e.REF_ID)).map((e=>({DOCUMENT_ID:e.REF_ID,DOC_DESCR:e.DOC_DESCR?e.DOC_DESCR:""})));else if("multi"===t){let t=await n.FH.documents.getValues(e.DOCUMENT_ID,e.DOCPROP_DESCR);a=t.map((e=>e.VALUE))}else{let t=await n.FH.documents.getValue(e.DOCUMENT_ID,e.DOCPROP_DESCR);t&&(a=t.VALUE)}return a}async saveValue(e,t,a){let i=this.getDataType(e),l=null;return"document"===i?(await n.FH.cards.transactionClearRefs(a,e.DOCUMENT_ID,e.DOCPROP_DESCR),t.length&&(l=await n.FH.cards.transactionInsertRefs(a,e.DOCUMENT_ID,e.DOCPROP_DESCR,t.map((e=>e.DOCUMENT_ID))))):l="multi"===i?await n.FH.cards.transactionSetValues(a,e.DOCUMENT_ID,e.DOCPROP_DESCR,t):await n.FH.cards.transactionSetValue(a,e.DOCUMENT_ID,e.DOCPROP_DESCR,t),l}async deleteValue(e,t){let a=this.getDataType(e);"document"===a||"multi"===a?await this.saveValue(e,[],t):await this.saveValue(e,"",t)}}t["default"]=new s}}]);
//# sourceMappingURL=CardPluginHtml.04c892ad.js.map