Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/358 filter gemeente component prop gewest #359

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
#358 added gewest prop to FilterGemeente component to limit gemeenten…
… shown if needed
AxelVerstappen committed Jan 29, 2025
commit 5f75e764e463355f8866e53aa34ba9890ae7e510
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
@@ -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']);

@@ -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;

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

export interface IFilterActorProps {
18 changes: 17 additions & 1 deletion src/stories/smart-components/filter-gemeente.stories.ts
Original file line number Diff line number Diff line change
@@ -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> = {
@@ -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: {
@@ -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,
},
};