import{a as he,b as de,c as _e,d as fe}from"./chunk-UIND2QOD.js";import{a as le}from"./chunk-VKGUPMBV.js";import{a as H}from"./chunk-WJQYXGPC.js";import{a as G}from"./chunk-P7KQ7LX4.js";import{a as q}from"./chunk-MMKOWPWI.js";import"./chunk-EGRHWZRV.js";import{a as Q}from"./chunk-VBM2RR4H.js";import{a as pe}from"./chunk-QYMDN3S2.js";import"./chunk-Z6SX4HYB.js";import"./chunk-5T6TZLDM.js";import"./chunk-ZVQ5RRLK.js";import"./chunk-FZR6ITPM.js";import{b as N,e as V,f as j}from"./chunk-BNNGG6ED.js";import{Ba as O,Wa as se,ma as P,ya as ae}from"./chunk-CQ74FR7E.js";import{a as z,b as T}from"./chunk-KXDO3JYP.js";import{a as S}from"./chunk-FGTTUT4L.js";import{d as me}from"./chunk-MDTKDCI6.js";import"./chunk-4CXDVP3F.js";import"./chunk-5JFE5MLS.js";import{p as $}from"./chunk-GD42XZQD.js";import"./chunk-ZNYLCQSJ.js";import"./chunk-YIGUHH4B.js";import"./chunk-CC7H2Q52.js";import"./chunk-LUCOJAXQ.js";import"./chunk-FWAWZDGH.js";import"./chunk-IHFPHQ5N.js";import"./chunk-RTKDH4JU.js";import"./chunk-IFY4UZPR.js";import"./chunk-Y4KZVCMP.js";import"./chunk-UU4K5RCK.js";import"./chunk-FKH5Y42R.js";import{a as ce}from"./chunk-F24KRXZV.js";import{p as ue}from"./chunk-JBWPPKX4.js";import"./chunk-7N232KV6.js";import"./chunk-PDYJ5OYY.js";import{s as ne,u as R,v as re}from"./chunk-NDLDFKR2.js";import{$c as c,Ca as F,Cb as M,Dc as b,Ec as B,Fc as te,Hb as d,K,Sc as ie,Ue as L,ad as m,bc as r,cc as s,dc as u,ec as k,ed as y,kb as a,la as _,lc as I,nc as C,pc as l,sd as U,ta as v,tc as X,ua as g,uc as Z,vb as f,vc as ee,we as oe,yc as w}from"./chunk-PVUKHE45.js";import"./chunk-AKP2VPKK.js";import"./chunk-GVXHDKBW.js";import{d as x,n as Y}from"./chunk-VD6R3735.js";import{a as J}from"./chunk-MZPAXKJS.js";Y();function ve(i){return[{dataField:"name",caption:i("\u0421\u043A\u043B\u0430\u0434")},{dataField:"address",caption:i("\u0410\u0434\u0440\u0435\u0441"),width:"40%"},{dataField:"custom",caption:i("\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"],we=i=>({custom:i});function be(i,t){if(i&1&&(k(0,"wk-button",9),c(1,"translate")),i&2){let e=l(2);r("icon",e.icons.Plus)("label",m(1,2,"\u041D\u043E\u0432\u044B\u0439 \u0441\u043A\u043B\u0430\u0434"))}}function ye(i,t){if(i&1&&d(0,be,2,4,"wk-button",8),i&2){let e=l();r("ngIf",e.canCreateWarehouse)}}function Se(i,t){if(i&1){let e=I();s(0,"wk-button",18),c(1,"translate"),C("clicked",function(){v(e);let n=l(2);return g(n.editWarehouse(n.mainWarehouse))}),u()}if(i&2){let e=l(2);r("icon",e.icons.Edit)("label",m(1,2,"\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C"))}}function We(i,t){if(i&1&&(s(0,"wk-card",10)(1,"div",11)(2,"div")(3,"div",12),b(4),c(5,"translate"),u(),s(6,"div",13),b(7),u()()(),s(8,"div",14)(9,"div",15),k(10,"wk-badge",16)(11,"wk-badge",16),u(),d(12,Se,2,4,"wk-button",17),u()()),i&2){let e=l();a(4),B(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),B(e.mainWarehouse.name),a(3),r("icon",e.icons.Location)("text",e.mainWarehouse.address)("tooltipPosition","bottom"),a(),r("icon",e.icons.Store)("text",e.getStoreCount(e.mainWarehouse.stores.length))("tooltipPosition","bottom"),a(),r("ngIf",e.canEditWarehouse)}}function Ee(i,t){i&1&&(s(0,"div",19),b(1),c(2,"translate"),u()),i&2&&(a(),B(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 xe(i,t){i&1&&(s(0,"div",19),b(1),c(2,"translate"),u()),i&2&&(a(),B(m(2,1,"\u0421\u043F\u0438\u0441\u043E\u043A \u0441\u043A\u043B\u0430\u0434\u043E\u0432")))}function ke(i,t){if(i&1&&b(0),i&2){let e=t.$implicit,o=l();te(" ",o.getStoreCount(e.stores.length),`
`)}}var p,D=(p=class{constructor(){this._localizationService=_(V),this._router=_(R),this._cdr=_(U),this._permissionService=_(me),this._warehouseService=_(Q),this.warehouses$=_(ue).select($.warehouses),this.icons=j,this.columns=ve(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:t=>this.editWarehouse(t)}]}ngOnInit(){this._initWarehouses(),this.canCreateWarehouse=this._permissionService.hasPermissions(S.CreateWarehouse),this.canEditWarehouse=this._permissionService.hasPermissions(S.EditWarehouse)}editWarehouse(t){t?.id&&this._router.navigate(["/cabinet/company/warehouses/edit"],{queryParams:{id:t.id},state:{name:t.name,address:t.address}})}getStoreCount(t){return`${this._localizationService.getSync("\u0422\u043E\u0440\u0433\u043E\u0432\u044B\u0445 \u0442\u043E\u0447\u0435\u043A")}: ${t}`}_initWarehouses(){this.table?.dataGrid.instance.beginCustomLoading(""),this._warehouseService.getWarehouseAll().pipe(T(this)).subscribe(t=>{this.mainWarehouse=t.find(e=>e.id===this.mainWarehouseId)??null,this.otherWarehouses=t.filter(e=>e.id!==this.mainWarehouseId),this.table?.dataGrid.instance.endCustomLoading(),this._cdr.detectChanges()})}},p.\u0275fac=function(e){return new(e||p)},p.\u0275cmp=M({type:p,selectors:[["tis-warehouse-list"]],viewQuery:function(e,o){if(e&1&&X(Ce,5),e&2){let n;Z(n=ee())&&(o.table=n.first)}},decls:13,vars:17,consts:[["headerTmpl",""],["table",""],["allWarehouse",""],["customColumn",""],[1,"header",3,"showBackButton","actionTemplate","title"],["stylingMode","outline",4,"ngIf"],["class","font-st2",4,"ngIf","ngIfElse"],[3,"allowColumnResizing","data","columns","menuItems","enableSpinner","enableContextMenu","customTemplates"],["routerLink","/cabinet/company/warehouses/create","token","create-warehouse",3,"icon","label",4,"ngIf"],["routerLink","/cabinet/company/warehouses/create","token","create-warehouse",3,"icon","label"],["stylingMode","outline"],[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","clicked",4,"ngIf"],["stylingMode","outlined","variant","secondary",3,"clicked","icon","label"],[1,"font-st2"]],template:function(e,o){if(e&1&&(k(0,"tis-subheader",4),c(1,"translate"),d(2,ye,1,1,"ng-template",null,0,y),s(4,"tis-main-layout"),d(5,We,13,11,"wk-card",5)(6,Ee,3,3,"div",6),k(7,"tis-table",7,1),u(),d(9,xe,3,3,"ng-template",null,2,y)(11,ke,1,1,"ng-template",null,3,y)),e&2){let n=w(3),W=w(10),E=w(12);r("showBackButton",!1)("actionTemplate",n)("title",m(1,13,"\u0421\u043A\u043B\u0430\u0434\u044B")),a(5),r("ngIf",o.mainWarehouse),a(),r("ngIf",o.mainWarehouse)("ngIfElse",W),a(),r("allowColumnResizing",!0)("data",o.otherWarehouses)("columns",o.columns)("menuItems",o.tableItems)("enableSpinner",!0)("enableContextMenu",o.canEditWarehouse)("customTemplates",ie(15,we,E))}},dependencies:[L,oe,ae,P,O,G,re,H,pe,N],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-l);justify-content:space-between;margin-bottom:var(--space-vertical-l)}.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-l)}.active-warehouse-badges[_ngcontent-%COMP%]{display:flex;gap:var(--space-horizontal-l)}
/*# sourceMappingURL=warehouse-list.component-QUCH4D66.css.map */`],changeDetection:0}),p);x([ce($.mainWarehouseId)],D.prototype,"mainWarehouseId",void 0);D=x([z()],D);Y();function Ie(i,t){if(i&1){let e=I();s(0,"wk-button",5),c(1,"translate"),C("clicked",function(){v(e);let n=l();return g(n.submit())}),u()}if(i&2){let e=l();r("icon",e.icons.Save)("label",m(1,2,"\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C"))}}var h,A=(h=class{constructor(t,e,o,n,W,E){this._cdr=t,this._router=e,this._route=o,this._warehouseService=n,this._toastService=W,this._localizationService=E,this.icons=j,this.warehouseId=F(null),this.warehouseName=F(null),this.warehouseAddress=F(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(t){this.warehouseUpsertForm=t,this._updateForm()}submit(){if(this.warehouseUpsertForm.markAllAsTouched(),this._cdr.detectChanges(),this.warehouseUpsertForm.valid){let t=J({},this.warehouseUpsertForm.value);if(this.isEditForm){this._editWarehouse(t);return}this._createWarehouse(t)}}back(){this._router.navigate(["cabinet/company/warehouses"])}_checkWarehouseId(){this._route.queryParams.pipe(K(1)).subscribe(t=>{this.warehouseId.set(t.id),this.isEditForm=!!this.warehouseId(),this.isEditForm||this._router.navigate(["/cabinet/company/warehouses/create"]),this.warehouseId()&&!this.warehouseName()&&!this.warehouseAddress()&&(this._toastService.add(fe(this._localizationService.getSync.bind(this._localizationService))),this.back())})}_updateForm(){this.warehouseUpsertForm.patchValue({name:this.warehouseName()??"",address:this.warehouseAddress()??""})}_createWarehouse(t){this._warehouseService.createWarehouse(t).pipe(T(this)).subscribe(()=>{this._toastService.add(de(this._localizationService.getSync.bind(this._localizationService))),this._router.navigate(["/cabinet/company/warehouses"])})}_editWarehouse(t){let e=this.warehouseId();e&&this._warehouseService.editWarehouse(t,e).pipe(T(this)).subscribe(()=>{this._toastService.add(_e(this._localizationService.getSync.bind(this._localizationService))),this._router.navigate(["/cabinet/company/warehouses"])})}},h.\u0275fac=function(e){return new(e||h)(f(U),f(R),f(ne),f(Q),f(se),f(V))},h.\u0275cmp=M({type:h,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(e,o){if(e&1){let n=I();s(0,"tis-subheader",1),c(1,"translate"),c(2,"translate"),C("backButtonClicked",function(){return v(n),g(o.back())}),u(),d(3,Ie,2,4,"ng-template",null,0,y),s(5,"tis-main-layout",2)(6,"wk-card",3),c(7,"translate"),s(8,"tis-warehouse-upsert-form",4),C("formReady",function(E){return v(n),g(o.initForm(E))}),u()()()}if(e&2){let n=w(4);r("actionTemplate",n)("title",o.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),r("header",m(7,9,"\u0414\u0430\u043D\u043D\u044B\u0435 \u043E \u0441\u043A\u043B\u0430\u0434\u0435")),a(2),r("initialValue",o.initialFormValue)("isEdit",o.isEditForm)}},dependencies:[L,P,O,he,G,H,le,N],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}),h);A=x([z()],A);var Et=[{path:"",component:D,pathMatch:"full"},{path:"create",component:A,canActivate:[q],data:{permissions:[S.CreateWarehouse]}},{path:"edit",component:A,canActivate:[q],data:{permissions:[S.EditWarehouse]}},{path:"**",redirectTo:""}];export{Et as routes};
//# sourceMappingURL=warehouse.routes-UXLNAFKM.js.map
