From 45c2008c1ba8a93615392017e68c0aac513c05ae Mon Sep 17 00:00:00 2001 From: Jen Jones Arnesen Date: Thu, 6 Jun 2024 14:43:39 +0200 Subject: [PATCH] fix: force overlay for geojson layers --- src/config/field-rules.js | 46 +++++++++++++++++++++++++++++- src/i18n/i18n_module_en.properties | 2 ++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/config/field-rules.js b/src/config/field-rules.js index 475f82e9f..587f22a5d 100644 --- a/src/config/field-rules.js +++ b/src/config/field-rules.js @@ -2,7 +2,7 @@ import { defaultAnalyticsPeriodBoundaries, createDefaultRuleForField } from './f /** * Rule functions in EditModel/form-rules - * + * * Rules for the form fields. * If multiple `when` objects are specified these are evaluated as an OR. * The following would result check if either of the statements return true @@ -388,6 +388,50 @@ export default new Map([ elseValue: false, }], }, + { + // When mapService is geojson or arcgis, then mapLayerPosition must be OVERLAY + field: 'mapLayerPosition', + when: [ + { + field: 'mapService', + operator: 'ONEOF', + value: ['GEOJSON_URL', 'ARCGIS_FEATURE'], + }, + ], + operations: [ + { + field: 'mapLayerPosition', + type: 'CHANGE_VALUE', + + setValue: (model, fieldConfig) => { + fieldConfig.value = 'OVERLAY'; + model[fieldConfig.name] = 'OVERLAY'; + }, + }, + ], + }, + { + // When mapService is Vector style, then mapLayerPosition must be BASEMAP + field: 'mapLayerPosition', + when: [ + { + field: 'mapService', + operator: 'EQUALS', + value: 'VECTOR_STYLE', + }, + ], + operations: [ + { + field: 'mapLayerPosition', + type: 'CHANGE_VALUE', + + setValue: (model, fieldConfig) => { + fieldConfig.value = 'BASEMAP'; + model[fieldConfig.name] = 'BASEMAP'; + }, + }, + ], + }, ]], ['organisationUnit', [ { diff --git a/src/i18n/i18n_module_en.properties b/src/i18n/i18n_module_en.properties index 8a98291b8..8e8707249 100644 --- a/src/i18n/i18n_module_en.properties +++ b/src/i18n/i18n_module_en.properties @@ -1736,6 +1736,8 @@ basemap=Bottom - basemap overlay=Top - overlay before_layer_id=Before layer id legend_set_url=Legend image URL +geojson_url=GeoJSON URL +arcgis_feature=ArcGIS feature confirm_delete_external_map_layer=Are you sure you want to delete this external map layer? sharing_settings=Sharing settings created_by=Created by