import{_ as f,ax as y,M as b,c as w,a as o,w as r,Z as _,ay as v,R as $,H as R,r as S,o as g,$ as h,K as p,aj as k,N as c,a1 as C,Q as L}from"./app-DzAYC6xy.js";import{Q as q,a as m}from"./QTable-98FMMxUQ.js";import{Q as B}from"./QTr-BZRxhYsi.js";import"./externalHosting.js";import"./QList-ClLOsgaS.js";import"./QMarkupTable-z27wCkH-.js";import"./QSelect-CKpWbBmC.js";import"./QChip-BlQVc6fr.js";import"./QItemLabel-DrLwH6Mx.js";import"./position-engine-BoHh6ymb.js";import"./selection-vu7NfHfB.js";import"./rtl-DFPa-2ov.js";import"./use-fullscreen-Bv2HJD5x.js";const Q={name:"StashesList",data(){return{ACTION:R,RESOURCE:$,columns:[{name:"type",align:"left",label:this.$i18n.t("components.stashesList.headers.type"),field:t=>t.type,format:t=>`${t}`,sortable:!0},{name:"identifier",align:"left",label:this.$i18n.t("components.stashesList.headers.identifier"),field:t=>t.identifier,format:t=>`${t}`,sortable:!0},{name:"item_count",align:"center",label:this.$i18n.t("components.stashesList.headers.items"),field:t=>t.item_count,format:t=>`${t}`,sortable:!0}],stashes:[],pagination:{sortBy:"type",descending:!1,page:1,rowsPerPage:0},loading:!0}},methods:{getRowsNumberCount(t){return this.$axios.post("/api/stashes/stashes-count",{filter:t}).then(s=>s.data.count)},fetchFromServer(t,s,a,l,i){return this.$axios.post("/api/stashes",{startRow:t,count:s,filter:a,sortBy:l,descending:i}).then(n=>n.data.stashes).catch(()=>{this.loading=!1,this.$q.notify({message:this.$i18n.t("general.error"),position:"top",color:"red",icon:"fas fa-exclamation-triangle",caption:this.$i18n.t("general.timeout")})})},async onRequest(t){const{page:s,rowsPerPage:a,sortBy:l,descending:i}=t.pagination,n=t.filter;this.loading=!0,this.pagination.rowsNumber=await this.getRowsNumberCount(n);const d=a===0?this.pagination.rowsNumber:a,e=a===0?0:(s-1)*a,u=await this.fetchFromServer(e,d,n,l,i);this.stashes.splice(0,this.stashes.length,...u),this.pagination.page=s,this.pagination.rowsPerPage=a,this.pagination.sortBy=l,this.pagination.descending=i,this.paginationSave=this.pagination,this.loading=!1},onRowClick(t){this.$router.push({name:"game-stashes-detail",params:{stashId:t.identifier},query:{type:t.type}})},getPaginationLabel(t,s,a){return this.$i18n.t("components.stashesList.paginationLabel",{from:t,to:s,total:a})},updatePagination(t){this.loading||(this.paginationSave=t,this.pagination=t)}},computed:{...y(v,["searchFilter","paginationSave"])},mounted(){this.$route.name==="game-stashes-list"&&(this.pagination={...this.paginationSave,sortBy:this.pagination.sortBy},this.$refs.tableRef.requestServerInteraction())}},N={key:0,class:"row q-pa-sm"},P={class:"row"},x={class:"col-12"},F={class:"q-mx-md q-my-sm row"},I={class:"text-caption text-sub"};function V(t,s,a,l,i,n){const d=S("router-view");return t.$route.name==="game-stashes-list"?(g(),b("div",N,[o(_,{class:"stashes-list-card full-width"},{default:r(()=>[h("div",P,[h("div",x,[h("div",F,[h("div",I,p(t.$t("components.stashesList.subheader")),1)]),o(k),o(q,{ref:"tableRef",color:"primary","card-class":"stashes-list-card text-main","table-class":"stashes-list-table","table-header-class":"stashes-list-table-header text-main",flat:"",style:{"max-height":"70vh"},rows:i.stashes,columns:i.columns,"row-key":"name",pagination:i.pagination,"onUpdate:pagination":[s[1]||(s[1]=e=>i.pagination=e),n.updatePagination],"no-results-label":t.$t("components.stashesList.noData"),"loading-label":t.$t("components.stashesList.loadData"),loading:i.loading,filter:t.searchFilter,"binary-state-sort":"",onRequest:n.onRequest},{"top-right":r(()=>[o(C,{"input-style":{color:"var(--q-main)"},borderless:"",dense:"",debounce:"300",modelValue:t.searchFilter,"onUpdate:modelValue":s[0]||(s[0]=e=>t.searchFilter=e),placeholder:t.$t("general.search")},{append:r(()=>[o(L,{class:"text-white search-icon",name:"search"})]),_:1},8,["modelValue","placeholder"])]),body:r(e=>[o(B,{props:e,onClick:u=>n.onRowClick(e.row),class:"cursor-pointer"},{default:r(()=>[o(m,{key:"type",props:e},{default:r(()=>[c(p(e.row.type),1)]),_:2},1032,["props"]),o(m,{key:"identifier",props:e},{default:r(()=>[c(p(e.row.identifier),1)]),_:2},1032,["props"]),o(m,{key:"item_count",props:e},{default:r(()=>[c(p(e.row.item_count),1)]),_:2},1032,["props"])]),_:2},1032,["props","onClick"])]),_:1},8,["rows","columns","pagination","no-results-label","loading-label","loading","filter","onRequest","onUpdate:pagination"])])])]),_:1})])):(g(),w(d,{key:1}))}const G=f(Q,[["render",V],["__scopeId","data-v-4ad10ad8"]]);export{G as default};
