60 lines
1.7 KiB
Vue
60 lines
1.7 KiB
Vue
<script setup lang="ts">
|
|
import FieldInspector from '@/components/FieldInspector.vue'
|
|
import type { useSchemaBuilder } from '@/composables/useSchemaBuilder'
|
|
import type { BuilderField } from '@/lib/schemaBuilderModel'
|
|
import type { FieldErrors } from '@/lib/schemaBuilderValidation'
|
|
|
|
type Builder = ReturnType<typeof useSchemaBuilder>
|
|
|
|
type InspectorActions = Pick<
|
|
Builder,
|
|
| 'setLabel'
|
|
| 'setFieldKey'
|
|
| 'unlockFieldKey'
|
|
| 'resetFieldKey'
|
|
| 'setFieldType'
|
|
| 'patchField'
|
|
| 'setLimit'
|
|
| 'setDefault'
|
|
| 'addChoice'
|
|
| 'removeChoice'
|
|
| 'renameChoice'
|
|
| 'reorderChoices'
|
|
>
|
|
|
|
const props = defineProps<{
|
|
actions: InspectorActions
|
|
saving: boolean
|
|
focusToken: number
|
|
field: BuilderField
|
|
errors: FieldErrors
|
|
compact: boolean
|
|
}>()
|
|
|
|
const uid = () => props.field.uid
|
|
</script>
|
|
|
|
<template>
|
|
<FieldInspector
|
|
:field="field"
|
|
:errors="errors"
|
|
:disabled="saving"
|
|
:compact="compact"
|
|
:focus-token="focusToken"
|
|
@label="actions.setLabel(uid(), $event)"
|
|
@key="actions.setFieldKey(uid(), $event)"
|
|
@unlock="actions.unlockFieldKey(uid())"
|
|
@reset="actions.resetFieldKey(uid())"
|
|
@type="actions.setFieldType(uid(), $event)"
|
|
@required="actions.patchField(uid(), { required: $event })"
|
|
@unique="actions.patchField(uid(), { unique: $event })"
|
|
@limit="(which, value) => actions.setLimit(uid(), which, value)"
|
|
@default="actions.setDefault(uid(), $event)"
|
|
@default-on="actions.patchField(uid(), { defaultOn: $event })"
|
|
@add-choice="actions.addChoice(uid(), $event)"
|
|
@remove-choice="actions.removeChoice(uid(), $event)"
|
|
@rename-choice="(index, text) => actions.renameChoice(uid(), index, text)"
|
|
@reorder-choices="actions.reorderChoices(uid(), $event)"
|
|
/>
|
|
</template>
|