import{a as me,b as le,c as pe,d as de}from"./chunk-6DMXK2ZU.js";import{a as N}from"./chunk-F5MI6XGL.js";import{a as V}from"./chunk-2JBQM4A4.js";import{d as ce}from"./chunk-7PKMSCVL.js";import"./chunk-WL2OYEJL.js";import{a as H}from"./chunk-ZQ3VCLAZ.js";import{a as ue}from"./chunk-TJNL4KWR.js";import{a as O}from"./chunk-RVEFR64E.js";import"./chunk-5QUMV2KP.js";import"./chunk-EGRHWZRV.js";import"./chunk-KGCVL6CP.js";import"./chunk-UBQPCB4A.js";import"./chunk-LBZE4AC4.js";import"./chunk-RTVR37QC.js";import"./chunk-ZATDFETU.js";import{I as L,La as z,Ma as P}from"./chunk-QHAVDXDG.js";import{K as U,S as oe,V as M,na as ne}from"./chunk-27KSTDMK.js";import{a as C}from"./chunk-FGTTUT4L.js";import{d as se}from"./chunk-OC7PGGXC.js";import"./chunk-PSDBNMO6.js";import"./chunk-V4WCDZSD.js";import{p as G}from"./chunk-3WWEFG5Z.js";import"./chunk-ZQPWXQD7.js";import"./chunk-NRBWRRAF.js";import"./chunk-NA4DKUZO.js";import"./chunk-OCLYE42A.js";import"./chunk-7E4GTVCE.js";import{a as re}from"./chunk-HEWBVLHR.js";import"./chunk-N3BL5TXR.js";import"./chunk-RTL4XZI4.js";import"./chunk-QGNMEQRN.js";import"./chunk-F4GTCTBH.js";import"./chunk-WXQVX7WD.js";import{m as ae}from"./chunk-OWZ5YAMH.js";import"./chunk-KXX3UDJ3.js";import"./chunk-PDYJ5OYY.js";import{s as te,u as R,v as ie,z as E}from"./chunk-GQAU5ACB.js";import{Ac as Z,Bb as h,Bc as K,Ea as I,Ec as S,Ib as A,Jc as f,Ka as T,Kc as y,Lc as X,Nb as v,S as J,Yc as ee,ac as g,cc as w,fd as c,gd as m,hc as u,ic as r,jc as s,k as q,kc as b,kd as W,qa as l,rc as D,sb as a,tc as _,vc as p,ya as k,yd as F,za as B,zc as Y}from"./chunk-ISMRT7VU.js";import"./chunk-GMHSUEGX.js";import{a as $}from"./chunk-M5TX2NVG.js";function he(t){return[{dataField:"name",caption:t("\u0421\u043A\u043B\u0430\u0434")},{dataField:"address",caption:t("\u0410\u0434\u0440\u0435\u0441"),width:"40%"},{dataField:"custom",caption:t("\u0414\u043E\u0441\u0442\u0443\u043F\u0435\u043D \u0434\u043B\u044F \u0442\u043E\u0440\u0433\u043E\u0432\u044B\u0445 \u0442\u043E\u0447\u0435\u043A"),width:"25%",isCustom:!0}]}var Ce=["table"],ve=t=>({custom:t});function ge(t,i){if(t&1&&(b(0,"wk-button",7),c(1,"translate")),t&2){let e=p(2);u("icon",e.icons.Plus)("label",m(1,2,"\u041D\u043E\u0432\u044B\u0439 \u0441\u043A\u043B\u0430\u0434"))}}function we(t,i){if(t&1&&g(0,ge,2,4,"wk-button",7),t&2){let e=p();w(e.canCreateWarehouse?0:-1)}}function be(t,i){if(t&1){let e=D();r(0,"wk-button",15),c(1,"translate"),_("clicked",function(){k(e);let n=p(2);return B(n.editWarehouse(n.mainWarehouse))}),s()}if(t&2){let e=p(2);u("icon",e.icons.Edit)("label",m(1,2,"\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C"))}}function Se(t,i){if(t&1&&(r(0,"wk-card",4)(1,"div",8)(2,"div")(3,"div",9),f(4),c(5,"translate"),s(),r(6,"div",10),f(7),s()()(),r(8,"div",11)(9,"div",12),b(10,"wk-badge",13)(11,"wk-badge",13),s(),g(12,be,2,4,"wk-button",14),s()()),t&2){let e=p();a(4),y(m(5,9,"\u041E\u0441\u043D\u043E\u0432\u043D\u043E\u0439 \u0441\u043A\u043B\u0430\u0434 \u0442\u0435\u043A\u0443\u0449\u0435\u0439 \u0442\u043E\u0440\u0433\u043E\u0432\u043E\u0439 \u0442\u043E\u0447\u043A\u0438")),a(3),y(e.mainWarehouse.name),a(3),u("icon",e.icons.Location)("text",e.mainWarehouse.address)("tooltipPosition","bottom"),a(),u("icon",e.icons.Store)("text",e.getStoreCount(e.mainWarehouse.stores.length))("tooltipPosition","bottom"),a(),w(e.canEditWarehouse?12:-1)}}function ye(t,i){t&1&&(r(0,"div",5),f(1),c(2,"translate"),s()),t&2&&(a(),y(m(2,1,"\u0421\u043F\u0438\u0441\u043E\u043A \u043E\u0441\u0442\u0430\u043B\u044C\u043D\u044B\u0445 \u0441\u043A\u043B\u0430\u0434\u043E\u0432")))}function We(t,i){t&1&&(r(0,"div",5),f(1),c(2,"translate"),s()),t&2&&(a(),y(m(2,1,"\u0421\u043F\u0438\u0441\u043E\u043A \u0441\u043A\u043B\u0430\u0434\u043E\u0432")))}function Ee(t,i){if(t&1&&f(0),t&2){let e=i.$implicit,o=p();X(" ",o.getStoreCount(e.stores.length),`
`)}}var x=class t{constructor(){this._localizationService=l(z),this._router=l(R),this._cdr=l(F),this._permissionService=l(se),this._warehouseService=l(V),this.destroyRef=l(I),this.warehouses$=l(ae).select(G.warehouses),this.icons=P,this.columns=he(this._localizationService.getSync.bind(this._localizationService)),this.mainWarehouse=null,this.otherWarehouses=[],this.tableItems=[{text:this._localizationService.getSync("\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C"),visible:()=>this.canEditWarehouse,action:i=>this.editWarehouse(i)}]}ngOnInit(){this._initWarehouses(),this.canCreateWarehouse=this._permissionService.hasPermissions(C.CreateWarehouse),this.canEditWarehouse=this._permissionService.hasPermissions(C.EditWarehouse)}editWarehouse(i){i?.id&&this._router.navigate(["/cabinet/company/warehouses/edit"],{queryParams:{id:i.id},state:{name:i.name,address:i.address}})}getStoreCount(i){return`${this._localizationService.getSync("\u0422\u043E\u0440\u0433\u043E\u0432\u044B\u0445 \u0442\u043E\u0447\u0435\u043A")}: ${i}`}_initWarehouses(){this.table?.dataGrid.instance.beginCustomLoading(""),this._warehouseService.getWarehouseAll().pipe(E(this.destroyRef)).subscribe(i=>{this.mainWarehouse=i.find(e=>e.id===this.mainWarehouseId)??null,this.otherWarehouses=i.filter(e=>e.id!==this.mainWarehouseId),this.table?.dataGrid.instance.endCustomLoading(),this._cdr.detectChanges()})}static{this.\u0275fac=function(e){return new(e||t)}}static{this.\u0275cmp=A({type:t,selectors:[["tis-warehouse-list"]],viewQuery:function(e,o){if(e&1&&Y(Ce,5),e&2){let n;Z(n=K())&&(o.table=n.first)}},decls:12,vars:16,consts:[["headerTmpl",""],["table",""],["customColumn",""],[1,"header",3,"showBackButton","actionTemplate","title"],["stylingMode","outline"],[1,"font-st2"],[3,"allowColumnResizing","data","columns","menuItems","enableSpinner","enableContextMenu","customTemplates"],["routerLink","/cabinet/company/warehouses/create","token","create-warehouse",3,"icon","label"],[1,"active-warehouse-header"],[1,"font-b1-secondary"],[1,"font-st1","warehouse-name"],[1,"active-warehouse-info"],[1,"active-warehouse-badges"],["size","large","variant","secondary",3,"icon","text","tooltipPosition"],["stylingMode","outlined","variant","secondary",3,"icon","label"],["stylingMode","outlined","variant","secondary",3,"clicked","icon","label"]],template:function(e,o){if(e&1&&(b(0,"tis-subheader",3),c(1,"translate"),v(2,we,1,1,"ng-template",null,0,W),r(4,"tis-main-layout"),g(5,Se,13,11,"wk-card",4),g(6,ye,3,3,"div",5)(7,We,3,3,"div",5),b(8,"tis-table",6,1),s(),v(10,Ee,1,1,"ng-template",null,2,W)),e&2){let n=S(3),d=S(11);u("showBackButton",!1)("actionTemplate",n)("title",m(1,12,"\u0421\u043A\u043B\u0430\u0434\u044B")),a(5),w(o.mainWarehouse?5:-1),a(),w(o.mainWarehouse?6:7),a(2),u("allowColumnResizing",!0)("data",o.otherWarehouses)("columns",o.columns)("menuItems",o.tableItems)("enableSpinner",!0)("enableContextMenu",o.canEditWarehouse)("customTemplates",ee(14,ve,d))}},dependencies:[oe,U,M,O,ie,N,ce,L],styles:[`[_nghost-%COMP%]{display:flex;flex-direction:column;min-height:100%}.header[_ngcontent-%COMP%]{top:0;position:sticky;z-index:10}.active-warehouse-header[_ngcontent-%COMP%]{display:flex;gap:var(--space-horizontal-16);justify-content:space-between;margin-bottom:var(--space-vertical-16)}.warehouse-name[_ngcontent-%COMP%]{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;overflow:hidden;text-overflow:ellipsis;word-break:break-word;text-decoration:none}.active-warehouse-info[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center;gap:var(--space-horizontal-16)}.active-warehouse-badges[_ngcontent-%COMP%]{display:flex;gap:var(--space-horizontal-16)}
/*# sourceMappingURL=warehouse-list.component-Z7V6S4VN.css.map */`],changeDetection:0})}};q([re(G.mainWarehouseId)],x.prototype,"mainWarehouseId",void 0);function xe(t,i){if(t&1){let e=D();r(0,"wk-button",5),c(1,"translate"),_("clicked",function(){k(e);let n=p();return B(n.submit())}),s()}if(t&2){let e=p();u("icon",e.icons.Save)("label",m(1,2,"\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C"))}}var Q=(()=>{class t{constructor(e,o,n,d,j,_e){this._cdr=e,this._router=o,this._route=n,this._warehouseService=d,this._toastService=j,this._localizationService=_e,this.destroyRef=l(I),this.icons=P,this.warehouseId=T(null),this.warehouseName=T(null),this.warehouseAddress=T(null),this.isEditForm=!1,this.warehouseAddress.set(this._router.getCurrentNavigation()?.extras.state?.address??null),this.warehouseName.set(this._router.getCurrentNavigation()?.extras.state?.name??null)}ngOnInit(){this._checkWarehouseId()}initForm(e){this.warehouseUpsertForm=e,this._updateForm()}submit(){if(this.warehouseUpsertForm.markAllAsTouched(),this._cdr.detectChanges(),this.warehouseUpsertForm.valid){let e=$({},this.warehouseUpsertForm.value);if(this.isEditForm){this._editWarehouse(e);return}this._createWarehouse(e)}}back(){this._router.navigate(["cabinet/company/warehouses"])}_checkWarehouseId(){this._route.queryParams.pipe(J(1)).subscribe(e=>{this.warehouseId.set(e.id),this.isEditForm=!!this.warehouseId(),this.isEditForm||this._router.navigate(["/cabinet/company/warehouses/create"]),this.warehouseId()&&!this.warehouseName()&&!this.warehouseAddress()&&(this._toastService.add(de(this._localizationService.getSync.bind(this._localizationService))),this.back())})}_updateForm(){this.warehouseUpsertForm.patchValue({name:this.warehouseName()??"",address:this.warehouseAddress()??""})}_createWarehouse(e){this._warehouseService.createWarehouse(e).pipe(E(this.destroyRef)).subscribe(()=>{this._toastService.add(le(this._localizationService.getSync.bind(this._localizationService))),this._router.navigate(["/cabinet/company/warehouses"])})}_editWarehouse(e){let o=this.warehouseId();o&&this._warehouseService.editWarehouse(e,o).pipe(E(this.destroyRef)).subscribe(()=>{this._toastService.add(pe(this._localizationService.getSync.bind(this._localizationService))),this._router.navigate(["/cabinet/company/warehouses"])})}static{this.\u0275fac=function(o){return new(o||t)(h(F),h(R),h(te),h(V),h(ne),h(z))}}static{this.\u0275cmp=A({type:t,selectors:[["tis-warehouse-upsert"]],decls:9,vars:11,consts:[["headerTmpl",""],[1,"header",3,"backButtonClicked","actionTemplate","title"],["background","secondary"],["tisColumns","1/6",3,"header"],[3,"formReady","initialValue","isEdit"],["token","submit","variant","success",3,"clicked","icon","label"]],template:function(o,n){if(o&1&&(r(0,"tis-subheader",1),c(1,"translate"),c(2,"translate"),_("backButtonClicked",function(){return n.back()}),s(),v(3,xe,2,4,"ng-template",null,0,W),r(5,"tis-main-layout",2)(6,"wk-card",3),c(7,"translate"),r(8,"tis-warehouse-upsert-form",4),_("formReady",function(j){return n.initForm(j)}),s()()()),o&2){let d=S(4);u("actionTemplate",d)("title",n.isEditForm?m(1,5,"\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435 \u0441\u043A\u043B\u0430\u0434\u0430"):m(2,7,"\u041D\u043E\u0432\u044B\u0439 \u0441\u043A\u043B\u0430\u0434")),a(6),u("header",m(7,9,"\u0414\u0430\u043D\u043D\u044B\u0435 \u043E \u0441\u043A\u043B\u0430\u0434\u0435")),a(2),u("initialValue",n.initialFormValue)("isEdit",n.isEditForm)}},dependencies:[U,M,me,O,N,ue,L],styles:[`[_nghost-%COMP%]{display:flex;flex-direction:column;min-height:100%}.header[_ngcontent-%COMP%]{top:0;position:sticky;z-index:10}
/*# sourceMappingURL=warehouse-upsert.component-CD5GRJDY.css.map */`],changeDetection:0})}}return t})();var gt=[{path:"",component:x,pathMatch:"full"},{path:"create",component:Q,canActivate:[H],data:{permissions:[C.CreateWarehouse]}},{path:"edit",component:Q,canActivate:[H],data:{permissions:[C.EditWarehouse]}},{path:"**",redirectTo:""}];export{gt as routes};
//# sourceMappingURL=warehouse.routes-AF2NRWKR.js.map
