From f01a6f95ddd8e31533b27b99dbda28da01ee9471 Mon Sep 17 00:00:00 2001 From: Magnar Eivind Martinsen Date: Fri, 30 Jun 2023 15:19:10 +0200 Subject: [PATCH] Started fixing the go back issues. Fixed some small problem in the landingpages --- metsis/metsis_lib/js/custom/go_back.js | 3 +++ metsis/metsis_lib/metsis_lib.libraries.yml | 4 ++++ .../src/Controller/DynamicLandingPagesController.php | 2 +- metsis/metsis_wms/js/metsis_wms.js | 4 +++- metsis/metsis_wms/src/Controller/DefaultController.php | 3 ++- 5 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 metsis/metsis_lib/js/custom/go_back.js diff --git a/metsis/metsis_lib/js/custom/go_back.js b/metsis/metsis_lib/js/custom/go_back.js new file mode 100644 index 0000000..08d38cd --- /dev/null +++ b/metsis/metsis_lib/js/custom/go_back.js @@ -0,0 +1,3 @@ +function go_back() { + history.back(); +} diff --git a/metsis/metsis_lib/metsis_lib.libraries.yml b/metsis/metsis_lib/metsis_lib.libraries.yml index c100576..2f2009e 100644 --- a/metsis/metsis_lib/metsis_lib.libraries.yml +++ b/metsis/metsis_lib/metsis_lib.libraries.yml @@ -55,6 +55,10 @@ landing_page: css: theme: css/landing_page.css: {} +go_back: + version: 1.0.0 + js: + js/custom/go_back.js: {} fa_academia: version: v1.9.2 diff --git a/metsis/metsis_lib/src/Controller/DynamicLandingPagesController.php b/metsis/metsis_lib/src/Controller/DynamicLandingPagesController.php index 586094d..ff0baf5 100644 --- a/metsis/metsis_lib/src/Controller/DynamicLandingPagesController.php +++ b/metsis/metsis_lib/src/Controller/DynamicLandingPagesController.php @@ -323,7 +323,7 @@ public function getLandingPage($id) { '#suffix' => '', ]; - if ((!NULL == $fields['access_constraint']) && (!NULL == $fields['use_constraint_identifier'])) { + if ((!NULL == $fields['access_constraint']) || (!NULL == $fields['use_constraint_identifier'])) { $renderArray['constraints_and_info']['constraints'] = [ '#type' => 'fieldset', '#title' => $this->t('Use and Access Constraints'), diff --git a/metsis/metsis_wms/js/metsis_wms.js b/metsis/metsis_wms/js/metsis_wms.js index aedb8d0..170c32c 100644 --- a/metsis/metsis_wms/js/metsis_wms.js +++ b/metsis/metsis_wms/js/metsis_wms.js @@ -2432,7 +2432,9 @@ console.log("Start of wms map script:"); document.getElementById("droplayers").style.display = "inline"; } } - + document.getElementById("goBackMapButton").addEventListener("click", () => { + history.back(); + }) }); }, }; diff --git a/metsis/metsis_wms/src/Controller/DefaultController.php b/metsis/metsis_wms/src/Controller/DefaultController.php index 59aa4aa..a8bb729 100644 --- a/metsis/metsis_wms/src/Controller/DefaultController.php +++ b/metsis/metsis_wms/src/Controller/DefaultController.php @@ -176,7 +176,7 @@ public function getWmsMap() { ]; $build['search-map']['top-panel']['buttons-container']['go-back'] = [ '#type' => 'markup', - '#markup' => 'Go back to search', + '#markup' => 'Go back to search', '#allowed_tags' => ['div', 'label', 'button', 'br', 'a', 'span'], ]; $build['search-map']['top-panel']['buttons-container']['reset-map'] = [ @@ -389,6 +389,7 @@ public function getWmsMap() { $build['#attached'] = [ 'library' => [ 'metsis_lib/adc_buttons', + 'metsis_lib/go_back', 'metsis_wms/wms_ol6', ], 'drupalSettings' => [