adrema/resources/js/views/formtemplate/GroupField.vue

67 lines
2.0 KiB
Vue
Raw Permalink Normal View History

2023-12-31 14:29:50 +01:00
<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>
2024-04-18 01:03:30 +02:00
<f-switch
id="has_empty_option"
v-model="modelValue.has_empty_option"
label="Leere Option erlauben"
size="sm"
name="has_empty_option"
inline
@update:modelValue="$emit('update:modelValue', {...modelValue, has_empty_option: $event})"
></f-switch>
<f-text
v-if="modelValue.has_empty_option"
id="empty_option_value"
v-model="modelValue.empty_option_value"
label="Wert der leeren Option"
size="sm"
@update:modelValue="$emit('update:modelValue', {...modelValue, empty_option_value: $event})"
></f-text>
2023-12-31 14:29:50 +01:00
<f-select
id="parent_field"
:options="fieldOptions"
size="sm"
name="parent_field"
label="Übergeordnetes Feld"
:model-value="modelValue.parent_field"
@update:modelValue="$emit('update:modelValue', {...props.modelValue, parent_field: $event})"
></f-select>
<f-select
id="parent_group"
:options="meta.groups"
size="sm"
name="parent_group"
label="Übergeordnete Gruppe"
:model-value="modelValue.parent_group"
@update:modelValue="$emit('update:modelValue', {...props.modelValue, parent_group: $event})"
></f-select>
</template>
2024-07-03 16:37:58 +02:00
<script lang="js" setup>
import { computed } from 'vue';
2023-12-31 14:29:50 +01:00
const props = defineProps({
modelValue: {},
meta: {},
payload: {},
});
const fieldOptions = computed(() => {
return props.payload.reduce((carry, section) => {
return section.fields.reduce((fcarry, field) => {
2024-07-03 16:37:58 +02:00
return field.type === 'GroupField' ? fcarry.concat({ id: field.key, name: field.name }) : fcarry;
2023-12-31 14:29:50 +01:00
}, carry);
}, []);
});
const emit = defineEmits(['update:modelValue']);
</script>