forked from Simnation/Main
1 line
5.3 KiB
JavaScript
1 line
5.3 KiB
JavaScript
import{_ as f,P as w,R as y,bh as $,o as c,X as V,a,w as o,a6 as k,c as g,bi as C,r as _,a7 as r,U as m,ab as v,V as L,aE as q,a9 as Q,S as U,W as p,aT as h}from"./app-014d9ed9.js";import{Q as E,a as S,b as i}from"./QTable.d759a99d.js";import{Q as I}from"./QBadge.718e7c58.js";import{d as P}from"./utils.9ce591f3.js";import"./externalHosting.js";import"./QList.9d5bb77f.js";import"./QMarkupTable.ba6854cc.js";import"./QSelect.d7ce3d4c.js";import"./QItemLabel.b6dd3adb.js";import"./position-engine.65ebcb34.js";import"./selection.2a17b691.js";import"./rtl.b51694b1.js";const T={name:"ItemList",data(){return{ACTION:w,RESOURCE:y,columns:[{name:"label",align:"left",label:this.$i18n.t("components.itemList.headers.label"),field:e=>e.label,format:e=>`${e}`,sortable:!0},{name:"type",align:"center",label:this.$i18n.t("components.itemList.headers.type"),field:e=>e.type,format:e=>`${e}`,sortable:!0},{name:"weight",align:"center",label:this.$i18n.t("components.itemList.headers.weight"),field:e=>e.weight,format:e=>`${e}`,sortable:!0},{name:"name",required:!0,label:this.$i18n.t("components.itemList.headers.name"),align:"left",field:e=>e.name,format:e=>`${e}`,sortable:!0},{name:"useable",align:"center",label:this.$i18n.t("components.itemList.headers.useable"),field:e=>e.useable,format:e=>`${e}`,sortable:!0},{name:"unique",align:"center",label:this.$i18n.t("components.itemList.headers.unique"),field:e=>e.unique,format:e=>`${e}`,sortable:!0},{name:"shouldClose",align:"center",label:this.$i18n.t("components.itemList.headers.shouldClose"),field:e=>e.shouldClose,format:e=>`${e}`,sortable:!0}],items:[],pagination:{sortBy:"desc",descending:!1,page:1,rowsPerPage:25},loading:!0}},methods:{can:P,onRowClick(e){this.$router.push({name:"dev-item-detail",params:{itemId:e.name}})},getPaginationLabel(e,l,d){return this.$i18n.t("components.itemList.paginationLabel",{from:e,to:l,total:d})},updatePagination(e){this.loading||(this.paginationSave=e,this.pagination=e)}},computed:{...$(C,["searchFilter","paginationSave"])},mounted(){this.$route.name==="dev-item-list"&&this.$axios.get("/api/items").then(e=>{for(const[l,d]of Object.entries(e.data.items))this.items.push(d);this.loading=!1,this.pagination={...this.paginationSave}}).catch(e=>{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")})})}},R={key:0,class:"row q-pa-sm"},x={class:"row"},B={class:"col-12"},N={class:"q-mx-md q-my-sm row flex-center"},D={class:"text-caption text-sub"},O={class:"q-ml-auto"};function F(e,l,d,A,s,u){const b=_("router-view");return e.$route.name==="dev-item-list"?(c(),V("div",R,[a(k,{class:"bg-secondary full-width"},{default:o(()=>[r("div",x,[r("div",B,[r("div",N,[r("div",D,m(e.$t("components.itemList.subheader")),1),r("div",O,[u.can(s.ACTION.DEV.ITEM.CREATE,s.RESOURCE.DEV)?(c(),g(v,{key:0,"text-color":"main",color:"primary",onClick:l[0]||(l[0]=t=>e.$router.push({name:"dev-item-create"})),label:e.$t("components.itemList.createItem"),class:"q-ma-sm"},null,8,["label"])):L("",!0)])]),a(q),a(E,{color:"primary","card-class":"bg-secondary text-main","table-class":"text-main","table-header-class":"text-primary",flat:"",rows:s.items,columns:s.columns,"row-key":"name",pagination:s.pagination,"rows-per-page-options":[0,25,50,100],"no-results-label":e.$t("components.itemList.noData"),"loading-label":e.$t("components.itemList.loadData"),loading:s.loading,filter:e.searchFilter,"pagination-label":u.getPaginationLabel,"rows-per-page-label":`${e.$t("components.itemList.recordsPerPage")}:`,"onUpdate:pagination":u.updatePagination},{"top-right":o(()=>[a(Q,{"input-style":{color:"var(--q-main)"},borderless:"",dense:"",debounce:"300",modelValue:e.searchFilter,"onUpdate:modelValue":l[1]||(l[1]=t=>e.searchFilter=t),placeholder:e.$t("general.search")},{append:o(()=>[a(U,{class:"text-main",name:"search"})]),_:1},8,["input-style","modelValue","placeholder"])]),body:o(t=>[a(S,{props:t,onClick:n=>u.onRowClick(t.row),class:"cursor-pointer"},{default:o(()=>[a(i,{key:"label",props:t},{default:o(()=>[p(m(t.row.label),1)]),_:2},1032,["props"]),a(i,{key:"type",props:t},{default:o(()=>[a(I,{"text-color":"main",color:t.row.type==="item"?"primary":"negative"},{default:o(()=>[p(m(t.row.type),1)]),_:2},1032,["color"])]),_:2},1032,["props"]),a(i,{key:"weight",props:t},{default:o(()=>[p(m(t.row.weight),1)]),_:2},1032,["props"]),a(i,{key:"name",props:t},{default:o(()=>[p(m(t.row.name),1)]),_:2},1032,["props"]),a(i,{key:"useable",props:t},{default:o(()=>[a(h,{disable:"",modelValue:t.row.useable,"onUpdate:modelValue":n=>t.row.useable=n},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1032,["props"]),a(i,{key:"unique",props:t},{default:o(()=>[a(h,{disable:"",modelValue:t.row.unique,"onUpdate:modelValue":n=>t.row.unique=n},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1032,["props"]),a(i,{key:"shouldClose",props:t},{default:o(()=>[a(h,{disable:"",modelValue:t.row.shouldClose,"onUpdate:modelValue":n=>t.row.shouldClose=n},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1032,["props"])]),_:2},1032,["props","onClick"])]),_:1},8,["rows","columns","pagination","no-results-label","loading-label","loading","filter","pagination-label","rows-per-page-label","onUpdate:pagination"])])])]),_:1})])):(c(),g(b,{key:1}))}const te=f(T,[["render",F]]);export{te as default};
|