import{d as _}from"./chunk-2MNVXWEX.js";import{Pa as v,a as w}from"./chunk-YFBLRBP4.js";import{a as y,b as s}from"./chunk-VXSBHXCN.js";import{Bb as m,Bc as f,Cc as p,Cd as g,Dc as S,J as u,L as d,g as r,o as l,oa as b,tb as h}from"./chunk-C2QKZJOP.js";import{d as n,n as C}from"./chunk-INB5GR2I.js";import{j as o}from"./chunk-B7YGBANW.js";C();var D=["table"],i,I=(i=class{get criteria(){return this._criteria}get filterData(){return this._filterData}get translate(){return this.localizationService.getSync.bind(this.localizationService)}get filters(){return this._filters}set filters(e){this._filters=e}constructor(e,t){this.cdr=e,this.drawerService=t,this.localizationService=b(_),this.orderBy="id",this.isAscending=!0,this.tableHeight="450px",this.disableDynamicTableHeight=!1,this.filterSubmitted=new r,this.filterCanceled=new r,this._searchSubject=new r,this._warehouseIdSubject=new r,this._accountIdSubject=new r,this._cashboxIdSubject=new r,this._criteria=null}ngOnInit(){this.dataSource=new w({key:"id",cacheRawData:!1,load:e=>o(this,null,function*(){let t=this.getSortDescriptors(e)?.[0],c={criteria:this.criteria??null,skip:e.skip??0,take:e.take??100,orderBy:t?t.selector.toString():this.orderBy,isAscending:t?!t.desc:this.isAscending},a=yield l(this.getLoadMethod(c).pipe(d(1)));return this.table&&!this.disableDynamicTableHeight&&(this.table.dataGrid.height=a.data.length>10?this.tableHeight:"100%",this.cdr.markForCheck()),{data:a.data,totalCount:a.count}})}),this._searchSubject.pipe(u(300),s(this)).subscribe(e=>{this.searchValue=e,this.table.refresh()}),this._warehouseIdSubject.pipe(s(this)).subscribe(e=>{this.warehouseId=e,this.table?.refresh()}),this._accountIdSubject.pipe(s(this)).subscribe(e=>{this.accountId=e,this.table?.refresh()}),this._cashboxIdSubject.pipe(s(this)).subscribe(e=>{this.cashboxId=e,this.table?.refresh()})}openFilters(){let e=this.drawerService.open(this.filterComponent,{data:this.filterData,header:this.localizationService.getSync("\u0424\u0438\u043B\u044C\u0442\u0440\u044B"),submitButton:{label:this.localizationService.getSync("\u041F\u0440\u0438\u043C\u0435\u043D\u0438\u0442\u044C"),variant:"success"},cancelButton:this.localizationService.getSync("\u0421\u0431\u0440\u043E\u0441\u0438\u0442\u044C \u0444\u0438\u043B\u044C\u0442\u0440\u044B")});e.submitted.pipe(s(this)).subscribe(t=>{this.previousFilters=this.filters,this.filters=t,e.close(),this.table.refresh(),this.filterSubmitted.next(t),this.cdr.detectChanges()}),e.canceled.pipe(s(this)).subscribe(()=>{this.previousFilters=this.filters,this.filters=null,this.table.refresh(),this.filterCanceled.next(),this.cdr.detectChanges()})}changedSearch(e){this._searchSubject.next(e)}changedWarehouse(e,t){this._warehouseIdSubject.next(e),t&&t.router.navigate([],{relativeTo:t.route,queryParams:{warehouseId:e},queryParamsHandling:"merge"})}changedAccount(e,t){this._accountIdSubject.next(e),t&&t.router.navigate([],{relativeTo:t.route,queryParams:{accountId:e},queryParamsHandling:"merge"})}changedCashbox(e,t){this._cashboxIdSubject.next(e),t&&t.router.navigate([],{relativeTo:t.route,queryParams:{cashboxId:e},queryParamsHandling:"merge"})}getSortDescriptors(e){return Array.isArray(e.sort)?e.sort:[]}},i.\u0275fac=function(t){return new(t||i)(h(g),h(v))},i.\u0275cmp=m({type:i,selectors:[["tis-base-table-view"]],viewQuery:function(t,c){if(t&1&&f(D,5),t&2){let a;p(a=S())&&(c.table=a.first)}},decls:0,vars:0,template:function(t,c){},encapsulation:2}),i);I=n([y()],I);export{I as a};
//# sourceMappingURL=chunk-JPNJN7BT.js.map
