mirror of
https://github.com/speatzle/nfsense.git
synced 2025-09-13 15:19:08 +00:00
Add Form Submit Functionality
This commit is contained in:
parent
54460ca3d5
commit
d7f2eb64f9
4 changed files with 47 additions and 12 deletions
|
@ -14,11 +14,11 @@ async function update() {
|
|||
</script>
|
||||
<template>
|
||||
<div v-if="editTypes[subsystem][entity]">
|
||||
<PageHeader :title="'Edit ' + editTypes[subsystem][entity].title">
|
||||
<PageHeader :title="'Edit ' + editTypes[subsystem][entity].name">
|
||||
<button @click="update">Update</button>
|
||||
<button @click="$router.go(-1)">Discard</button>
|
||||
</PageHeader>
|
||||
<NiceForm class="scroll cl-secondary" :title="editTypes[subsystem][entity].title" :sections="editTypes[subsystem][entity].sections" v-model="data"/>
|
||||
<NiceForm class="scroll cl-secondary" :sections="editTypes[subsystem][entity].sections" v-model="data"/>
|
||||
</div>
|
||||
<div v-else>
|
||||
<PageHeader title="Error"/>
|
||||
|
|
|
@ -1,23 +1,32 @@
|
|||
<script setup lang="ts">
|
||||
import { editTypes } from "../../../../definitions";
|
||||
import { apiCall } from "../../../../api";
|
||||
import { useToast } from 'vue-toast-notification';
|
||||
|
||||
const $toast = useToast();
|
||||
|
||||
const props = $defineProps<{subsystem: string, entity: string}>();
|
||||
const { subsystem, entity } = $(props);
|
||||
|
||||
let data = $ref({});
|
||||
|
||||
async function create() {
|
||||
|
||||
async function create(value: any) {
|
||||
console.debug("value", value);
|
||||
let res = await apiCall(editTypes[subsystem].name +".Create"+ editTypes[subsystem][entity].name, value);
|
||||
if (res.Error === null) {
|
||||
$toast.success("Created " + entity);
|
||||
$router.go(-1)
|
||||
} else {
|
||||
console.debug("error", res);
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<template>
|
||||
<div v-if="editTypes[subsystem][entity]">
|
||||
<PageHeader :title="'Edit ' + editTypes[subsystem][entity].title">
|
||||
<button @click="create">Create</button>
|
||||
<button @click="$router.go(-1)">Discard</button>
|
||||
<PageHeader :title="'Create ' + editTypes[subsystem][entity].name">
|
||||
</PageHeader>
|
||||
<NiceForm class="scroll cl-secondary" :title="editTypes[subsystem][entity].title" :sections="editTypes[subsystem][entity].sections" v-model="data"/>
|
||||
<NiceForm class="scroll cl-secondary" :submit="create" :discard="() => $router.go(-1)" :sections="editTypes[subsystem][entity].sections" v-model="data"/>
|
||||
</div>
|
||||
<div v-else>
|
||||
<PageHeader title="Error"/>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue