1
0
Fork 0
forked from Simnation/Main
Main/resources/[tools]/unlimited-spectre/html/assets/GangCreate.fdc0e4eb.js

2 lines
9.2 KiB
JavaScript
Raw Normal View History

2025-06-07 08:51:21 +02:00
import{_ as S,o as g,X as p,a7 as s,a as t,w as r,a6 as _,ab as h,r as N,a5 as u,U as m,a9 as f,Y as y,Z as v,W as V,S as I,aT as U,bG as B,bH as Q}from"./app-014d9ed9.js";import{Q as $}from"./QForm.8d79ab03.js";import{Q as C}from"./QTooltip.9d840032.js";import{Q as x}from"./QMarkupTable.ba6854cc.js";import{B as q}from"./BasicDialog.9dd9de92.js";import{S as O,m as F}from"./move.a5bc0ce3.js";import"./externalHosting.js";import"./position-engine.65ebcb34.js";import"./selection.2a17b691.js";const j={name:"GangCreate",data(){return{defaults:["name","grades","label"],customVars:[],sortable:null,pendingSave:!1,gang:{name:"",grades:{},label:""},gangGrades:[]}},methods:{isNumeric(e){return typeof e!="string"?!1:!isNaN(e)&&!isNaN(parseFloat(e))},isBoolean(e){return e==="true"||(e==="false"?!1:e)},addCustomVar(){this.customVars.push({name:"",value:""})},removeVar(e){const l=this.customVars.indexOf(e);l>-1&&this.$q.dialog({component:q,componentProps:{title:this.$i18n.t("components.gang.deleteHeader"),message:this.$i18n.t("components.gang.deleteCustomVarMsg",{name:e.name})},cancel:!0,persistent:!0}).onOk(()=>{this.customVars.splice(l,1)})},removeNode(e){e.parentElement!==null&&e.parentElement.removeChild(e)},insertNodeAt(e,l,o){const d=o===0?e.children[0]:e.children[o-1].nextSibling;e.insertBefore(l,d)},buildGangGrade(e){let l=[];for(const[o,d]of Object.entries(e))l.push({name:d.name,isboss:d.isboss?d.isboss:!1});return l},updateBoss(){},addGrade(){this.gangGrades.push({name:"",isboss:!1})},removeGrade(e){const l=this.gangGrades.indexOf(e);l>-1&&this.$q.dialog({component:q,componentProps:{title:this.$i18n.t("components.gang.deleteHeader"),message:this.$i18n.t("components.gang.deleteGradeMsg",{name:e.name})},cancel:!0,persistent:!0}).onOk(()=>{this.gangGrades.splice(l,1)})},trySave(){this.$refs.gangForm.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.gang.msg.error.missingFields")});return}this.$refs.customVarForm.validate().then(l=>{if(!l){this.$q.notify({message:this.$i18n.t("general.error"),position:"top",color:"red",icon:"fas fa-exclamation-triangle",caption:this.$i18n.t("components.gang.msg.error.uniqueVars")});return}this.customVars.forEach(d=>{!d.name||(this.gang[d.name]=this.isNumeric(d.value)?Number(d.value):this.isBoolean(d.value))});let o={};for(const[d,i]of Object.entries(this.gangGrades)){if(!i.name)continue;const c=Object.keys(o).length;i.isboss?o[c]={name:i.name,isboss:!0}:o[c]={name:i.name}}if(Object.keys(o).length===0){this.$q.notify({message:this.$i18n.t("general.error"),position:"top",color:"red",icon:"fas fa-exclamation-triangle",caption:this.$i18n.t("components.gang.msg.error.gradeNeeded")});return}this.pendingSave=!0,this.gang.grades=o,this.$axios.post("/api/gangs/create",this.gang).then(d=>{if(this.pendingSave=!1,!d.data.resCode){const c=d.data.resMsg;this.$q.notify({message:this.$i18n.t("general.error"),position:"top",color:"red",icon:"fas fa-exclamation-triangle",caption:this.$i18n.t(`components.gang.msg.error.${c}`,{name:this.gang.name})});return}Object.keys(o).length!==this.gangGrades.length&&(this.gangGrades=this.buildGangGrade(this.gang.grades)),this.$q.notify({message:this.$i18n.t("general.success"),position:"top",color:"green",icon:"fas fa-check",caption:this.$i18n.t("general.saved")}),this.$router.push({name:"dev-gang-list"})}).catch(d=>{})})})}},mounted(){const e=this.$el.querySelector(".q-table > draggable"),l=this;this.sortable=O.create(e,{handle:".drag-handle",animation:150,onEnd(o){o.oldIndex!==o.newIndex&&(l.removeNode(o.item),l.insertNodeAt(o.from,o.item,o.oldIndex),F(l.gangGrades,o.oldIndex,o.newIndex))}})},beforeUnmount(){this.sortable.destroy()}},w=e=>(B("data-v-bd31e4ed"),e=e(),Q(),e),E={class:"row"},M={class:"col-12"},T={class:"q-ma-sm row"},z={class:"text-h6"},A={class:"col-12"},H={class:"q-ma-sm row"},L={class:"row"},D={class:"text-h6"},P={class:"text-caption text-sub"},W={class:"q-ml-auto"},X={style:{width:"30px"},class:"text-right vertical-middle"},Y={class:"c