"use strict";(self["webpackChunkcarabi_x2"]=self["webpackChunkcarabi_x2"]||[]).push([[6358],{3610:function(t,a,e){var r=e(3216),s=e(6848);const o=new s.Ay({data(){return{loaded:!1,dashboards:[]}},computed:{curDashboard(){return this.dashboards[this.dashboards.length-1]}},async created(){await this.fullReload()},methods:{async fullReload(){this.loaded=!1,this.dashboards=[],await this.loadStack(null,"Рабочий стол")},async reload(){let t=[];try{t=await r.vd.select("DM_GET_DESKTOP_MODULES_2",{DESKTOP_MODULE_ID:this.curDashboard.id},1e3)}catch(a){}this.curDashboard.buttons=t},async loadStack(t,a){this.loaded=!1,this.dashboards.push({title:a,id:t,buttons:null}),await this.reload(),this.loaded=!0},backStack(){this.dashboards.splice(-1,1)},async addReport(t){await r.vd.query("DM_CREATE_REPORT",{DOCUMENT_ID:t}),await this.reload()},async addPlugin(t){await r.vd.query("DM_CREATE_PLUGIN",{PLUGIN_SYSNAME:t}),await this.reload()}}});a.A=o},6595:function(t,a,e){e.r(a),e.d(a,{default:function(){return h}});var r=function(){var t=this,a=t._self._c;return a("Modal",{ref:"modal",attrs:{title:"Добавить в меню",autoOpen:!0},on:{closed:function(a){return t.$emit("closed")}}},[a("div",{staticClass:"uk-padding-small"},[a("div",{},[a("select",{directives:[{name:"model",rawName:"v-model",value:t.curBlockId,expression:"curBlockId"}],staticClass:"uk-select uk-form-small",on:{change:function(a){var e=Array.prototype.filter.call(a.target.options,(function(t){return t.selected})).map((function(t){var a="_value"in t?t._value:t.value;return a}));t.curBlockId=a.target.multiple?e:e[0]}}},[a("option",{attrs:{value:""}},[t._v("Выберите раздел")]),t._l(t.blocks,(function(e){return a("option",{key:e.ID,domProps:{value:e.ID}},[t._v(" "+t._s(e.NAME)+" ")])}))],2)]),t.curBlockId?a("div",{staticClass:"uk-margin-small-top"},[a("select",{directives:[{name:"model",rawName:"v-model",value:t.curGroupId,expression:"curGroupId"}],staticClass:"uk-select uk-form-small",on:{change:function(a){var e=Array.prototype.filter.call(a.target.options,(function(t){return t.selected})).map((function(t){var a="_value"in t?t._value:t.value;return a}));t.curGroupId=a.target.multiple?e:e[0]}}},[a("option",{attrs:{value:""}},[t._v("Выберите группу")]),t._l(t.curGroups,(function(e){return a("option",{key:e.GROUP_ID,domProps:{value:e.GROUP_ID}},[t._v(" "+t._s(e.NAME)+" ")])}))],2)]):t._e(),a("div",{staticClass:"uk-margin-small-top"},[a("div",{staticClass:"uk-text-muted"},[t._v("Название в меню:")]),a("input",{directives:[{name:"model",rawName:"v-model",value:t.newName,expression:"newName"}],staticClass:"uk-input",attrs:{placeholder:"Название в меню"},domProps:{value:t.newName},on:{input:function(a){a.target.composing||(t.newName=a.target.value)}}})])]),a("div",{staticClass:"uk-text-center uk-padding-small"},[t.errorText?a("div",{staticClass:"uk-text-danger uk-margin-small-bottom"},[t._v(t._s(t.errorText))]):t._e(),a("button",{staticClass:"uk-button uk-modal-close",attrs:{disabled:t.saving,type:"button"}},[t._v("Отмена")]),a("button",{staticClass:"uk-margin-small-left uk-button uk-button-primary",attrs:{disabled:t.saving,type:"button"},on:{click:function(a){return a.preventDefault(),t.Commit()}}},[t._v("Добавить")])])])},s=[],o=(e(3216),e(8466)),l=e(3610),n=e(2643),i=e(4041)["A"],u={name:"AddToMenuModal",components:{Modal:()=>e.e(8362).then(e.bind(e,2215))},props:{name:{type:String,default:""},saveCallback:{type:Function}},data(){return{curBlockId:"",curGroupId:"",newName:"",errorText:"",saving:!1}},computed:{blocks(){let t=o.A?.blocks||[];return[{ID:0,NAME:"Рабочий стол"},...t]},curGroups(){if(!this.curBlockId)return null;let t=o.A.groups.filter((t=>t.BLOCK_ID===this.curBlockId));return t}},watch:{curBlockId(){this.curGroupId=""}},async mounted(){this.newName=this.name},methods:{async Commit(){try{if(this.saving=!0,this.errorText="",""===this.curBlockId)throw new n.yo("Выберите раздел меню");if(0!==this.curBlockId&&""===this.curGroupId)throw new n.yo("Выберите группу меню");if(""===this.newName)throw new n.yo("Название не может быть пустым");await this.saveCallback({blockId:this.curBlockId,groupId:this.curGroupId,name:this.newName}),this.curBlockId?(await o.A.reload(),i.notify("Элемент добавлен в меню")):(await l.A.reload(),i.notify("Элемент добавлен на рабочий стол")),this.$refs.modal.close()}catch(t){console.log(typeof t),this.errorText=(0,n.CS)(t)}this.saving=!1}}},c=u,d=e(1656),m=(0,d.A)(c,r,s,!1,null,null,null),h=m.exports}}]);
//# sourceMappingURL=AddToMenu.36146b14.js.map