add field meta

This commit is contained in:
Philipp Lang 2023-12-26 20:20:32 +01:00 committed by philipp lang
parent 3c81dfe7db
commit b109d40ebb
7 changed files with 62 additions and 26 deletions

View File

@ -14,7 +14,7 @@ class CheckboxesField extends Field
public static function meta(): array public static function meta(): array
{ {
return [ return [
['key' => 'options', 'default' => [], 'rules' => ['options' => 'array', 'options.*' => 'string'], 'label' => 'Optionen'], ['key' => 'options', 'default' => [], 'rules' => ['options' => 'array', 'options.*' => 'required|string'], 'label' => 'Optionen'],
]; ];
} }

View File

@ -1,5 +1,13 @@
<template> <template>
<div> <f-switch
id="fieldrequired"
v-model="modelValue.required"
label="Erforderlich"
size="sm"
name="fieldrequired"
inline
@update:modelValue="$emit('update:modelValue', {...modelValue, required: $event})"
></f-switch>
<f-textarea <f-textarea
id="description" id="description"
label="Beschreibung" label="Beschreibung"
@ -8,7 +16,6 @@
:model-value="modelValue.description" :model-value="modelValue.description"
@update:modelValue="$emit('update:modelValue', {...modelValue, description: $event})" @update:modelValue="$emit('update:modelValue', {...modelValue, description: $event})"
></f-textarea> ></f-textarea>
</div>
</template> </template>
<script setup> <script setup>

View File

@ -26,7 +26,6 @@
@submit="storeField" @submit="storeField"
> >
<f-text id="fieldname" v-model="singleField.model.name" label="Name" size="sm" name="fieldname"></f-text> <f-text id="fieldname" v-model="singleField.model.name" label="Name" size="sm" name="fieldname"></f-text>
<f-switch id="fieldrequired" v-model="singleField.model.required" label="Erforderlich" size="sm" name="fieldrequired" inline></f-switch>
<component :is="fields[singleField.model.type]" v-model="singleField.model"></component> <component :is="fields[singleField.model.type]" v-model="singleField.model"></component>
</asideform> </asideform>
</div> </div>
@ -52,10 +51,11 @@ import {snakeCase} from 'change-case';
import '!/eventform/dist/main.js'; import '!/eventform/dist/main.js';
import Asideform from './Asideform.vue'; import Asideform from './Asideform.vue';
import TextareaField from './TextareaField.vue'; import TextareaField from './TextareaField.vue';
import DropdownField from './DropdownField.vue'; import TextField from './TextField.vue';
import DropdownField from './RadioField.vue';
import RadioField from './RadioField.vue'; import RadioField from './RadioField.vue';
import CheckboxField from './CheckboxField.vue'; import CheckboxField from './CheckboxField.vue';
import CheckboxesField from './DropdownField.vue'; import CheckboxesField from './CheckboxesField.vue';
const sectionVisible = ref(-1); const sectionVisible = ref(-1);
const singleSection = ref(null); const singleSection = ref(null);
@ -69,6 +69,7 @@ const emit = defineEmits(['submit', 'cancel']);
const fields = { const fields = {
TextareaField: TextareaField, TextareaField: TextareaField,
TextField: TextField,
DropdownField: DropdownField, DropdownField: DropdownField,
RadioField: RadioField, RadioField: RadioField,
CheckboxField: CheckboxField, CheckboxField: CheckboxField,

View File

@ -12,6 +12,15 @@
></f-text> ></f-text>
<ui-icon-button icon="plus" @click="$emit('update:modelValue', {...modelValue, options: [...modelValue.options, '']})">Option einfügen</ui-icon-button> <ui-icon-button icon="plus" @click="$emit('update:modelValue', {...modelValue, options: [...modelValue.options, '']})">Option einfügen</ui-icon-button>
</div> </div>
<f-switch
id="fieldrequired"
v-model="modelValue.required"
label="Erforderlich"
size="sm"
name="fieldrequired"
inline
@update:modelValue="$emit('update:modelValue', {...modelValue, required: $event})"
></f-switch>
</template> </template>
<script setup> <script setup>

View File

@ -0,0 +1,21 @@
<template>
<f-switch
id="fieldrequired"
v-model="modelValue.required"
label="Erforderlich"
size="sm"
name="fieldrequired"
inline
@update:modelValue="$emit('update:modelValue', {...modelValue, required: $event})"
></f-switch>
</template>
<script setup>
const props = defineProps({
modelValue: {
validator: (v) => v === true || v === false,
},
});
const emit = defineEmits(['update:modelValue']);
</script>

View File

@ -1,16 +1,14 @@
<template> <template>
<div> <f-text id="rows" label="Zeilen" size="sm" name="rows" :model-value="modelValue.rows" type="number" min="1" @update:modelValue="$emit('update:modelValue', {...modelValue, rows: $event})"></f-text>
<f-text <f-switch
id="rows" id="fieldrequired"
label="Zeilen" v-model="modelValue.required"
label="Erforderlich"
size="sm" size="sm"
name="rows" name="fieldrequired"
:model-value="modelValue.rows" inline
type="number" @update:modelValue="$emit('update:modelValue', {...modelValue, required: $event})"
min="1" ></f-switch>
@update:modelValue="$emit('update:modelValue', {...modelValue, rows: $event})"
></f-text>
</div>
</template> </template>
<script setup> <script setup>