Skip to content

Commit

Permalink
#203 Show required per field optionally and update annotation text
Browse files Browse the repository at this point in the history
  • Loading branch information
wouter-adriaens committed Jan 24, 2024
1 parent 3e3ead3 commit 4747265
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
41 changes: 22 additions & 19 deletions src/components/smart/OeAdres.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<VlPropertiesLabel>
<vl-form-message-label data-cy="label-land">
<span class="vl-u-spacer-right--xxsmall">Land</span>
<span v-if="$props.config?.land?.required" class="vl-form__annotation">
{{ '(verplicht)' }}
</span>
<span v-if="props.showRequiredPerField && $props.config?.land?.required" class="vl-form__annotation"
>VERPLICHT</span
>
</vl-form-message-label>
</VlPropertiesLabel>
<VlPropertiesData>
Expand All @@ -35,9 +35,9 @@
<VlPropertiesLabel>
<vl-form-message-label data-cy="label-gemeente">
<span class="vl-u-spacer-right--xxsmall">Gemeente</span>
<span v-if="$props.config?.gemeente?.required" class="vl-form__annotation">
{{ '(verplicht)' }}
</span>
<span v-if="props.showRequiredPerField && $props.config?.gemeente?.required" class="vl-form__annotation"
>VERPLICHT</span
>
</vl-form-message-label>
</VlPropertiesLabel>
<VlPropertiesData>
Expand Down Expand Up @@ -84,9 +84,9 @@
<VlPropertiesLabel>
<vl-form-message-label data-cy="label-postcode">
<span class="vl-u-spacer-right--xxsmall">Postcode</span>
<span v-if="$props.config?.postcode?.required" class="vl-form__annotation">
{{ '(verplicht)' }}
</span>
<span v-if="props.showRequiredPerField && $props.config?.postcode?.required" class="vl-form__annotation"
>VERPLICHT</span
>
</vl-form-message-label>
</VlPropertiesLabel>
<VlPropertiesData>
Expand Down Expand Up @@ -144,9 +144,9 @@
<VlPropertiesLabel>
<vl-form-message-label data-cy="label-straat">
<span class="vl-u-spacer-right--xxsmall">Straat</span>
<span v-if="$props.config?.straat?.required" class="vl-form__annotation">
{{ '(verplicht)' }}
</span>
<span v-if="props.showRequiredPerField && $props.config?.straat?.required" class="vl-form__annotation"
>VERPLICHT</span
>
</vl-form-message-label>
</VlPropertiesLabel>
<VlPropertiesData>
Expand Down Expand Up @@ -199,9 +199,9 @@
<VlPropertiesLabel>
<vl-form-message-label data-cy="label-huisnummer">
<span class="vl-u-spacer-right--xxsmall">Huisnummer</span>
<span v-if="$props.config?.huisnummer?.required" class="vl-form__annotation">
{{ '(verplicht)' }}
</span>
<span v-if="props.showRequiredPerField && $props.config?.huisnummer?.required" class="vl-form__annotation"
>VERPLICHT</span
>
</vl-form-message-label>
</VlPropertiesLabel>
<VlPropertiesData>
Expand Down Expand Up @@ -259,9 +259,9 @@
<VlPropertiesLabel>
<vl-form-message-label data-cy="label-busnummer">
<span class="vl-u-spacer-right--xxsmall">Busnummer</span>
<span v-if="$props.config?.busnummer?.required" class="vl-form__annotation">
{{ '(verplicht)' }}
</span>
<span v-if="props.showRequiredPerField && $props.config?.busnummer?.required" class="vl-form__annotation"
>VERPLICHT</span
>
</vl-form-message-label>
</VlPropertiesLabel>
<VlPropertiesData>
Expand Down Expand Up @@ -342,12 +342,14 @@ import { CrabApiService } from '@services/crab-api.service';
import { requiredIf } from '@utils/i18n-validators';
const props = withDefaults(defineProps<IAdresProps>(), {
hideTitle: false,
showRequiredPerField: false,
config: () => ({
land: { required: true },
gemeente: { required: true },
postcode: { required: true },
straat: { required: true },
huisnummer: { required: false },
huisnummer: { required: true },
busnummer: { required: false },
}),
api: 'https://test-geo.onroerenderfgoed.be/',
Expand Down Expand Up @@ -506,6 +508,7 @@ const rules = computed(() => ({
// Init validation instance
const v$ = useVuelidate(rules, adres, { $lazy: true });
defineExpose({ validate: () => v$.value.$validate() });
// Reference data
const crabApiService = new CrabApiService(props.api);
Expand Down
1 change: 1 addition & 0 deletions src/models/adres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface IAdresProps {
countryId?: string;
adres?: ILocatieAdres;
optionsLimit?: number;
showRequiredPerField?: boolean;
}

export interface IAdresConfig {
Expand Down

0 comments on commit 4747265

Please sign in to comment.