Skip to content

Commit

Permalink
#358 added gewest prop to FilterGemeente component to limit gemeenten…
Browse files Browse the repository at this point in the history
… shown if needed
  • Loading branch information
AxelVerstappen committed Jan 29, 2025
1 parent 6d13793 commit 5f75e76
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ typings/
dist/*
.DS_Store
storybook-static/*

# cypress
cypress/screenshots
18 changes: 16 additions & 2 deletions src/components/smart/FilterGemeente.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
<script setup lang="ts">
import { VlMultiselect } from '@govflanders/vl-ui-design-system-vue3';
import { computed, onBeforeMount, ref } from 'vue';
import { type IFilterGemeenteProps, Niscode } from '@models/index';
import { CrabApiService } from '@services/crab-api.service';
import type { IFilterGemeenteProps } from '@models/index';
import type { IGemeente } from '@models/locatie';
const props = withDefaults(defineProps<IFilterGemeenteProps>(), {
api: '',
value: undefined,
gewest: undefined,
});
const emit = defineEmits(['update:value']);
Expand All @@ -42,6 +43,19 @@ const gemeenten = ref<IGemeente[]>([]);
const customGemeenteLabel = (option: IGemeente) => option.naam;
onBeforeMount(async () => {
gemeenten.value = await crabApiService.getGemeenten();
const data = await crabApiService.getGemeenten();
switch (props.gewest) {
case Niscode.VlaamsGewest:
gemeenten.value = crabApiService.vlaamseGemeenten;
break;
case Niscode.WaalsGewest:
gemeenten.value = crabApiService.waalseGemeenten;
break;
case Niscode.BrusselsHoofdstedelijkGewest:
gemeenten.value = crabApiService.brusselseGemeenten;
break;
default:
gemeenten.value = data;
}
});
</script>
2 changes: 2 additions & 0 deletions src/models/filter-input.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { IGemeente } from './locatie';
import { Niscode } from './niscode.enum';

export type TFilterInput = string | IGemeente;

Expand Down Expand Up @@ -43,6 +44,7 @@ export interface IFilterInputRadioProps {
export interface IFilterGemeenteProps {
api: string;
value?: string;
gewest?: Niscode;
}

export interface IFilterActorProps {
Expand Down
18 changes: 17 additions & 1 deletion src/stories/smart-components/filter-gemeente.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import '@/scss/main.scss';
import FilterGemeente from '@components/smart/FilterGemeente.vue';
import type { Meta, StoryObj } from '@storybook/vue3';
import type { IGemeente } from '@models/locatie';
import { Niscode } from '@models/niscode.enum';

// More on how to set up stories at: https://storybook.js.org/docs/vue/writing-stories/introduction
const meta: Meta<typeof FilterGemeente> = {
Expand All @@ -20,12 +21,20 @@ const meta: Meta<typeof FilterGemeente> = {
},
tags: ['autodocs'],
argTypes: {
gewest: {
control: 'text',
description: 'Gewest niscode',
table: {
type: { summary: 'Niscode' },
defaultValue: { summary: undefined },
},
},
value: {
control: 'text',
description: 'Current niscode',
table: {
type: { summary: 'string' },
defaultValue: { summary: '' },
defaultValue: { summary: undefined },
},
},
api: {
Expand Down Expand Up @@ -72,3 +81,10 @@ export const Default: Story = {
api: 'https://test-geo.onroerenderfgoed.be/',
},
};

export const WithGewestConstraint: Story = {
args: {
api: 'https://test-geo.onroerenderfgoed.be/',
gewest: Niscode.VlaamsGewest,
},
};

0 comments on commit 5f75e76

Please sign in to comment.