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
Show file tree
Hide file tree
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
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,
},
};