mirror of
https://github.com/directus/directus.git
synced 2026-01-25 13:38:02 -05:00
Only render form field if field is present (#18500)
This commit is contained in:
committed by
GitHub
parent
2e5a4fd804
commit
b514136ff7
@@ -15,70 +15,72 @@
|
||||
{{ t('no_visible_fields_copy') }}
|
||||
</v-info>
|
||||
<template v-for="(fieldName, index) in fieldNames" :key="fieldName">
|
||||
<component
|
||||
:is="`interface-${fieldsMap[fieldName]?.meta?.interface || 'group-standard'}`"
|
||||
v-if="fieldsMap[fieldName]?.meta?.special?.includes('group')"
|
||||
v-show="!fieldsMap[fieldName]?.meta?.hidden"
|
||||
:ref="
|
||||
<template v-if="fieldsMap[fieldName]">
|
||||
<component
|
||||
:is="`interface-${fieldsMap[fieldName]!.meta?.interface || 'group-standard'}`"
|
||||
v-if="fieldsMap[fieldName]!.meta?.special?.includes('group')"
|
||||
v-show="!fieldsMap[fieldName]!.meta?.hidden"
|
||||
:ref="
|
||||
(el: Element) => {
|
||||
formFieldEls[fieldName] = el;
|
||||
}
|
||||
"
|
||||
:class="[
|
||||
fieldsMap[fieldName]?.meta?.width || 'full',
|
||||
index === firstVisibleFieldIndex ? 'first-visible-field' : '',
|
||||
]"
|
||||
:field="fieldsMap[fieldName]"
|
||||
:fields="fieldsForGroup[index] || []"
|
||||
:values="modelValue || {}"
|
||||
:initial-values="initialValues || {}"
|
||||
:disabled="disabled"
|
||||
:batch-mode="batchMode"
|
||||
:batch-active-fields="batchActiveFields"
|
||||
:primary-key="primaryKey"
|
||||
:loading="loading"
|
||||
:validation-errors="validationErrors"
|
||||
:badge="badge"
|
||||
:raw-editor-enabled="rawEditorEnabled"
|
||||
:direction="direction"
|
||||
v-bind="fieldsMap[fieldName]?.meta?.options || {}"
|
||||
@apply="apply"
|
||||
/>
|
||||
:class="[
|
||||
fieldsMap[fieldName]!.meta?.width || 'full',
|
||||
index === firstVisibleFieldIndex ? 'first-visible-field' : '',
|
||||
]"
|
||||
:field="fieldsMap[fieldName]"
|
||||
:fields="fieldsForGroup[index] || []"
|
||||
:values="modelValue || {}"
|
||||
:initial-values="initialValues || {}"
|
||||
:disabled="disabled"
|
||||
:batch-mode="batchMode"
|
||||
:batch-active-fields="batchActiveFields"
|
||||
:primary-key="primaryKey"
|
||||
:loading="loading"
|
||||
:validation-errors="validationErrors"
|
||||
:badge="badge"
|
||||
:raw-editor-enabled="rawEditorEnabled"
|
||||
:direction="direction"
|
||||
v-bind="fieldsMap[fieldName]!.meta?.options || {}"
|
||||
@apply="apply"
|
||||
/>
|
||||
|
||||
<form-field
|
||||
v-else-if="!fieldsMap[fieldName]?.meta?.hidden"
|
||||
:ref="
|
||||
(el) => {
|
||||
formFieldEls[fieldName] = el;
|
||||
}
|
||||
"
|
||||
:class="index === firstVisibleFieldIndex ? 'first-visible-field' : ''"
|
||||
:field="fieldsMap[fieldName]!"
|
||||
:autofocus="index === firstEditableFieldIndex && autofocus"
|
||||
:model-value="(values || {})[fieldName]"
|
||||
:initial-value="(initialValues || {})[fieldName]"
|
||||
:disabled="isDisabled(fieldsMap[fieldName]!)"
|
||||
:batch-mode="batchMode"
|
||||
:batch-active="batchActiveFields.includes(fieldName)"
|
||||
:primary-key="primaryKey"
|
||||
:loading="loading"
|
||||
:validation-error="
|
||||
validationErrors.find(
|
||||
(err) =>
|
||||
err.collection === fieldsMap[fieldName]?.collection &&
|
||||
(err.field === fieldName || err.field.endsWith(`(${fieldName})`))
|
||||
)
|
||||
"
|
||||
:badge="badge"
|
||||
:raw-editor-enabled="rawEditorEnabled"
|
||||
:raw-editor-active="rawActiveFields.has(fieldName)"
|
||||
:direction="direction"
|
||||
@update:model-value="setValue(fieldName, $event)"
|
||||
@set-field-value="setValue($event.field, $event.value, { force: true })"
|
||||
@unset="unsetValue(fieldsMap[fieldName]!)"
|
||||
@toggle-batch="toggleBatchField(fieldsMap[fieldName]!)"
|
||||
@toggle-raw="toggleRawField(fieldsMap[fieldName]!)"
|
||||
/>
|
||||
<form-field
|
||||
v-else-if="!fieldsMap[fieldName]!.meta?.hidden"
|
||||
:ref="
|
||||
(el) => {
|
||||
formFieldEls[fieldName] = el;
|
||||
}
|
||||
"
|
||||
:class="index === firstVisibleFieldIndex ? 'first-visible-field' : ''"
|
||||
:field="fieldsMap[fieldName]!"
|
||||
:autofocus="index === firstEditableFieldIndex && autofocus"
|
||||
:model-value="(values || {})[fieldName]"
|
||||
:initial-value="(initialValues || {})[fieldName]"
|
||||
:disabled="isDisabled(fieldsMap[fieldName]!)"
|
||||
:batch-mode="batchMode"
|
||||
:batch-active="batchActiveFields.includes(fieldName)"
|
||||
:primary-key="primaryKey"
|
||||
:loading="loading"
|
||||
:validation-error="
|
||||
validationErrors.find(
|
||||
(err) =>
|
||||
err.collection === fieldsMap[fieldName]!.collection &&
|
||||
(err.field === fieldName || err.field.endsWith(`(${fieldName})`))
|
||||
)
|
||||
"
|
||||
:badge="badge"
|
||||
:raw-editor-enabled="rawEditorEnabled"
|
||||
:raw-editor-active="rawActiveFields.has(fieldName)"
|
||||
:direction="direction"
|
||||
@update:model-value="setValue(fieldName, $event)"
|
||||
@set-field-value="setValue($event.field, $event.value, { force: true })"
|
||||
@unset="unsetValue(fieldsMap[fieldName]!)"
|
||||
@toggle-batch="toggleBatchField(fieldsMap[fieldName]!)"
|
||||
@toggle-raw="toggleRawField(fieldsMap[fieldName]!)"
|
||||
/>
|
||||
</template>
|
||||
</template>
|
||||
<v-divider v-if="showDivider && !noVisibleFields" />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user