Skip to content

Commit

Permalink
✨ [#2173] Populate WebformBuilder leafletMapBackgrounds
Browse files Browse the repository at this point in the history
  • Loading branch information
robinmolen committed Dec 3, 2024
1 parent ff9684a commit a0964d4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/openforms/forms/admin/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
from zgw_consumers.api_models.constants import VertrouwelijkheidsAanduidingen

from openforms.config.constants import UploadFileType
from openforms.config.models import GlobalConfiguration, RichTextColor
from openforms.config.models import (
GlobalConfiguration,
LeafletMapBackground,
RichTextColor,
)


def get_rich_text_colors():
Expand All @@ -17,6 +21,10 @@ def get_rich_text_colors():
return colors


def get_leaflet_map_backgrounds():
return list(LeafletMapBackground.objects.values("identifier", "url", "label"))


class FormioConfigMixin:
def render_change_form(
self, request, context, add=False, change=False, form_url="", obj=None
Expand All @@ -26,6 +34,7 @@ def render_change_form(
{
"required_default": config.form_fields_required_default,
"rich_text_colors": get_rich_text_colors(),
"leaflet_map_backgrounds": get_leaflet_map_backgrounds(),
"upload_filetypes": [
{"label": label, "value": value}
for value, label in UploadFileType.choices
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{ feature_flags|json_script:"feature-flags" }}
{{ required_default|json_script:'config-REQUIRED_DEFAULT' }}
{{ rich_text_colors|json_script:'config-RICH_TEXT_COLORS' }}
{{ leaflet_map_backgrounds|json_script:'config-LEAFLET_MAP_BACKGROUNDS' }}
{{ upload_filetypes|json_script:'config-UPLOAD_FILETYPES' }}
{{ confidentiality_levels|json_script:'CONFIDENTIALITY_LEVELS' }}
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 @@ -37,6 +37,7 @@ const CONFIDENTIALITY_LEVELS = jsonScriptToVar('CONFIDENTIALITY_LEVELS', {defaul
const FILE_TYPES = jsonScriptToVar('config-UPLOAD_FILETYPES', {default: []});
const MAX_FILE_UPLOAD_SIZE = jsonScriptToVar('setting-MAX_FILE_UPLOAD_SIZE', {default: 'unknown'});
const RICH_TEXT_COLORS = jsonScriptToVar('config-RICH_TEXT_COLORS', {default: []});
const LEAFLET_MAP_BACKGROUNDS = jsonScriptToVar('config-LEAFLET_MAP_BACKGROUNDS', {default: []});

const WebformBuilderFormio = Formio.Builders.builders.webform;

Expand Down Expand Up @@ -162,6 +163,7 @@ class WebformBuilder extends WebformBuilderFormio {
supportedLanguageCodes={LANGUAGES}
theme={currentTheme.getValue()}
richTextColors={RICH_TEXT_COLORS}
leafletMapBackgrounds={LEAFLET_MAP_BACKGROUNDS}
getFormComponents={() => this.webform.form.components}
getValidatorPlugins={getValidatorPlugins}
getRegistrationAttributes={getRegistrationAttributes}
Expand Down

0 comments on commit a0964d4

Please sign in to comment.