Skip to content

Commit

Permalink
[Taskman #125090] Map now loads all sites when filtering by country
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanMiu committed Dec 14, 2020
1 parent 2a871f8 commit 50f5b19
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
34 changes: 11 additions & 23 deletions src/components/manage/Blocks/DiscodataOpenlayersMapBlock/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import PrivacyProtection from './PrivacyProtection';
// VOLTO-DATABLOCKS
import { setQueryParam } from 'volto-datablocks/actions';
// SEMANTIC REACT UI
import { Grid, Header, Loader, Dimmer } from 'semantic-ui-react';
import { Grid, Header } from 'semantic-ui-react';
// SVGs
import clearSVG from '@plone/volto/icons/clear.svg';
import navigationSVG from '@plone/volto/icons/navigation.svg';
Expand Down Expand Up @@ -101,7 +101,6 @@ const OpenlayersMapView = (props) => {
updateMapPosition: null,
});
const [selectedSite, setSelectedSite] = useState(null);
const [loader, setLoader] = useState(false);
const [mapRendered, setMapRendered] = useState(false);
const [firstFilteringUpdate, setFirstFilteringUpdate] = useState(false);
const [prepareMapRender, setPrepareMapRender] = useState(false);
Expand Down Expand Up @@ -350,6 +349,11 @@ const OpenlayersMapView = (props) => {
sql: `(eea_activities LIKE '%:options%')`,
type: 'multiple',
},
// Country
siteCountry: {
sql: `(countryCode LIKE '%:options%')`,
type: 'multiple',
},
// Country / Region / Provinces
nuts_latest: {
sql: `(nuts_regions LIKE '%:options%')`,
Expand Down Expand Up @@ -628,13 +632,12 @@ const OpenlayersMapView = (props) => {
const extent = data.results?.[0];
if (
stateRef.current.map.sitesSourceQuery?.where &&
stateRef.current.map.sitesSourceQuery?.where.includes(
(stateRef.current.map.sitesSourceQuery?.where.includes(
'nuts_regions',
) &&
extent.MIN_X &&
extent.MIN_Y &&
extent.MAX_X &&
extent.MAX_Y
) ||
stateRef.current.map.sitesSourceQuery?.where.includes(
'countryCode',
))
) {
stateRef.current.map.element
.getView()
Expand Down Expand Up @@ -835,18 +838,6 @@ const OpenlayersMapView = (props) => {
extent[3] +
',"spatialReference":{"wkid":102100}}',
)}&geometryType=esriGeometryEnvelope&inSR=102100&outFields=*&outSR=102100`;

if (
stateRef.current.map.sitesSourceQuery?.where &&
stateRef.current.map.sitesSourceQuery?.where.includes(
'nuts_regions',
)
) {
url =
'https://services.arcgis.com/LcQjj2sL7Txk9Lag/arcgis/rest/services/SiteMap/FeatureServer/0/query/?f=json&' +
'returnGeometry=true&spatialRel=esriSpatialRelIntersects&geometryType=esriGeometryEnvelope&inSR=102100&outFields=*' +
'&outSR=102100';
}
reqs++;
jsonp(
url,
Expand Down Expand Up @@ -1332,9 +1323,6 @@ const OpenlayersMapView = (props) => {
</>
)}
</div>
<Dimmer id="map-loader" active={loader}>
<Loader />
</Dimmer>
{document.getElementById('map-view-your-area-button') ? (
<Portal node={document.getElementById('map-view-your-area-button')}>
<div id="view-your-area" className="ol-unselectable ol-control">
Expand Down
13 changes: 12 additions & 1 deletion src/components/manage/Blocks/FiltersBlock/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ const View = ({ content, ...props }) => {
}
setState({
...state,
filters: newFilters,
filters: { ...(newFilters || {}) },
});
if (triggerQueryUpdate) {
props.setQueryParam({
Expand Down Expand Up @@ -830,6 +830,7 @@ const View = ({ content, ...props }) => {
const provinces = state.filters.province;
let nuts = [];
let nuts_latest = [];
console.log(state.filters);
siteCountries &&
siteCountries.forEach((country) => {
const filteredRegions = regions
Expand Down Expand Up @@ -1320,6 +1321,16 @@ const View = ({ content, ...props }) => {
/>
</div>
</div>
<div className="dynamic-filter-actions">
<button
aria-label="Clear filters button"
className="outline red"
onClick={clearFilters}
style={{ margin: 0 }}
>
Clear Filters
</button>
</div>
</div>
</Portal>
);
Expand Down

0 comments on commit 50f5b19

Please sign in to comment.