Skip to content

Commit

Permalink
Review detail link in homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
allyoucanmap committed Aug 2, 2024
1 parent 4f57b04 commit e69bc1b
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 17 deletions.
12 changes: 11 additions & 1 deletion geonode_mapstore_client/client/js/actions/gnsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const GET_FACET_ITEMS = 'GEONODE:GET_FACET_ITEMS';
export const SET_FACET_ITEMS = 'GEONODE:SET_FACET_ITEMS';
export const GET_FACET_FILTERS = 'GEONODE:GET_FACET_FILTERS';
export const SET_FILTERS = "SET_FILTERS";
export const SHOW_FILTER_FORM = "GEONODE:SHOW_FILTER_FORM";

/**
* Actions for GeoNode resource featured items
Expand Down Expand Up @@ -140,6 +141,13 @@ export function setFilters(filters) {
};
}

export function showFilterForm(show) {
return {
type: SHOW_FILTER_FORM,
show
};
}

export default {
SEARCH_RESOURCES,
searchResources,
Expand All @@ -151,5 +159,7 @@ export default {
requestResource,
setFeaturedResources,
SET_SEARCH_CONFIG,
setSearchConfig
setSearchConfig,
SHOW_FILTER_FORM,
showFilterForm
};
26 changes: 15 additions & 11 deletions geonode_mapstore_client/client/js/plugins/ResourcesGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import {
import { withResizeDetector } from 'react-resize-detector';
import { userSelector } from '@mapstore/framework/selectors/security';
import ConnectedCardGrid from '@js/plugins/resourcesgrid/ConnectedCardGrid';
import { getTotalResources, getFacetsItems } from '@js/selectors/search';
import { searchResources, setSearchConfig, getFacetItems, setFilters as setFiltersAction } from '@js/actions/gnsearch';
import { getTotalResources, getFacetsItems, getShowFilterForm } from '@js/selectors/search';
import { searchResources, setSearchConfig, getFacetItems, setFilters as setFiltersAction, showFilterForm as showFilterFormAction } from '@js/actions/gnsearch';

import gnsearch from '@js/reducers/gnsearch';
import gnresource from '@js/reducers/gnresource';
Expand Down Expand Up @@ -541,9 +541,14 @@ function ResourcesGrid({
onGetFacets,
facets,
filters,
setFilters
setFilters,
showFilterForm: showFilterFormProp,
setShowFilterForm
}, context) {

const showDetail = !isEmpty(resource);
const showFilterForm = showFilterFormProp && !showDetail;

const [_cardLayoutStyleState, setCardLayoutStyle] = useLocalStorage('layoutCardsStyle', defaultCardLayoutStyle);
const cardLayoutStyleState = cardLayoutStyle || _cardLayoutStyleState; // Force style when `cardLayoutStyle` is configured

Expand Down Expand Up @@ -591,10 +596,6 @@ function ResourcesGrid({
excludeQueryKeys: []
});

const [_showFilterForm, setShowFilterForm] = useState(false);
const showDetail = !isEmpty(resource);
const showFilterForm = _showFilterForm && !showDetail;

const handleShowFilterForm = (show) => {
if (!isEmpty(resource)) {
const href = closeDetailPanelHref();
Expand Down Expand Up @@ -858,8 +859,9 @@ const ResourcesGridPlugin = connect(
state => getMonitoredState(state, getConfigProp('monitorState')),
state => state?.gnsearch?.error,
getFacetsItems,
state => state?.gnsearch?.filters
], (params, user, totalResources, loading, location, resource, monitoredState, error, facets, filters) => ({
state => state?.gnsearch?.filters,
getShowFilterForm
], (params, user, totalResources, loading, location, resource, monitoredState, error, facets, filters, showFilterForm) => ({
params,
user,
totalResources,
Expand All @@ -869,13 +871,15 @@ const ResourcesGridPlugin = connect(
monitoredState,
error,
facets,
filters
filters,
showFilterForm
})),
{
onSearch: searchResources,
onInit: setSearchConfig,
onGetFacets: getFacetItems,
setFilters: setFiltersAction
setFilters: setFiltersAction,
setShowFilterForm: showFilterFormAction
}
)(withResizeDetector(withPageConfig(ResourcesGrid)));

Expand Down
8 changes: 7 additions & 1 deletion geonode_mapstore_client/client/js/reducers/gnsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import {
INCREASE_TOTAL_COUNT,
SET_SEARCH_CONFIG,
SET_FACET_ITEMS,
SET_FILTERS
SET_FILTERS,
SHOW_FILTER_FORM
} from '@js/actions/gnsearch';

import { UPDATE_SINGLE_RESOURCE } from '@js/actions/gnresource';
Expand Down Expand Up @@ -132,6 +133,11 @@ function gnsearch(state = defaultState, action) {
...state,
filters: {...state.filters, ...action.filters}
};
case SHOW_FILTER_FORM:
return {
...state,
showFilterForm: !!action.show
};
default:
return state;
}
Expand Down
1 change: 1 addition & 0 deletions geonode_mapstore_client/client/js/selectors/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ export const getTotalResources = (state) => {
};

export const getFacetsItems = state => state?.gnsearch?.facetItems;
export const getShowFilterForm = state => state?.gnsearch?.showFilterForm;
10 changes: 6 additions & 4 deletions geonode_mapstore_client/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,24 @@
{% endblock %}

<script>
window.addEventListener('mapstore:ready', function(event) {
window.addEventListener('mapstore:ready', function (event) {
const catalogPagePath = window.__GEONODE_CONFIG__.localConfig.geoNodeSettings.catalogPagePath;
const pagePath = catalogPagePath ? catalogPagePath : '/catalogue/';
const msAPI = event.detail;
msAPI.setPluginsConfig([
{
name: 'FeaturedResourcesGrid',
cfg: {
targetSelector: '#gn-home-featured-resources-grid',
pagePath: ''
pagePath: pagePath
}
},
{
name: 'ResourcesGrid',
cfg: {
targetSelector: '#gn-home-resources-grid',
pagePath: pagePath,
pagination: true,
pagePath: '',
enableGeoNodeCardsMenuItems: true
}
},
Expand All @@ -83,7 +85,7 @@
]);
});
</script>

{% block ms_scripts %}
<script id="gn-script" src="{% static 'mapstore/dist/js/gn-components.js' %}?{% client_version %}"></script>
{% endblock %}
Expand Down

0 comments on commit e69bc1b

Please sign in to comment.