Skip to content

Commit

Permalink
✨ [#2173] Populate WebformBuilder getMapTileLayers
Browse files Browse the repository at this point in the history
  • Loading branch information
robinmolen committed Dec 17, 2024
1 parent 6891fa1 commit cfe9972
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/openforms/forms/admin/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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, MapTileLayer, RichTextColor


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


def get_map_tile_layers():
return list(MapTileLayer.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 +30,7 @@ def render_change_form(
{
"required_default": config.form_fields_required_default,
"rich_text_colors": get_rich_text_colors(),
"map_tile_layers": get_map_tile_layers(),
"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' }}
{{ map_tile_layers|json_script:'config-MAP_TILE_LAYERS' }}
{{ 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 MAP_TILE_LAYERS = jsonScriptToVar('config-MAP_TILE_LAYERS', {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}
getMapTileLayers={async () => MAP_TILE_LAYERS}
getFormComponents={() => this.webform.form.components}
getValidatorPlugins={getValidatorPlugins}
getRegistrationAttributes={getRegistrationAttributes}
Expand Down

0 comments on commit cfe9972

Please sign in to comment.