"use strict";(self["webpackChunkcarabi_x2"]=self["webpackChunkcarabi_x2"]||[]).push([[7105],{3106:function(t,e,i){i.r(e),i.d(e,{default:function(){return d}});var l=function(){var t=this,e=t._self._c;return e("div",{staticClass:"flex-grow flex-column"},[e("div",{staticClass:"flex-row uk-flex-space-between",staticStyle:{padding:"5px 10px 0"}},[e("div",{staticClass:"flex-grow"},[e("button",{staticClass:"uk-button uk-button-small uk-button-primary",attrs:{type:"button"},on:{click:function(e){t.showApplyAll=!t.showApplyAll}}},[t._v("Изменить все")])]),e("select",{directives:[{name:"model",rawName:"v-model",value:t.filterValues,expression:"filterValues"}],staticClass:"uk-select uk-form-small",staticStyle:{width:"80px"},on:{change:function(e){var i=Array.prototype.filter.call(e.target.options,(function(t){return t.selected})).map((function(t){var e="_value"in t?t._value:t.value;return e}));t.filterValues=e.target.multiple?i:i[0]}}},[e("option",{attrs:{value:""}},[t._v("Все")]),t._l(t.fields,(function(i){return e("option",{key:i.id,domProps:{value:i.id}},[t._v(t._s(i.title))])}))],2),e("div",{staticClass:"flex-row uk-margin-small-left",staticStyle:{width:"160px"}},[e("input",{directives:[{name:"model",rawName:"v-model",value:t.rawFilterContext,expression:"rawFilterContext"}],staticClass:"flex-grow uk-input uk-form-small",attrs:{type:"text",placeholder:"поиск..."},domProps:{value:t.rawFilterContext},on:{input:function(e){e.target.composing||(t.rawFilterContext=e.target.value)}}}),e("button",{staticClass:"uk-button uk-button-small uk-button-default",on:{click:function(e){t.rawFilterContext=""}}},[e("i",{staticClass:"fas fa-times"})])])]),t.showApplyAll?e("div",{staticClass:"flex-row",staticStyle:{padding:"5px 10px 0px"}},t._l(t.fields,(function(i){return e("div",{key:i.id,staticClass:"flex-grow flex-row"},[e("div",{staticClass:"flex-grow",staticStyle:{"line-height":"28px","text-align":"right"}},[t._v(t._s(i.title)+":")]),e("button",{staticClass:"uk-button uk-button-small uk-button-success uk-margin-small-left",staticStyle:{width:"30px",padding:"0"},on:{click:function(e){return t.setAll(i.id,!0)}}},[e("i",{staticClass:"fas fa-check"})]),e("button",{staticClass:"uk-button uk-button-small uk-button-danger uk-margin-small-left",on:{click:function(e){return t.setAll(i.id,!1)}}},[e("i",{staticClass:"fas fa-times"})])])})),0):t._e(),e("div",{ref:"grid",staticClass:"flex-grow flex-column",staticStyle:{padding:"5px 10px"}})])},s=[],r=(i(3216),i(2158)),a=i(6587),n={name:"PermissionsPanel",components:{},props:{type:String,items:Array},data:()=>({filterValues:"",rawFilterContext:"",showApplyAll:!1}),computed:{fields(){return[{id:"READ",title:"Чтение"},{id:"EDIT",title:"Запись"},{id:"ACCESS",title:"Доступ"}]},filterContext(){return this.rawFilterContext.trim().toLowerCase()},filtredItems(){let t=[...this.items];return this.filterValues&&(t=t.filter((t=>t[this.filterValues]))),this.filterContext&&(t=t.filter((t=>-1!==t.context.indexOf(this.filterContext)))),t}},watch:{filtredItems(){this.grid.setData(this.filtredItems)}},mounted(){this.initGrid(),this.grid.setData(this.filtredItems)},methods:{initGrid(){this.grid=new r.A(a(this.$refs.grid));var t=[{title:"Чтение",name:"READ",width:60,renderer:this.renderCheckbox("READ")},{title:"Запись",name:"WRITE",width:60,renderer:this.renderCheckbox("EDIT")},{title:"Доступ",name:"ACCESS",width:60,renderer:this.renderCheckbox("ACCESS")}];"users"===this.type?(t.push({title:"Пользователь",name:"FIO",width:230,resizable:!0}),t.push({title:"Подразделение",name:"PODR_NAME",width:140,resizable:!0})):(t.push({title:"Роль",name:"ROLE_NAME",width:200,resizable:!0}),t.push({title:"Сист. название",name:"ROLE_SYS_NAME",width:150,resizable:!0})),this.grid.setColumns(t)},renderCheckbox(t){return(e,i,l,s)=>{l.attr("checkbox","checkbox"),l.html('<div class="cara-table-content-cell--title uk-text-center"><input class="pos-checkbox uk-margin-remove" type="checkbox"></div>');var r=l.find("input");i[t]&&r.prop("checked",!0),r.on("click",(e=>{i[t]=r.prop("checked")?1:0,i.changed=!0}))}},setAll(t,e){for(let i of this.filtredItems)i[t]=e?1:0,i.changed=!0;this.grid.refresh(),this.showApplyAll=!1}}},o=n,u=i(1656),c=(0,u.A)(o,l,s,!1,null,null,null),d=c.exports}}]);
//# sourceMappingURL=PermissionsPanel.62e6c5de.js.map