Skip to content

Commit

Permalink
✨ [#5016] Add Referentielijsten service select to builder
Browse files Browse the repository at this point in the history
and modify the services API endpoint to retrieve referentielijsten services based on a query parameter
  • Loading branch information
stevenbal committed Jan 28, 2025
1 parent 4c63012 commit 98285cb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/openforms/js/components/formio_builder/WebformBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
getRegistrationAttributes,
getValidatorPlugins,
} from './plugins';
import {getServices} from './referentielijsten';

let _supportedLanguages = undefined;
const getSupportedLanguages = () => {
Expand Down Expand Up @@ -167,6 +168,7 @@ class WebformBuilder extends WebformBuilderFormio {
getFormComponents={() => this.webform.form.components}
getValidatorPlugins={getValidatorPlugins}
getRegistrationAttributes={getRegistrationAttributes}
getServices={getServices}
getPrefillPlugins={getPrefillPlugins}
getPrefillAttributes={getPrefillAttributes}
getFileTypes={async () => FILE_TYPES}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {get} from 'utils/fetch';

export const getServices = async type => {
const resp = await get(`/api/v2/services?type=${encodeURIComponent(type)}`);
return resp.data;
};
1 change: 1 addition & 0 deletions src/openforms/services/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Meta:
model = Service
fields = (
"url",
"slug",
"label",
"api_root",
"api_type",
Expand Down
8 changes: 8 additions & 0 deletions src/openforms/services/api/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from zgw_consumers.models import Service

from openforms.api.utils import mark_experimental
from openforms.config.models import GlobalConfiguration

from . import serializers

Expand All @@ -30,3 +31,10 @@ class ServiceViewSet(viewsets.ReadOnlyModelViewSet):
serializer_class = serializers.ServiceSerializer

queryset = Service.objects.all()

def get_queryset(self):
qs = super().get_queryset()
if self.request.query_params.get("type") == "referentielijsten":
config = GlobalConfiguration.get_solo()
return config.referentielijsten_services

Check warning on line 39 in src/openforms/services/api/viewsets.py

View check run for this annotation

Codecov / codecov/patch

src/openforms/services/api/viewsets.py#L38-L39

Added lines #L38 - L39 were not covered by tests
return qs

0 comments on commit 98285cb

Please sign in to comment.