|
| 1 | +<script setup> |
| 2 | +import { Head, Link, useForm } from "@inertiajs/vue3" |
| 3 | +import { |
| 4 | + mdiMenu, |
| 5 | + mdiArrowLeftBoldOutline |
| 6 | +} from "@mdi/js" |
| 7 | +import LayoutAuthenticated from "@/Layouts/LayoutAuthenticated.vue" |
| 8 | +import SectionMain from "@/Components/SectionMain.vue" |
| 9 | +import SectionTitleLineWithButton from "@/Components/SectionTitleLineWithButton.vue" |
| 10 | +import CardBox from "@/Components/CardBox.vue" |
| 11 | +import FormField from '@/Components/FormField.vue' |
| 12 | +import FormControl from '@/Components/FormControl.vue' |
| 13 | +import FormCheckRadioGroup from '@/Components/FormCheckRadioGroup.vue' |
| 14 | +import BaseButton from '@/Components/BaseButton.vue' |
| 15 | +import BaseButtons from '@/Components/BaseButtons.vue' |
| 16 | +
|
| 17 | +const props = defineProps({ |
| 18 | + menu: { |
| 19 | + type: Object, |
| 20 | + default: () => ({}), |
| 21 | + }, |
| 22 | + item_options: { |
| 23 | + type: Object, |
| 24 | + default: () => ({}), |
| 25 | + }, |
| 26 | +}) |
| 27 | +
|
| 28 | +const form = useForm({ |
| 29 | + name: '', |
| 30 | + uri: '', |
| 31 | + description: '', |
| 32 | + enabled: true, |
| 33 | + parent_id: '', |
| 34 | + weight: '' |
| 35 | +}) |
| 36 | +
|
| 37 | +</script> |
| 38 | + |
| 39 | +<template> |
| 40 | + <LayoutAuthenticated> |
| 41 | + <Head title="Create menu item" /> |
| 42 | + <SectionMain> |
| 43 | + <SectionTitleLineWithButton |
| 44 | + :icon="mdiMenu" |
| 45 | + title="Add menu item" |
| 46 | + main |
| 47 | + > |
| 48 | + <BaseButton |
| 49 | + :route-name="route('menu.item.index', menu.id)" |
| 50 | + :icon="mdiArrowLeftBoldOutline" |
| 51 | + label="Back" |
| 52 | + color="white" |
| 53 | + rounded-full |
| 54 | + small |
| 55 | + /> |
| 56 | + </SectionTitleLineWithButton> |
| 57 | + <CardBox |
| 58 | + form |
| 59 | + @submit.prevent="form.post(route('menu.item.store', menu.id))" |
| 60 | + > |
| 61 | + <FormField |
| 62 | + label="Name" |
| 63 | + :class="{ 'text-red-400': form.errors.name }" |
| 64 | + > |
| 65 | + <FormControl |
| 66 | + v-model="form.name" |
| 67 | + type="text" |
| 68 | + placeholder="Enter Name" |
| 69 | + :error="form.errors.name" |
| 70 | + > |
| 71 | + <div class="text-red-400 text-sm" v-if="form.errors.name"> |
| 72 | + {{ form.errors.name }} |
| 73 | + </div> |
| 74 | + </FormControl> |
| 75 | + </FormField> |
| 76 | + <FormField |
| 77 | + label="Link" |
| 78 | + :class="{ 'text-red-400': form.errors.uri }" |
| 79 | + > |
| 80 | + <FormControl |
| 81 | + v-model="form.uri" |
| 82 | + type="text" |
| 83 | + placeholder="Enter Link" |
| 84 | + :error="form.errors.name" |
| 85 | + > |
| 86 | + <div class="item-list"> |
| 87 | + You can also enter an internal path such as <em class="placeholder">/home</em> or an external URL such as <em class="placeholder">http://example.com</em>. |
| 88 | + Add prefix <em class="placeholder"><admin></em> to link for admin page. Enter <em class="placeholder"><nolink></em> to display link text only. |
| 89 | + </div> |
| 90 | + <div class="text-red-400 text-sm" v-if="form.errors.uri"> |
| 91 | + {{ form.errors.uri }} |
| 92 | + </div> |
| 93 | + </FormControl> |
| 94 | + </FormField> |
| 95 | + <FormField |
| 96 | + label="Description" |
| 97 | + :class="{ 'text-red-400': form.errors.description }" |
| 98 | + > |
| 99 | + <FormControl |
| 100 | + v-model="form.description" |
| 101 | + type="text" |
| 102 | + placeholder="Enter Description" |
| 103 | + :error="form.errors.description" |
| 104 | + > |
| 105 | + <div class="text-red-400 text-sm" v-if="form.errors.description"> |
| 106 | + {{ form.errors.description }} |
| 107 | + </div> |
| 108 | + </FormControl> |
| 109 | + </FormField> |
| 110 | + <FormCheckRadioGroup |
| 111 | + v-model="form.enabled" |
| 112 | + name="enabled" |
| 113 | + :options="{ enabled: 'Enabled' }" |
| 114 | + /> |
| 115 | + <FormField |
| 116 | + label="Parent Item" |
| 117 | + :class="{ 'text-red-400': form.errors.parent_id }" |
| 118 | + > |
| 119 | + <FormControl |
| 120 | + v-model="form.parent_id" |
| 121 | + type="select" |
| 122 | + placeholder="--ROOT--" |
| 123 | + :error="form.errors.parent_id" |
| 124 | + :options="item_options" |
| 125 | + > |
| 126 | + <div class="text-red-400 text-sm" v-if="form.errors.parent_id"> |
| 127 | + {{ form.errors.parent_id }} |
| 128 | + </div> |
| 129 | + <div> |
| 130 | + The maximum depth for a link and all its children is fixed. Some menu links may not be available as parents if selecting them would exceed this limit. |
| 131 | + </div> |
| 132 | + </FormControl> |
| 133 | + </FormField> |
| 134 | + <FormField |
| 135 | + label="Weight" |
| 136 | + :class="{ 'text-red-400': form.errors.weight }" |
| 137 | + > |
| 138 | + <FormControl |
| 139 | + v-model="form.weight" |
| 140 | + type="text" |
| 141 | + placeholder="Enter Weight" |
| 142 | + :error="form.errors.weight" |
| 143 | + > |
| 144 | + <div class="text-red-400 text-sm" v-if="form.errors.weight"> |
| 145 | + {{ form.errors.weight }} |
| 146 | + </div> |
| 147 | + </FormControl> |
| 148 | + </FormField> |
| 149 | + <template #footer> |
| 150 | + <BaseButtons> |
| 151 | + <BaseButton |
| 152 | + type="submit" |
| 153 | + color="info" |
| 154 | + label="Submit" |
| 155 | + :class="{ 'opacity-25': form.processing }" |
| 156 | + :disabled="form.processing" |
| 157 | + /> |
| 158 | + </BaseButtons> |
| 159 | + </template> |
| 160 | + </CardBox> |
| 161 | + </SectionMain> |
| 162 | + </LayoutAuthenticated> |
| 163 | +</template> |
0 commit comments