INIT commit
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<script setup>
|
||||
|
||||
import {isRequestPending} from "src/composables/form/props";
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
|
||||
resetAfterSubmit: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false
|
||||
},
|
||||
isRequestPending,
|
||||
saveButton: {
|
||||
type: Object,
|
||||
required: false,
|
||||
default: () => ({
|
||||
label: "Save",
|
||||
icon: "save",
|
||||
align: "left"
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
const emits = defineEmits(["save"]);
|
||||
const saveForm = () => {
|
||||
const formDataCopy = JSON.parse(JSON.stringify(props.modelValue));
|
||||
emits("save", formDataCopy);
|
||||
|
||||
if (props.resetAfterSubmit) {
|
||||
console.error("Not implemented")
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<q-form @submit.prevent="saveForm" ref="form">
|
||||
|
||||
{{ modelValue }}
|
||||
|
||||
<slot/>
|
||||
|
||||
<q-btn type="submit" color="primary" :icon="props.saveButton.icon" :loading="props.isRequestPending">
|
||||
{{ props.saveButton.label }}
|
||||
<template v-slot:loading>
|
||||
Loading...
|
||||
</template>
|
||||
</q-btn>
|
||||
</q-form>
|
||||
</template>
|
||||
Reference in New Issue
Block a user