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

2 lines
10 KiB
JavaScript
Raw Normal View History

2025-06-07 08:51:21 +02:00
import{_ as S,R as I,P as E,o as m,X as f,a7 as t,a as n,w as r,a6 as _,ab as u,c as $,V,r as D,a5 as p,W as y,U as g,a9 as b,Y as C,Z as k,S as O,aT as U,bG as B,bH as Q}from"./app-014d9ed9.js";import{Q as G}from"./QTooltip.9d840032.js";import{Q as q}from"./QMarkupTable.ba6854cc.js";import{Q as M}from"./QForm.8d79ab03.js";import{S as A,m as T}from"./move.a5bc0ce3.js";import{d as j}from"./utils.9ce591f3.js";import{B as v}from"./BasicDialog.9dd9de92.js";import"./externalHosting.js";import"./position-engine.65ebcb34.js";import"./selection.2a17b691.js";const R={name:"Gang",data(){return{RESOURCE:I,ACTION:E,defaults:["name","grades","label"],customVars:[],sortable:null,pendingSave:!1,pendingDelete:!1,gang:{},gangGrades:[]}},methods:{can:j,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,a){e>-1&&this.$q.dialog({component:v,componentProps:{title:this.$i18n.t("components.gang.deleteHeader"),message:this.$i18n.t("components.gang.deleteCustomVarMsg",{name:a.name})},cancel:!0,persistent:!0}).onOk(()=>{delete this.gang[a.oldName],this.customVars.splice(e,1)})},removeNode(e){e.parentElement!==null&&e.parentElement.removeChild(e)},insertNodeAt(e,a,l){const d=l===0?e.children[0]:e.children[l-1].nextSibling;e.insertBefore(a,d)},buildGangGrade(e){let a=[];for(const[l,d]of Object.entries(e))a.push({name:d.name,isboss:d.isboss?d.isboss:!1});return a},updateBoss(){},addGrade(){this.gangGrades.push({name:"",isboss:!1})},removeGrade(e){const a=this.gangGrades.indexOf(e);a>-1&&this.$q.dialog({component:v,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(a,1)})},trySave(){this.$refs.customVarForm.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.uniqueVars")});return}this.customVars.forEach(l=>{!l.name||(l.oldName=l.name,this.gang[l.name]=this.isNumeric(l.value)?Number(l.value):this.isBoolean(l.value))});let a={};for(const[l,d]of Object.entries(this.gangGrades)){if(!d.name)continue;const s=Object.keys(a).length;d.isboss?a[s]={name:d.name,isboss:!0}:a[s]={name:d.name}}if(Object.keys(a).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=a,this.$axios.patch(`/api/gangs/save/${this.$route.params.gangId}`,this.gang).then(l=>{if(this.pendingSave=!1,!l.data.resCode){const s=l.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.${s}`,{name:this.gang.name})});return}Object.keys(a).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")})}).catch(l=>{})})},tryDelete(){this.pendingDelete=!0,this.$q.dialog({component:v,componentProps:{title:this.$i18n.t("components.gang.deleteHeader"),message:this.$i18n.t("components.gang.deleteMsg",{name:this.$route.params.gangId})},cancel:!0,persistent:!0}).onOk(()=>{this.$axios.delete(`/api/gangs/delete/${this.$route.params.gangId}`).then(e=>{if(this.pendingDelete=!1,!e.data.resCode){const l=e.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.${l}`,{name:this.$route.params.gangId})});return}this.$q.notify({message:this.$i18n.t("general.success"),position:"top",color:"green",icon:"fas fa-check",caption:this.$i18n.t("general.deleted")}),this.$router.push({name:"dev-gang-list"})}).catch(e=>{})}