"use strict";(self["webpackChunkcarabi_x2"]=self["webpackChunkcarabi_x2"]||[]).push([[1120],{43:function(t,e,n){n.r(e),n.d(e,{default:function(){return f}});var r=function(){var t=this,e=t._self._c;return e("div",{staticClass:"flex-column flex-grow"},[e("div",{staticClass:"flex-column flex-grow"},[e("draggable",{on:{end:t.dragEnd},model:{value:t.columns,callback:function(e){t.columns=e},expression:"columns"}},[t._l(t.columns,(function(n){return[n.renaming?e("span",{key:n.id,staticClass:"flex-row"},[e("input",{directives:[{name:"model",rawName:"v-model",value:n.title,expression:"col.title"},{name:"focus",rawName:"v-focus"}],staticClass:"uk-input uk-form-small flex-grow",domProps:{value:n.title},on:{keydown:function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"enter",13,e.key,"Enter")?null:t.rename(n)},input:function(e){e.target.composing||t.$set(n,"title",e.target.value)}}}),e("div",{staticStyle:{"margin-left":"2px"}},[e("button",{staticClass:"uk-button uk-button-small uk-button-primary",on:{click:function(e){return e.preventDefault(),t.rename(n)}}},[e("i",{staticClass:"fas fa-check"})])])]):e("div",{key:n.id,staticClass:"export-col flex-row"},[e("div",{staticClass:"flex-grow"},[e("i",{staticClass:"fas fa-arrows-alt-v",staticStyle:{padding:"0 5px"}}),t._v(" "+t._s(n.title)+" ")]),e("div",{},[e("a",{attrs:{href:"#"},on:{click:function(t){t.preventDefault(),n.renaming=!0}}},[e("i",{staticClass:"fas fa-edit"})]),e("a",{staticClass:"uk-text-danger",staticStyle:{"margin-left":"2px"},attrs:{href:"#"},on:{click:function(e){return e.preventDefault(),t.remove(n)}}},[e("i",{staticClass:"fas fa-trash-alt"})])])])]}))],2)],1),e("div",{staticClass:"uk-text-muted uk-text-center uk-margin-small"},[t._v(" порядок колонок можно менять ")])])},a=[],s=n(7833),l=n.n(s),i=n(1527),o=n.n(i),c={name:"PropsSelected",components:{Draggable:o()},props:{DocKindId:Number,DocKindName:String,xml:{type:String,default:null}},data(){return{columns:[]}},watch:{xml(){this.changing||this.parse()}},mounted(){this.parse()},methods:{dragEnd(){console.log("dragEnd",this.columns),this.format()},remove(t){let e=this.columns.indexOf(t);this.columns.splice(e,1),this.format()},rename(t){t.renaming=!1,this.format()},format(){let t={select:[],reference:[]},e=(t,n)=>{if(0===n.length)return t;let r=t.reference.find((t=>t._attributes.docprop_id===n[0].propId&&t._attributes.dockind_id===n[0].docKindId));r||(r={_attributes:{referencing:"join",docprop_id:n[0].propId,dockind_id:n[0].docKindId},select:[],reference:[]},t.reference.push(r));let a=[...n];return a.shift(),console.log("formatPath",r,a),e(r,a)};for(let r in this.columns)this.columns[r].columnnum=r;for(let r of this.columns){let n=e(t,r.path);n.select.push({_attributes:{docprop_id:r.propId,as:r.title,columnnum:r.columnnum}})}let n=l().js2xml({query:{formal:{_attributes:{dockind_id:this.DocKindId},...t}}},{compact:!0,spaces:2});console.log("xml",n),this.changing=!0,this.$emit("changed",n),this.changing=!1},parse(){let t=[],e=(n,r)=>{if(n.select)for(let e of n.select){let n=parseInt(e._attributes.docprop_id);isNaN(n)&&(n="");let a=e._attributes.as;a||(a="");let s=parseInt(e._attributes.columnnum);s||(s=0);let l=n;r.length&&(l=r[r.length-1].propId+"_"+l),t.push({id:l,propId:n,title:a,columnnum:s,path:r,renaming:!1})}if(n.reference)for(let t of n.reference){let n=parseInt(t._attributes.docprop_id),a=t._attributes.dockind_id;e(t,[...r,{propId:n,docKindId:a}])}},n=l().xml2js(this.xml,{compact:!0,alwaysArray:!0});try{n=n.query[0].formal[0]}catch(r){throw console.error(r),"Parser can't find query.formal in formal"}if(!n)throw"Parser can't find query.formal in formal";console.log("parseXml",n),e(n,[]),t.sort(((t,e)=>t.columnnum-e.columnnum)),this.columns=t}}},u=c,d=n(1656),m=(0,d.A)(u,r,a,!1,null,"6a0eaf72",null),f=m.exports}}]);
//# sourceMappingURL=PropsSelected.9b57db97.js.map