From 6da46fde90e19dc37ee84f7eb029dd5c3e828e08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Van=20Der=20Biest?= Date: Wed, 6 Apr 2016 13:24:17 +0200 Subject: [PATCH] mapfishapp: restore ability to choose which context is shown by default --- config/configurations/template | 2 +- mapfishapp/src/main/webapp/app/js/GEOR_config.js | 16 ---------------- .../src/main/webapp/app/js/GEOR_mapinit.js | 14 ++++++++++++-- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/config/configurations/template b/config/configurations/template index 04d4a0bd4b..9d59029aeb 160000 --- a/config/configurations/template +++ b/config/configurations/template @@ -1 +1 @@ -Subproject commit 04d4a0bd4bfd30bb6117b9e86ef209bab12ab39b +Subproject commit 9d59029aeb79147c20475054e83c7e801544a7dd diff --git a/mapfishapp/src/main/webapp/app/js/GEOR_config.js b/mapfishapp/src/main/webapp/app/js/GEOR_config.js index eb31853e58..bbe425393e 100644 --- a/mapfishapp/src/main/webapp/app/js/GEOR_config.js +++ b/mapfishapp/src/main/webapp/app/js/GEOR_config.js @@ -47,22 +47,6 @@ GEOR.config = (function() { */ HEADER_HEIGHT: getCustomParameter("HEADER_HEIGHT", 90), - /** - * Method: DEFAULT_WMC - * runtime method to get the current default WMC - */ - DEFAULT_WMC: function() { - if (GEOR.config.CONTEXTS && - GEOR.config.CONTEXTS[0] && - GEOR.config.CONTEXTS[0]["wmc"]) { - return GEOR.config.CONTEXTS[0]["wmc"]; - } - alert("Administrator: "+ - "GEOR.config.CONTEXTS is not configured as expected !"); - // should not happen: - return "default.wmc"; - }, - /** * Constant: ANONYMOUS * Whether a user is logged in or not: can be overriden diff --git a/mapfishapp/src/main/webapp/app/js/GEOR_mapinit.js b/mapfishapp/src/main/webapp/app/js/GEOR_mapinit.js index fa3c711c6d..4eab1fe3f6 100644 --- a/mapfishapp/src/main/webapp/app/js/GEOR_mapinit.js +++ b/mapfishapp/src/main/webapp/app/js/GEOR_mapinit.js @@ -451,7 +451,7 @@ GEOR.mapinit = (function() { // and finally we're running our global success callback: cb.call(); } else { - updateStoreFromWMC(GEOR.config.DEFAULT_WMC()); + updateStoreFromWMC(GEOR.config.DEFAULT_WMC); } }; @@ -524,6 +524,16 @@ GEOR.mapinit = (function() { layerStore = ls; tr = OpenLayers.i18n; cb = callback || OpenLayers.Util.Void; + + // the default WMC is either the one provided by the admin in GEOR.custom, + // or the first one publicized by mapfishapp's ContextController.java + // in GEOR.config.CONTEXTS + GEOR.config.DEFAULT_WMC = GEOR.custom.DEFAULT_WMC || + // first context publicized by ContextController: + (GEOR.config.CONTEXTS[0] && GEOR.config.CONTEXTS[0]["wmc"]) || + // this last one should not happen + "context/default.wmc"; + var url; // POSTing a content to the app (which results in GEOR.initstate // being set) has priority over everything else: @@ -589,7 +599,7 @@ GEOR.mapinit = (function() { // this is so that the map object and fake base layer are // properly configured when adding the other layers // to the map - updateStoreFromWMC(GEOR.config.DEFAULT_WMC(), { + updateStoreFromWMC(GEOR.config.DEFAULT_WMC, { success: function() { loadLayers(initState); }