import{d as _}from"./chunk-JTYOM5WI.js";import{Ta as v,a as w}from"./chunk-JTDXTMDS.js";import{a as y,b as r}from"./chunk-NSGLSIBS.js";import{Ab as m,I as u,K as d,g as i,gd as g,ka as b,p as l,rb as c,uc as f,vc as p,wc as S}from"./chunk-QMYHTLAJ.js";import{d as n,n as I}from"./chunk-HE7HQ6LI.js";import{j as h}from"./chunk-K4ALXBGI.js";I();var D=["table"],C=class o{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 i,this.filterCanceled=new i,this._searchSubject=new i,this._warehouseIdSubject=new i,this._accountIdSubject=new i,this._cashboxIdSubject=new i,this._criteria=null}ngOnInit(){this.dataSource=new w({key:"id",cacheRawData:!1,load:e=>h(this,null,function*(){let t=this.getSortDescriptors(e)?.[0],a={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},s=yield l(this.getLoadMethod(a).pipe(d(1)));return this.table&&!this.disableDynamicTableHeight&&(this.table.dataGrid.height=s.data.length>10?this.tableHeight:"100%",this.cdr.markForCheck()),{data:s.data,totalCount:s.count}})}),this._searchSubject.pipe(u(300),r(this)).subscribe(e=>{this.searchValue=e,this.table.refresh()}),this._warehouseIdSubject.pipe(r(this)).subscribe(e=>{this.warehouseId=e,this.table?.refresh()}),this._accountIdSubject.pipe(r(this)).subscribe(e=>{this.accountId=e,this.table?.refresh()}),this._cashboxIdSubject.pipe(r(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(r(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(r(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:[]}static{this.\u0275fac=function(t){return new(t||o)(c(g),c(v))}}static{this.\u0275cmp=m({type:o,selectors:[["tis-base-table-view"]],viewQuery:function(t,a){if(t&1&&f(D,5),t&2){let s;p(s=S())&&(a.table=s.first)}},decls:0,vars:0,template:function(t,a){},encapsulation:2})}};C=n([y()],C);export{C as a};
