import{a as x}from"./chunk-V5CW4EY5.js";import{a as fe}from"./chunk-4I2G26JZ.js";import{a as _e}from"./chunk-GQPCKGXM.js";import{b as De}from"./chunk-F43KEH5M.js";import"./chunk-OR5WJ2OD.js";import{a as be}from"./chunk-TIRGOBBX.js";import"./chunk-7LB63SXX.js";import"./chunk-JAY45DEO.js";import{a as ge}from"./chunk-LJU7P7LF.js";import{t as M}from"./chunk-W3BEWLBM.js";import"./chunk-LINAD4CC.js";import{a as me}from"./chunk-VFX53AYF.js";import{f as de,p as he}from"./chunk-ZVQ5RRLK.js";import{b as Ce}from"./chunk-VWGLVI6E.js";import{e as E}from"./chunk-BOZT4LSN.js";import{B as ie,D as oe,Ha as ne,Ia as ae,Ja as se,Ka as ue,Oa as ce,Ya as le,o as D,q as K,r as W,ra as re,u as Z,w as ee,z as te}from"./chunk-JQUUDIFA.js";import{a as b,b as l}from"./chunk-EK6YV2TW.js";import"./chunk-WUNNKW5D.js";import"./chunk-IFY4UZPR.js";import{o as pe}from"./chunk-GW2OL5S3.js";import"./chunk-P5XIDEFS.js";import"./chunk-PDYJ5OYY.js";import"./chunk-CO3WTSA4.js";import{fa as X,ua as J}from"./chunk-NZ765PUK.js";import{Aa as A,Ac as j,Bb as f,Bc as V,Cc as q,Gb as R,I as P,Wb as w,Wc as Q,Yb as L,bc as c,cc as d,dc as h,ec as p,ed as $,fd as z,jb as m,jd as Y,ka as F,lc as U,rc as N,sa as T,ta as k,tc as C,ub as n,ud as H,xc as B,yc as G,yd as g,zc as O}from"./chunk-DYUFV4HF.js";import"./chunk-AKP2VPKK.js";import"./chunk-ML3VIXIY.js";import{d as _,n as I}from"./chunk-INB5GR2I.js";import"./chunk-B7YGBANW.js";I();I();var a=(function(o){return o[o.Constant=0]="Constant",o[o.Promotional=1]="Promotional",o})(a||{}),Ee={[a.Constant]:"\u041F\u043E\u0441\u0442\u043E\u044F\u043D\u043D\u0430\u044F",[a.Promotional]:"\u0410\u043A\u0446\u0438\u043E\u043D\u043D\u0430\u044F"};var Ie=["datePicker"];function Fe(o,t){if(o&1&&p(0,"wk-date-picker",4,0),o&2){let e=C();c("type","range")("placeholder","\u0434\u0434.\u043C\u043C.\u0433\u0433\u0433\u0433")("endDatePlaceholder","\u0434\u0434.\u043C\u043C.\u0433\u0433\u0433\u0433")("requiredForLabel",!0)("errorMessage",e.errorText())}}var s,y=(s=class{constructor(t,e,i,r){this.data=t,this._dialogRef=e,this._fb=i,this._cdr=r,this.datePicker=H("datePicker"),this.errorText=A(""),this.priceTypeOptions=[{id:a.Constant,name:"\u041F\u043E\u0441\u0442\u043E\u044F\u043D\u043D\u0430\u044F"},{id:a.Promotional,name:"\u0410\u043A\u0446\u0438\u043E\u043D\u043D\u0430\u044F"}],this.priceForm=this._fb.group({name:this._fb.nonNullable.control(this.data?.name??"",[D.required,D.minLength(de.min),D.maxLength(he.max)]),type:this._fb.nonNullable.control({value:this.data?.type??a.Constant,disabled:!!this.data?.id},[me()]),period:this._fb.control({value:this.data?.period??[],disabled:this.data?.type===a.Constant||!this.data?.type},[x.rangeRequired(),x.period()])})}ngOnInit(){this._dialogRef.submitData$$.next(this.priceForm),this._dialogRef.instance?.submitted.pipe(l(this)).subscribe(()=>{this._cdr.markForCheck()}),this.priceForm.controls.type.valueChanges.pipe(l(this)).subscribe(t=>{t===a.Constant?this.priceForm.controls.period.disable():this.priceForm.controls.period.enable()})}},s.\u0275fac=function(e){return new(e||s)(n(se),n(ae),n(ie),n(g))},s.\u0275cmp=f({type:s,selectors:[["tis-upsert-price-dialog"]],viewQuery:function(e,i){e&1&&j(i.datePicker,Ie,5),e&2&&V()},decls:4,vars:5,consts:[["datePicker",""],[1,"form",3,"formGroup"],["label","\u041D\u0430\u0438\u043C\u0435\u043D\u043E\u0432\u0430\u043D\u0438\u0435 \u0446\u0435\u043D\u044B \u043F\u0440\u043E\u0434\u0430\u0436\u0438","formControlName","name","token","name",1,"name"],["label","\u0422\u0438\u043F","formControlName","type","token","type",1,"type",3,"requiredForLabel","options","showClearButton"],["label","\u041F\u0435\u0440\u0438\u043E\u0434","formControlName","period","token","period","helperText","\u0426\u0435\u043D\u0430 \u043F\u0440\u043E\u0434\u0430\u0436\u0438 \u043E\u0442\u043E\u0431\u0440\u0430\u0437\u0438\u0442\u0441\u044F \u0432 \u0440\u0435\u0436\u0438\u043C\u0435 \u043D\u0430 \u0443\u043A\u0430\u0437\u0430\u043D\u043D\u044B\u0439 \u0432\u0430\u043C\u0438 \u043F\u0435\u0440\u0438\u043E\u0434 \u0430\u0432\u0442\u043E\u043C\u0430\u0442\u0438\u0447\u0435\u0441\u043A\u0438",1,"period",3,"type","placeholder","endDatePlaceholder","requiredForLabel","errorMessage"]],template:function(e,i){e&1&&(d(0,"form",1),p(1,"tis-text-field",2)(2,"wk-dropdown",3),w(3,Fe,2,5,"wk-date-picker",4),h()),e&2&&(c("formGroup",i.priceForm),m(2),c("requiredForLabel",!0)("options",i.priceTypeOptions)("showClearButton",!1),m(),L(i.priceForm.controls.type.value?3:-1))},dependencies:[oe,Z,K,W,ee,te,Ce,ce,ne],styles:[`.form[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(6,1fr);gap:var(--space-vertical-l)}.name[_ngcontent-%COMP%]{grid-column:1/5;margin-bottom:0}.type[_ngcontent-%COMP%]{grid-column:5/7;margin-bottom:0}.period[_ngcontent-%COMP%]{grid-column:1/7;margin-bottom:0}
/*# sourceMappingURL=upsert-price-dialog.component-IOXAXJ5G.css.map */`],changeDetection:0}),s);y=_([b()],y);var ye=[{dataField:"name",caption:"\u041D\u0430\u0438\u043C\u0435\u043D\u043E\u0432\u0430\u043D\u0438\u0435"},{dataField:"type",caption:"\u0422\u0438\u043F",customizeText:({value:o})=>Ee[o],width:"25%"},{dataField:"period",caption:"\u041F\u0435\u0440\u0438\u043E\u0434",calculateCellValue:o=>o.from&&o.to?`${M(new Date(o.from),"dd.MM.yyyy")}-${M(new Date(o.to),"dd.MM.yyyy")}`:"-"}],Se={type:"success",header:"\u0426\u0435\u043D\u0430",message:"\u0426\u0435\u043D\u0430 \u0443\u0441\u043F\u0435\u0448\u043D\u043E \u0441\u043E\u0437\u0434\u0430\u043D\u0430"},ve={type:"success",header:"\u0426\u0435\u043D\u0430",message:"\u0426\u0435\u043D\u0430 \u0443\u0441\u043F\u0435\u0448\u043D\u043E \u0441\u043E\u0445\u0440\u0430\u043D\u0435\u043D\u0430"},Pe={type:"success",header:"\u0426\u0435\u043D\u0430",message:"\u0426\u0435\u043D\u0430 \u0443\u0441\u043F\u0435\u0448\u043D\u043E \u0443\u0434\u0430\u043B\u0435\u043D\u0430"};var Te=["table"],ke=()=>[];function Ae(o,t){if(o&1){let e=U();d(0,"wk-button",4),N("clicked",function(){T(e);let r=C();return k(r.openUpsertDialog())}),h()}if(o&2){let e=C();c("icon",e.plusIcon)}}var u,S=(u=class{constructor(t,e,i,r){this._priceService=t,this._dialogService=e,this._toastService=i,this._cdr=r,this.prices$=F(pe).select(be.prices),this.columns=ye,this.plusIcon=E.Plus,this.menuItem=[{text:"\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C",action:v=>this.openUpsertDialog(v)},{text:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C",action:v=>this._openDeleteDialog(v.id)}]}ngAfterViewInit(){this.prices$.pipe(l(this)).subscribe(t=>{this.table&&(this.table.dataGrid.height=t.length>10?"392px":"100%",this._cdr.detectChanges())})}openUpsertDialog(t){let e=this._initUpsertDialog(t);e.canceled.pipe(P(1)).subscribe(()=>e.close()),e.additionalAction.pipe(l(e)).subscribe(()=>{this._deletePrice(e,t?.id)}),e.submitted.pipe(l(e)).subscribe(i=>{if(i.markAllAsTouched(),!i.invalid){if(t){this._editPrice(t.id,i.value,e);return}this._createPrice(i.value,e)}})}_initUpsertDialog(t){return this._dialogService.open(y,{data:{id:t?.id,name:t?.name,type:t?.type,period:t?.from&&t?.to?[new Date(t.from),new Date(t.to)]:[]},header:t?.id?"\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435 \u0446\u0435\u043D\u044B \u043F\u0440\u043E\u0434\u0430\u0436\u0438":"\u041D\u043E\u0432\u0430\u044F \u0446\u0435\u043D\u0430 \u043F\u0440\u043E\u0434\u0430\u0436\u0438",cancelButton:"\u041E\u0442\u043C\u0435\u043D\u0430",submitButton:{label:"\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C",variant:"success",icon:E.Save},additionalButton:t?.id?{variant:"danger",stylingMode:"outlined",label:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C"}:void 0})}_createPrice(t,e){this._priceService.createPrice(t).subscribe(()=>{e.close(),this._toastService.add(Se),this._cdr.detectChanges()})}_editPrice(t,e,i){this._priceService.updatePrice(t,e).subscribe(()=>{i.close(),this._toastService.add(ve),this._cdr.detectChanges()})}_openDeleteDialog(t){let e=this._dialogService.open(null,{header:"\u0423\u0434\u0430\u043B\u0435\u043D\u0438\u0435 \u0446\u0435\u043D\u044B",text:"\u0412\u044B \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u043E \u0445\u043E\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043B\u0438\u0442\u044C \u0446\u0435\u043D\u0443?",submitButton:{label:"\u0414\u0430, \u0443\u0434\u0430\u043B\u0438\u0442\u044C",icon:E.Delete,variant:"success"},cancelButton:"\u041D\u0435\u0442"});e.canceled.pipe(P(1)).subscribe(()=>e.close()),e.submitted.pipe(l(e)).subscribe(()=>{this._deletePrice(e,t)})}_deletePrice(t,e){e&&this._priceService.deletePrice(e).subscribe(()=>{this._toastService.add(Pe),this._cdr.detectChanges(),t.close()})}},u.\u0275fac=function(e){return new(e||u)(n(De),n(ue),n(le),n(g))},u.\u0275cmp=f({type:u,selectors:[["tis-price-list"]],viewQuery:function(e,i){if(e&1&&B(Te,5),e&2){let r;G(r=O())&&(i.table=r.first)}},decls:7,vars:10,consts:[["headerActions",""],["table",""],["title","\u0412\u0438\u0434\u044B \u0446\u0435\u043D",1,"header",3,"showBackButton","actionTemplate"],[3,"allowColumnResizing","columns","data","menuItems","enableContextMenu"],["token","sell-price","label","\u0426\u0435\u043D\u0430 \u043F\u0440\u043E\u0434\u0430\u0436\u0438",3,"clicked","icon"]],template:function(e,i){if(e&1&&(p(0,"tis-subheader",2),R(1,Ae,1,1,"ng-template",null,0,Y),d(3,"tis-main-layout"),p(4,"tis-table",3,1),$(6,"async"),h()),e&2){let r=q(2);c("showBackButton",!1)("actionTemplate",r),m(4),c("allowColumnResizing",!0)("columns",i.columns)("data",z(6,7,i.prices$)??Q(9,ke))("menuItems",i.menuItem)("enableContextMenu",!0)}},dependencies:[fe,_e,re,ge,J,X],styles:[`[_nghost-%COMP%]{display:flex;flex-direction:column;min-height:100%}.header[_ngcontent-%COMP%]{top:0;position:sticky;z-index:10}
/*# sourceMappingURL=price-list.component-QYC6GPAI.css.map */`],changeDetection:0}),u);S=_([b()],S);var bt=[{path:"",component:S,pathMatch:"full"},{path:"**",redirectTo:""}];export{bt as routes};
//# sourceMappingURL=price.routes-ERXKB6GG.js.map
