1
0
Fork 0
forked from Simnation/Main
Main/resources/[tools]/unlimited-spectre/html/assets/EditGameItem.ca08f00f.js
2025-06-07 08:51:21 +02:00

1 line
13 KiB
JavaScript

import{x as m,b as x,bD as P,bE as z,F as A,ai as j,H as K,ak as G,q as $,ao as R,h as Y,bB as E,_,o as u,X as h,a7 as i,U as c,V as q,a as n,c as V,w as l,a5 as f,S as w,a8 as S,aP as W,aQ as X,W as k,a9 as g,ab as y,Z as N,Y as Q,aa as F,a6 as H,ac as T}from"./app-014d9ed9.js";import{Q as M}from"./QImg.91aecb73.js";import{e as B}from"./externalHosting.js";import{a as Z,Q as C,c as J}from"./QItemLabel.b6dd3adb.js";import{Q as ee}from"./QSelect.d7ce3d4c.js";import{Q as O}from"./QTooltip.9d840032.js";import{Q as L}from"./QMarkupTable.ba6854cc.js";import{Q as U}from"./QForm.8d79ab03.js";import{B as D}from"./BasicDialog.9dd9de92.js";const te=[m("rect",{x:"0",y:"0",width:" 100",height:"100",fill:"none"}),m("g",{transform:"translate(25 25)"},[m("rect",{x:"-20",y:"-20",width:" 40",height:"40",fill:"currentColor",opacity:"0.9"},[m("animateTransform",{attributeName:"transform",type:"scale",from:"1.5",to:"1",repeatCount:"indefinite",begin:"0s",dur:"1s",calcMode:"spline",keySplines:"0.2 0.8 0.2 0.8",keyTimes:"0;1"})])]),m("g",{transform:"translate(75 25)"},[m("rect",{x:"-20",y:"-20",width:" 40",height:"40",fill:"currentColor",opacity:"0.8"},[m("animateTransform",{attributeName:"transform",type:"scale",from:"1.5",to:"1",repeatCount:"indefinite",begin:"0.1s",dur:"1s",calcMode:"spline",keySplines:"0.2 0.8 0.2 0.8",keyTimes:"0;1"})])]),m("g",{transform:"translate(25 75)"},[m("rect",{x:"-20",y:"-20",width:" 40",height:"40",fill:"currentColor",opacity:"0.7"},[m("animateTransform",{attributeName:"transform",type:"scale",from:"1.5",to:"1",repeatCount:"indefinite",begin:"0.3s",dur:"1s",calcMode:"spline",keySplines:"0.2 0.8 0.2 0.8",keyTimes:"0;1"})])]),m("g",{transform:"translate(75 75)"},[m("rect",{x:"-20",y:"-20",width:" 40",height:"40",fill:"currentColor",opacity:"0.6"},[m("animateTransform",{attributeName:"transform",type:"scale",from:"1.5",to:"1",repeatCount:"indefinite",begin:"0.2s",dur:"1s",calcMode:"spline",keySplines:"0.2 0.8 0.2 0.8",keyTimes:"0;1"})])])],je=x({name:"QSpinnerCube",props:P,setup(e){const{cSize:t,classes:s}=z(e);return()=>m("svg",{class:s.value,width:t.value,height:t.value,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100",preserveAspectRatio:"xMidYMid"},te)}}),Ke=x({name:"QInnerLoading",props:{...A,...j,showing:Boolean,color:String,size:{type:[String,Number],default:42},label:String,labelClass:String,labelStyle:[String,Array,Object]},setup(e,{slots:t}){const s=Y(),p=K(e,s.proxy.$q),{transition:r,transitionStyle:d}=G(e,$(()=>e.showing)),a=$(()=>"q-inner-loading absolute-full column flex-center"+(p.value===!0?" q-inner-loading--dark":"")),b=$(()=>"q-inner-loading__label"+(e.labelClass!==void 0?` ${e.labelClass}`:""));function o(){const I=[m(E,{size:e.size,color:e.color})];return e.label!==void 0&&I.push(m("div",{class:b.value,style:e.labelStyle},[e.label])),I}function v(){return e.showing===!0?m("div",{class:a.value,style:d.value},t.default!==void 0?t.default():o()):null}return()=>m(R,{name:r.value,appear:!0},v)}}),ne={name:"FakeItem",props:{slotNumber:Number}},ie={class:"item"},oe={class:"header q-px-sm q-mb-sm"},le={key:0,class:"slot"},ae=i("div",{class:"info"},null,-1),se=i("div",{class:"icon q-pa-xs"},[i("div",{class:"image"})],-1),re=i("div",{class:"caption q-px-xs"},null,-1);function me(e,t,s,p,r,d){return u(),h("div",ie,[i("div",oe,[s.slotNumber<=5?(u(),h("div",le,c(s.slotNumber),1)):q("",!0),ae]),se,re])}const Ge=_(ne,[["render",me]]),de={name:"Item",props:{item:{},isPlayer:{default:!1}},data(){return{externalHosting:B}}},ce={class:"item"},ue={class:"header q-px-sm q-mb-sm"},fe={key:0,class:"slot"},he={class:"info"},pe={class:"icon q-pa-xs"},ge={class:"caption q-px-xs"};function ye(e,t,s,p,r,d){return u(),h("div",ce,[i("div",ue,[s.item.slot<=5&&s.isPlayer?(u(),h("div",fe,c(s.item.slot),1)):q("",!0),i("div",he,c(s.item.amount)+" ("+c(s.item.amount*s.item.weight/1e3)+") ",1)]),i("div",pe,[n(M,{class:"image",fit:"contain",src:`${r.externalHosting.backend}/public/inventory/icons/${s.item.image}`,"spinner-color":"primary"},null,8,["src"])]),i("div",ge,c(s.item.label),1)])}const Re=_(de,[["render",ye]]),be={name:"AddInventoryItem",data(){return{externalHosting:B,item:{info:{}},items:null,itemAccept:[""],info:[]}},computed:{getItemLabel(){if(!this.items)return"";const e=this.items.find(t=>t.value===this.item.name);return e?e.label:this.item.name}},props:{title:String},emits:["ok","hide"],methods:{isNumeric(e){return typeof e!="string"?!1:!isNaN(e)&&!isNaN(parseFloat(e))},isBoolean(e){return e==="true"||(e==="false"?!1:e)},filterItems(e,t){const s=e==null?void 0:e.toLowerCase();this.itemAccept=Object.freeze(this.items.filter(p=>{var r;return((r=p.label)==null?void 0:r.toLowerCase().indexOf(s))>-1})),t()},addInfo(){this.info.push({name:"",value:""})},removeInfo(e){const t=this.info.indexOf(e);t>-1&&this.$q.dialog({component:D,componentProps:{title:this.$i18n.t("components.inventory.deleteInfoHeader"),message:this.$i18n.t("components.inventory.deleteInfoMsg",{name:e.name})},cancel:!0,persistent:!0}).onOk(()=>{this.info.splice(t,1)})},show(){this.$refs.dialog.show()},hide(){this.$refs.dialog.hide()},onDialogHide(){this.$emit("hide")},onOKClick(){this.$refs.infoForm.validate().then(e=>{if(!e){this.$q.notify({message:this.$i18n.t("general.error"),position:"top",color:"red",icon:"fas fa-exclamation-triangle",caption:this.$i18n.t("components.inventory.msg.error.uniqueInfo")});return}this.info.forEach(t=>{!t.name||(this.item.info[t.name]=this.isNumeric(t.value)?Number(t.value):this.isBoolean(t.value))}),this.$emit("ok",{item:this.item}),this.hide()})},onCancelClick(){this.hide()}},async mounted(){await this.$axios.get("/api/items/item-list").then(e=>{const t=e.data.items;if(!t){this.$q.notify({message:"Error",position:"top",color:"red",icon:"fas fa-exclamation-triangle",caption:this.$i18n.t("components.inventory.msg.error.failedFetchItems")}),this.hide();return}this.items=t}).catch(()=>{this.$q.notify({message:"Error",position:"top",color:"red",icon:"fas fa-exclamation-triangle",caption:this.$i18n.t("components.inventory.msg.error.failedFetchItems")}),this.hide()})}},ve=["innerHTML"],_e={class:"text-main"},$e={class:"row"},ke={class:"text-h6"},Ie={class:"text-caption text-sub"},Ce={class:"row q-mt-sm"},xe={style:{width:"30px"},class:"text-right vertical-middle"};function qe(e,t,s,p,r,d){return u(),V(T,{ref:"dialog",onHide:d.onDialogHide},{default:l(()=>[n(H,{class:"q-dialog-plugin bg-secondary text-main"},{default:l(()=>[n(f,{class:"row"},{default:l(()=>[i("div",{class:"text-body2",innerHTML:s.title},null,8,ve),n(w,{class:"q-ml-auto cursor-pointer",name:"close",onClick:S(d.hide,["stop"])},null,8,["onClick"])]),_:1}),n(f,null,{default:l(()=>[n(ee,{label:e.$t("components.inventory.itemName"),color:"primary","label-color":"primary",filled:"",modelValue:r.item.name,"onUpdate:modelValue":t[0]||(t[0]=a=>r.item.name=a),options:r.itemAccept,"popup-content-class":"bg-secondary text-main","use-input":"","emit-value":"","input-class":"text-main",onFilter:d.filterItems},{selected:l(()=>[i("div",_e,c(d.getItemLabel),1)]),option:l(a=>[n(Z,W(X(a.itemProps)),{default:l(()=>[n(C,{avatar:""},{default:l(()=>[n(M,{src:`${r.externalHosting.backend}/public/inventory/icons/${a.opt.image}`,"spinner-color":"primary",fit:"contain"},null,8,["src"])]),_:2},1024),n(C,null,{default:l(()=>[n(J,{class:"text-main"},{default:l(()=>[k(c(a.opt.label),1)]),_:2},1024)]),_:2},1024)]),_:2},1040)]),_:1},8,["label","modelValue","options","onFilter"]),n(g,{"label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",type:"number",class:"q-mt-md",modelValue:r.item.amount,"onUpdate:modelValue":t[1]||(t[1]=a=>r.item.amount=a),modelModifiers:{number:!0},label:e.$t("components.inventory.amount")},null,8,["input-style","modelValue","label"])]),_:1}),n(f,null,{default:l(()=>[i("div",$e,[i("div",null,[i("div",ke,c(e.$t("components.inventory.infoSection")),1),i("div",Ie,c(e.$t("components.inventory.infoSectionSub")),1)])]),i("div",Ce,[n(y,{"text-color":"main",color:"primary",label:e.$t("components.inventory.addInfoValue"),onClick:d.addInfo},null,8,["label","onClick"])])]),_:1}),n(f,null,{default:l(()=>[n(U,{ref:"infoForm"},{default:l(()=>[n(L,{class:"bg-secondary text-main",flat:"",square:"",separator:"none"},{default:l(()=>[i("tbody",null,[(u(!0),h(Q,null,N(r.info,(a,b)=>(u(),h("tr",{key:`${b}-infoField`},[i("td",null,[n(g,{"label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",modelValue:a.name,"onUpdate:modelValue":o=>a.name=o,label:e.$t("components.inventory.infoName"),"lazy-rules":"",rules:[o=>o&&o.length>0||e.$t("rules.required"),o=>o&&!/\s/.test(o)||e.$t("rules.noSpace"),o=>o&&r.info.filter(v=>v.name===o).length<=1||e.$t("rules.unique")]},null,8,["input-style","modelValue","onUpdate:modelValue","label","rules"])]),i("td",null,[n(g,{"label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",class:"q-field--with-bottom",modelValue:a.value,"onUpdate:modelValue":o=>a.value=o,label:e.$t("components.inventory.infoValue")},null,8,["input-style","modelValue","onUpdate:modelValue","label"])]),i("td",xe,[n(y,{"text-color":"main",class:"text-red-6",dense:"",flat:"",icon:"fas fa-trash",size:"xs",onClick:o=>d.removeInfo(a)},{default:l(()=>[n(O,null,{default:l(()=>[k(c(e.$t("general.delete")),1)]),_:1})]),_:2},1032,["onClick"])])]))),128))])]),_:1})]),_:1},512)]),_:1}),n(F,{align:"center"},{default:l(()=>[n(y,{"text-color":"main",color:"primary",label:e.$t("general.add"),onClick:d.onOKClick},null,8,["label","onClick"])]),_:1})]),_:1})]),_:1},8,["onHide"])}const Ye=_(be,[["render",qe]]),Ve={name:"EditInventoryItem",data(){return{info:[],editedItem:{}}},props:{title:String,item:Object},emits:["ok","hide"],methods:{isNumeric(e){return typeof e!="string"?!1:!isNaN(e)&&!isNaN(parseFloat(e))},isBoolean(e){return e==="true"||(e==="false"?!1:e)},addInfo(){this.info.push({name:"",value:""})},removeInfo(e){const t=this.info.indexOf(e);t>-1&&this.$q.dialog({component:D,componentProps:{title:this.$i18n.t("components.inventory.deleteInfoHeader"),message:this.$i18n.t("components.inventory.deleteInfoMsg",{name:e.name})},cancel:!0,persistent:!0}).onOk(()=>{this.info.splice(t,1)})},show(){this.$refs.dialog.show()},hide(){this.$refs.dialog.hide()},onDialogHide(){this.$emit("hide")},onOKClick(){this.$refs.infoForm.validate().then(e=>{if(!e){this.$q.notify({message:this.$i18n.t("general.error"),position:"top",color:"red",icon:"fas fa-exclamation-triangle",caption:this.$i18n.t("components.inventory.msg.error.uniqueInfo")});return}this.info.forEach(t=>{!t.name||(this.editedItem.info[t.name]=this.isNumeric(t.value)?Number(t.value):this.isBoolean(t.value))}),this.$emit("ok",{item:this.editedItem}),this.hide()})},onCancelClick(){this.hide()}},mounted(){this.editedItem=this.item;for(const[e,t]of Object.entries(this.item.info))this.info.push({name:e,value:t});this.editedItem.info={}}},we=["innerHTML"],Se={class:"row"},Ne={class:"text-h6"},Qe={class:"text-caption text-sub"},Fe={class:"row q-mt-sm"},He={style:{width:"30px"},class:"text-right vertical-middle"};function Te(e,t,s,p,r,d){return u(),V(T,{ref:"dialog",onHide:d.onDialogHide},{default:l(()=>[n(H,{class:"q-dialog-plugin bg-secondary text-main"},{default:l(()=>[n(f,{class:"row"},{default:l(()=>[i("div",{class:"text-body2",innerHTML:s.title},null,8,we),n(w,{class:"q-ml-auto cursor-pointer",name:"close",onClick:S(d.hide,["stop"])},null,8,["onClick"])]),_:1}),n(f,null,{default:l(()=>[n(g,{"label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",type:"number",class:"q-mt-md",modelValue:r.editedItem.amount,"onUpdate:modelValue":t[0]||(t[0]=a=>r.editedItem.amount=a),modelModifiers:{number:!0},label:e.$t("components.inventory.amount")},null,8,["input-style","modelValue","label"])]),_:1}),n(f,null,{default:l(()=>[i("div",Se,[i("div",null,[i("div",Ne,c(e.$t("components.inventory.infoSection")),1),i("div",Qe,c(e.$t("components.inventory.infoSectionSub")),1)])]),i("div",Fe,[n(y,{"text-color":"main",color:"primary",label:e.$t("components.inventory.addInfoValue"),onClick:d.addInfo},null,8,["label","onClick"])])]),_:1}),n(f,null,{default:l(()=>[n(U,{ref:"infoForm"},{default:l(()=>[n(L,{class:"bg-secondary text-main",flat:"",square:"",separator:"none"},{default:l(()=>[i("tbody",null,[(u(!0),h(Q,null,N(r.info,(a,b)=>(u(),h("tr",{key:`${b}-infoField`},[i("td",null,[n(g,{"label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",modelValue:a.name,"onUpdate:modelValue":o=>a.name=o,label:e.$t("components.inventory.infoName"),"lazy-rules":"",rules:[o=>o&&o.length>0||e.$t("rules.required"),o=>o&&!/\s/.test(o)||e.$t("rules.noSpace"),o=>o&&r.info.filter(v=>v.name===o).length<=1||e.$t("rules.unique")]},null,8,["input-style","modelValue","onUpdate:modelValue","label","rules"])]),i("td",null,[n(g,{"label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",class:"q-field--with-bottom",modelValue:a.value,"onUpdate:modelValue":o=>a.value=o,label:e.$t("components.inventory.infoValue")},null,8,["input-style","modelValue","onUpdate:modelValue","label"])]),i("td",He,[n(y,{"text-color":"main",class:"text-red-6",dense:"",flat:"",icon:"fas fa-trash",size:"xs",onClick:o=>d.removeInfo(a)},{default:l(()=>[n(O,null,{default:l(()=>[k(c(e.$t("general.delete")),1)]),_:1})]),_:2},1032,["onClick"])])]))),128))])]),_:1})]),_:1},512)]),_:1}),n(F,{align:"center"},{default:l(()=>[n(y,{"text-color":"main",color:"primary",label:e.$t("general.ok"),onClick:d.onOKClick},null,8,["label","onClick"])]),_:1})]),_:1})]),_:1},8,["onHide"])}const Ee=_(Ve,[["render",Te]]);export{Ye as A,Ee as E,Ge as F,Re as I,Ke as Q,je as a};