Show validation errors in drawer-item (#17423)

Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>
This commit is contained in:
Nitwel
2023-03-06 11:47:05 +01:00
committed by GitHub
parent 4b2edb05c3
commit 9d1dd1ae52
5 changed files with 15 additions and 10 deletions

View File

@@ -1,13 +1,13 @@
<template>
<div ref="el" class="v-form" :class="gridClass">
<validation-errors
v-if="!nested && validationErrors.length > 0"
v-if="showValidationErrors && validationErrors.length > 0"
:validation-errors="validationErrors"
:fields="fields ? fields : []"
@scroll-to-field="scrollToField"
/>
<v-info
v-if="noVisibleFields && !nested && !loading"
v-if="noVisibleFields && showNoVisibleFields && !loading"
:title="t('no_visible_fields')"
:icon="inline ? false : 'search'"
center
@@ -115,7 +115,8 @@ interface Props {
autofocus?: boolean;
group?: string | null;
badge?: string;
nested?: boolean;
showValidationErrors?: boolean;
showNoVisibleFields?: boolean;
rawEditorEnabled?: boolean;
direction?: string;
showDivider?: boolean;
@@ -135,7 +136,8 @@ const props = withDefaults(defineProps<Props>(), {
autofocus: false,
group: null,
badge: undefined,
nested: false,
showValidationErrors: true,
showNoVisibleFields: true,
rawEditorEnabled: false,
direction: undefined,
showDivider: false,
@@ -203,7 +205,7 @@ const noVisibleFields = computed(() => {
watch(
() => props.validationErrors,
(newVal, oldVal) => {
if (props.nested) return;
if (!props.showValidationErrors) return;
if (isEqual(newVal, oldVal)) return;
if (newVal?.length > 0) el?.value?.scrollIntoView({ behavior: 'smooth' });
}

View File

@@ -29,7 +29,8 @@
:batch-mode="batchMode"
:disabled="disabled"
:direction="direction"
nested
:show-no-visible-fields="false"
:show-validation-errors="false"
@update:model-value="$emit('apply', $event)"
/>
</div>

View File

@@ -38,7 +38,8 @@
:disabled="disabled"
:badge="badge"
:direction="direction"
nested
:show-no-visible-fields="false"
:show-validation-errors="false"
@update:model-value="$emit('apply', $event)"
/>
</v-detail>

View File

@@ -12,7 +12,8 @@
:badge="badge"
:raw-editor-enabled="rawEditorEnabled"
:direction="direction"
nested
:show-no-visible-fields="false"
:show-validation-errors="false"
@update:model-value="$emit('apply', $event)"
/>
</div>

View File

@@ -37,7 +37,7 @@
v-if="junctionField"
:disabled="disabled"
:loading="loading"
:nested="true"
:show-no-visible-fields="false"
:initial-values="initialValues?.[junctionField]"
:primary-key="relatedPrimaryKey"
:model-value="internalEdits?.[junctionField]"
@@ -52,7 +52,7 @@
v-model="internalEdits"
:disabled="disabled"
:loading="loading"
:nested="true"
:show-no-visible-fields="false"
:initial-values="initialValues"
:autofocus="swapFormOrder"
:show-divider="swapFormOrder"