-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #145 rework 1-click template forms logic
- Loading branch information
1 parent
508b935
commit b2819e5
Showing
3 changed files
with
119 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<script setup> | ||
import { computed } from "vue"; | ||
import TextInput from "@/Components/TextInput.vue"; | ||
import FormField from "@/Components/FormField.vue"; | ||
const props = defineProps({ | ||
scope: String, | ||
item: Object, | ||
form: Object, | ||
errors: Object, | ||
}); | ||
const itemName = computed(() => { | ||
if (props.scope) { | ||
return `${props.scope}/${props.item.name}`; | ||
} | ||
return props.item.name; | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div v-if="item.type === 'v-stack'" class="flex flex-col gap-4"> | ||
<template v-for="item in item.items" :key="'v-' + item.id"> | ||
<DynamicForm | ||
:item="item" | ||
:form="form" | ||
:errors="errors" | ||
:scope="scope" | ||
/> | ||
</template> | ||
</div> | ||
|
||
<div v-else-if="item.type === 'h-stack'" class="flex flex-row gap-4"> | ||
<template v-for="item in item.items" :key="'h-' + item.id"> | ||
<DynamicForm | ||
:item="item" | ||
:form="form" | ||
:errors="errors" | ||
:scope="scope" | ||
/> | ||
</template> | ||
</div> | ||
|
||
<template v-else> | ||
<FormField class="w-full" :error="errors[itemName]"> | ||
<template #label>{{ item.label }}</template> | ||
|
||
<TextInput | ||
v-if="item.type === 'text-field'" | ||
v-model="form[itemName]" | ||
class="w-full" | ||
/> | ||
</FormField> | ||
</template> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters