diff --git a/geonode_mapstore_client/templates/base.html b/geonode_mapstore_client/templates/base.html index 3d5d89e72f..9f96763608 100644 --- a/geonode_mapstore_client/templates/base.html +++ b/geonode_mapstore_client/templates/base.html @@ -17,6 +17,9 @@ {% block header %} {% include './geonode-mapstore-client/snippets/header.html' %} +{% block gn_config %} + {% include './geonode-mapstore-client/_geonode_config.html' %} +{% endblock %} {% endblock %} {% block footer %} diff --git a/geonode_mapstore_client/templates/geonode-mapstore-client/snippets/search_bar.html b/geonode_mapstore_client/templates/geonode-mapstore-client/snippets/search_bar.html index bdad107689..95dafe39d4 100644 --- a/geonode_mapstore_client/templates/geonode-mapstore-client/snippets/search_bar.html +++ b/geonode_mapstore_client/templates/geonode-mapstore-client/snippets/search_bar.html @@ -108,12 +108,39 @@ } const newQueryHash = newParams.join('&'); - const catalogPagePath = window.__GEONODE_CONFIG__.localConfig.geoNodeSettings.catalogPagePath; - const searchPath = '/catalogue/#/search'; - const baseCatalogPath = catalogPagePath ? searchPath.replace('/catalogue/', catalogPagePath) : searchPath; - + const pathname = splitHash[0].replace('#', ''); + const gnCatalogueNode = document.getElementById('#gn-catalogue'); + const catalogPagePath = window.__GEONODE_CONFIG__ + && window.__GEONODE_CONFIG__.localConfig + && window.__GEONODE_CONFIG__.localConfig.geoNodeSettings + && window.__GEONODE_CONFIG__.localConfig.geoNodeSettings.catalogPagePath; + const defaultCatalogPath = '/catalogue/'; + const baseCatalogPath = catalogPagePath ? catalogPagePath : defaultCatalogPath; + const isCatalogPage = window.location.pathname === baseCatalogPath {% block searchbar_search_href %} - location.href = baseCatalogPath + (newQueryHash ? '?' + newQueryHash : ''); + if (queryHash !== newQueryHash) { + // if MapStoreAPI are available we are in the catalog + if (isCatalogPage && window.MapStoreAPI && window.MapStoreAPI.triggerAction) { + // the location change will modify the internal mapstore routing after the # + // without changing the browser path + window.MapStoreAPI.triggerAction({ + type: '@@router/LOCATION_CHANGE', + payload: { + location: { + pathname: !!gnCatalogueNode ? pathname : '/', + search: '?' + newQueryHash, + hash: '' + }, + action: 'PUSH', + isFirstRendering: false + } + }) + } else { + // we need to redirect to catalog page + // if we are in a page different from catalog + location.href = baseCatalogPath + '#/' + (newQueryHash ? '?' + newQueryHash : ''); + } + } {% endblock %} clearRequest();