You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
14 KiB
1 line
14 KiB
3 months ago
|
(window.webpackJsonp=window.webpackJsonp||[]).push([[10],{AVcX:function(e,t,i){"use strict";i.r(t),i.d(t,"BasicModule",function(){return R});var r=i("PCNd"),n=i("tyNb"),o=i("mrSG"),c=i("R0Ic"),s=i("0EQZ"),a=i("FvrZ"),l=i("0IaG"),d=i("8yBR"),h=i("fXoL"),u=i("bUwk"),p=i("Xi3o"),f=i("Olgc"),b=i("ofXK"),v=i("bTqV"),m=i("Xa2L"),g=i("bSwM"),_=i("NFeN"),w=i("sYmb");function S(e,t){1&e&&(h.Ub(0,"div",7),h.Pb(1,"mat-spinner"),h.Tb())}function O(e,t){if(1&e){const e=h.Vb();h.Ub(0,"mat-tree-node"),h.Pb(1,"button",11),h.Ub(2,"mat-checkbox",12),h.bc("change",function(){h.wc(e);const i=t.$implicit;return h.fc(2).toggle(i)}),h.Hc(3),h.gc(4,"translate"),h.Tb(),h.Tb()}if(2&e){const e=t.$implicit,i=h.fc(2);h.Cb(2),h.lc("checked",i.selection.isSelected(e.data.id)),h.Cb(1),h.Ic(h.hc(4,2,e.data.header))}}function C(e,t){if(1&e){const e=h.Vb();h.Ub(0,"mat-nested-tree-node"),h.Ub(1,"div"),h.Ub(2,"button",13),h.Ub(3,"mat-icon"),h.Hc(4),h.Tb(),h.Tb(),h.Ub(5,"mat-checkbox",14),h.bc("change",function(){h.wc(e);const i=t.$implicit;return h.fc(2).toggle(i)}),h.Hc(6),h.gc(7,"translate"),h.Tb(),h.Tb(),h.Ub(8,"div",15),h.Qb(9,16),h.Tb(),h.Tb()}if(2&e){const e=t.$implicit,i=h.fc(2);h.Cb(4),h.Ic(i.ctrl.isExpanded(e)?"expand_more":"chevron_right"),h.Cb(1),h.lc("checked",i.selected(e,!1))("indeterminate",i.selected(e,!0)),h.Cb(1),h.Ic(h.hc(7,5,e.data.header)),h.Cb(2),h.lc("@expand",i.ctrl.isExpanded(e)?"expanded":"collapsed")}}function y(e,t){if(1&e&&(h.Ub(0,"mat-tree",8),h.Fc(1,O,5,4,"mat-tree-node",9),h.Fc(2,C,10,7,"mat-nested-tree-node",10),h.Tb()),2&e){const e=h.fc();h.lc("dataSource",e.tree)("treeControl",e.ctrl),h.Cb(2),h.lc("matTreeNodeDefWhen",e.expandable)}}let T=(()=>{class e{constructor(e,t,i,r,n){this._id=e,this._httpService=t,this._i18nService=i,this._toastService=r,this._dialogRef=n,this._loading=!0,this.expandable=(e,t)=>{var i;return null===(i=t.children)||void 0===i?void 0:i.length},this.selected=(e,t)=>{if(this._tree.data){const i=this._ctrl.getDescendants(e);let r=i.some(e=>this._selection.isSelected(e.data.id));return t&&r&&(r=!i.every(e=>this._selection.isSelected(e.data.id))),r}},this.toggle=e=>{this._selection.toggle(e.data.id);const t=this._ctrl.getDescendants(e);t.length&&(this._selection.isSelected(e.data.id)?this._selection.select(...t.map(e=>e.data.id)):this._selection.deselect(...t.map(e=>e.data.id)));let i=e.parent;for(;i;)this._selection.isSelected(i.data.id)?this.selected(i,!1)||this._selection.deselect(i.data.id):this.selected(i,!1)&&this._selection.select(i.data.id),i=i.parent},this.save=()=>Object(o.a)(this,void 0,void 0,function*(){void 0!==this._httpService.post(`roles/${this._id}/menu`,this._selection.selected).catch(e=>Object(o.a)(this,void 0,void 0,function*(){var t,i;switch(e.status){case 410:this._toastService.show(this._i18nService.translate("routes.basic.role.error.gone."+(null===(i=null===(t=e.error)||void 0===t?void 0:t.propertyName)||void 0===i?void 0:i.toLowerCase()))),this._dialogRef.close({success:!1});break;case 422:this._toastService.show(this._i18nService.translate("shared.notification.fail")),this._dialogRef.close({success:!1});break;default:this._dialogRef.close({success:!1})}}))&&(this._toastService.show(this._i18nService.translate("shared.notification.success")),this._dialogRef.close({success:!0}))}),this._ctrl=new a.j(e=>e.children),this._tree=new d.d,this._selection=new s.c(!0),this._httpService.get(`roles/${this._id}/menu`).then(e=>{var t,i;if(null===(t=e.menu.children)||void 0===t?void 0:t.length){const t=[...e.menu.children];for(;t.length;){const e=t.pop();(null===(i=e.children)||void 0===i?void 0:i.length)&&(e.children.forEach(t=>t.parent=e),t.push(...e.children))}}this._selection.select(...e.permission),this._tree.data=e.menu.children;for(let r of this._tree.data)this._ctrl.expandDescendants(r);this._loading=!1})}get loading(){return this._loading}get ctrl(){return this._ctrl}get tree(){return this._tree}get selection(){return this._selection}}return e.\u0275fac=function(t){return new(t||e)(h.Ob(l.a),h.Ob(u.a),h.Ob(p.a),h.Ob(f.a),h.Ob(l.g))},e.\u0275cmp=h.Ib({type:e,selectors:[["app-basic-rol
|