Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanMiu committed Sep 28, 2020
1 parent 698e7ab commit 8111cd5
Show file tree
Hide file tree
Showing 8 changed files with 572 additions and 21 deletions.
46 changes: 31 additions & 15 deletions src/components/manage/Blocks/DiscodataOpenlayersMapBlock/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,13 @@ const OpenlayersMapView = (props) => {
const extent = data.results?.[0];
if (
stateRef.current.map.sitesSourceQuery?.where &&
stateRef.current.map.sitesSourceQuery?.where.includes('nuts_regions')
stateRef.current.map.sitesSourceQuery?.where.includes(
'nuts_regions',
) &&
extent.MIN_X &&
extent.MIN_Y &&
extent.MAX_X &&
extent.MAX_Y
) {
stateRef.current.map.element
.getView()
Expand Down Expand Up @@ -786,7 +792,9 @@ const OpenlayersMapView = (props) => {

if (
stateRef.current.map.sitesSourceQuery?.where &&
stateRef.current.map.sitesSourceQuery?.where.includes('nuts_regions')
stateRef.current.map.sitesSourceQuery?.where.includes(
'nuts_regions',
)
) {
url =
'https://services.arcgis.com/LcQjj2sL7Txk9Lag/arcgis/rest/services/SiteMap/FeatureServer/0/query/?f=json&' +
Expand Down Expand Up @@ -954,14 +962,19 @@ const OpenlayersMapView = (props) => {
filterSource !== 'query_params' &&
!stateRef.current.updateMapPosition
) {
navigator.geolocation.getCurrentPosition(
(position) => {
return centerPosition(map, position, 12);
},
(error) => {
console.log(error);
},
);
const extent = props.discodata_query.search?.mapExtent;
if (!extent) {
navigator.geolocation.getCurrentPosition(
(position) => {
return centerPosition(map, position, 12);
},
(error) => {
console.log(error);
},
);
} else {
map.getView().fit([extent[0], extent[1], extent[2], extent[3]]);
}
}
// Events
sitesSource.on('updateClosestFeature', function (e) {
Expand Down Expand Up @@ -1019,11 +1032,14 @@ const OpenlayersMapView = (props) => {
applyZoom();
currentZoom = newZoom;
}
props.setQueryParam({
queryParam: {
extent: map.getView().calculateExtent(map.getSize()),
},
});
if (filterSource !== 'query_params') {
props.setQueryParam({
queryParam: {
extent: map.getView().calculateExtent(map.getSize()),
mapExtent: map.getView().calculateExtent(map.getSize()),
},
});
}
}
});
setState({
Expand Down
3 changes: 3 additions & 0 deletions src/components/manage/Blocks/FiltersBlock/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,9 @@ const View = ({ content, ...props }) => {
filtersCounter: props.discodata_query.search['filtersCounter']
? props.discodata_query.search['filtersCounter'] + 1
: 1,
extent: nuts_latest.length
? null
: props.discodata_query.search['extent'],
advancedFiltering,
},
});
Expand Down
5 changes: 5 additions & 0 deletions src/components/manage/Blocks/Iframe/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ const getSchema = (props) => {
title: 'Overflow',
type: 'boolean',
},
preset: {
title: 'Preset',
type: 'array',
choices: [['site_tableau', 'Site tableau']],
},
queryParameters: {
title: 'Query parameters',
type: 'schema',
Expand Down
18 changes: 16 additions & 2 deletions src/components/manage/Blocks/Iframe/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const View = ({ content, ...props }) => {
const [discodataQuery, setDiscodataQuery] = useState({});
const { data } = props;
const { url = '', title = '', width = '100%', height = 'auto' } = data;
const { hideToolbar = false, overflow = false } = data;
const { hideToolbar = false, overflow = false, preset = null } = data;
console.log(discodataQuery);
useEffect(() => {
if (props.data.queryParameters?.value) {
try {
Expand Down Expand Up @@ -69,11 +70,24 @@ const View = ({ content, ...props }) => {
return '';
}
};

const getPresetQueries = () => {
if (preset === 'site_tableau') {
return {
reportingYear: '2017,2018,2019',
};
}
return {};
};

return (
<div>
<Iframe
title={title}
url={applyQueryParameters(url, discodataQuery)}
url={applyQueryParameters(url, {
...discodataQuery,
...getPresetQueries(),
})}
width={width}
height={height}
className="embeded-iframe"
Expand Down
5 changes: 5 additions & 0 deletions src/components/manage/Blocks/NavigationBlock/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ const getSchema = (props) => {
title: 'Parent page',
widget: 'object_by_path',
},
preset: {
title: 'Preset',
type: 'array',
choices: [['site', 'Site']],
},
className: {
title: 'Classname',
type: 'text',
Expand Down
Loading

0 comments on commit 8111cd5

Please sign in to comment.