From 64a449e9b4a151218ebc5617fbc3b8f5be00c0d0 Mon Sep 17 00:00:00 2001 From: Samuel Lorch Date: Sat, 13 May 2023 22:51:07 +0200 Subject: [PATCH] Fix Edit form for Number Type ID's --- client/src/definitions.ts | 7 +++++++ .../src/pages/[subsystem]/[entity]/edit/[id].vue | 16 +++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/client/src/definitions.ts b/client/src/definitions.ts index ff7096c..c9b3759 100644 --- a/client/src/definitions.ts +++ b/client/src/definitions.ts @@ -87,6 +87,7 @@ export const editTypes: { [key: string]: { [key: string]: any } } = { name: "Firewall", "forwardrules": { name: "ForwardRule", + idType: "Number", validationSchema: toFormValidator( zod.object({ name: zod.string(), @@ -111,6 +112,7 @@ export const editTypes: { [key: string]: { [key: string]: any } } = { }, "destinationnatrules": { name: "DestinationNATRule", + idType: "Number", validationSchema: toFormValidator( zod.object({ name: zod.string(), @@ -141,6 +143,7 @@ export const editTypes: { [key: string]: { [key: string]: any } } = { }, "sourcenatrules": { name: "SourceNATRule", + idType: "Number", validationSchema: toFormValidator( zod.object({ name: zod.string(), @@ -208,6 +211,7 @@ export const editTypes: { [key: string]: { [key: string]: any } } = { }, "staticroutes": { name: "StaticRoute", + idType: "Number", validationSchema: toFormValidator( zod.object({ name: zod.string(), @@ -275,6 +279,7 @@ export const editTypes: { [key: string]: { [key: string]: any } } = { name: "Service", "dhcpv4servers": { name: "DHCPv4Server", + idType: "Number", validationSchema: toFormValidator( zod.object({ }), @@ -299,6 +304,7 @@ export const editTypes: { [key: string]: { [key: string]: any } } = { }, "ntpservers": { name: "NTPServer", + idType: "Number", validationSchema: toFormValidator( zod.object({ }), @@ -314,6 +320,7 @@ export const editTypes: { [key: string]: { [key: string]: any } } = { }, "dnsservers": { name: "DNSServer", + idType: "Number", validationSchema: toFormValidator( zod.object({ }), diff --git a/client/src/pages/[subsystem]/[entity]/edit/[id].vue b/client/src/pages/[subsystem]/[entity]/edit/[id].vue index d1fa623..dd7a231 100644 --- a/client/src/pages/[subsystem]/[entity]/edit/[id].vue +++ b/client/src/pages/[subsystem]/[entity]/edit/[id].vue @@ -4,22 +4,28 @@ import { apiCall } from "../../../../api"; import getPlugins from '../../../../plugins'; const p = getPlugins(); -const props = $defineProps<{subsystem: string, entity: string, id: string}>(); +const props = $defineProps<{subsystem: string, entity: string, id: string | number}>(); const { subsystem, entity, id } = $(props); let initialValues = $ref({} as {}); let loading = $ref(true); async function load(){ - loading = true - let res = await apiCall(editTypes[subsystem].name +".Get"+ editTypes[subsystem][entity].name, {id: id}); + loading = true; + let res: any; + if (editTypes[subsystem][entity].idType == "Number") { + res = await apiCall(editTypes[subsystem].name +".Get"+ editTypes[subsystem][entity].name, {id: id as number - 0}); + } else { + res = await apiCall(editTypes[subsystem].name +".Get"+ editTypes[subsystem][entity].name, {id: id}); + } + if (res.Error === null) { console.debug("update data", res.Data); initialValues = res.Data; } else { console.debug("error", res); } - loading = false + loading = false; } async function update(value: any) { @@ -44,7 +50,7 @@ onMounted(async() => {
- +

Loading...