Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions geonode_mapstore_client/client/js/api/geonode/v2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ export const getResourceByPk = (pk) => {
return axios.get(getEndpointUrl(RESOURCES, `/${pk}`), {
params: {
api_preset: API_PRESET.VIEWER_COMMON,
include_i18n: true
include_i18n: true,
include: ['data']
}
})
.then(({ data }) => data.resource);
Expand Down Expand Up @@ -318,7 +319,8 @@ export const getDatasetByPk = (pk) => {
return axios.get(getEndpointUrl(DATASETS, `/${pk}`), {
params: {
api_preset: [API_PRESET.VIEWER_COMMON, API_PRESET.DATASET],
include_i18n: true
include_i18n: true,
include: ['data']
},
...paramsSerializer()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
gnViewerSetNewResourceThumbnail,
closeInfoPanelOnMapClick,
closeDatasetCatalogPanel,
gnZoomToFitBounds,
closeResourceDetailsOnMapInfoOpen,
gnUpdateResourceExtent,
gnUpdateBackgroundEditEpic,
Expand All @@ -28,8 +27,8 @@ import {
UPDATE_RESOURCE_EXTENT_LOADING,
updateResourceExtent
} from '@js/actions/gnresource';
import { clickOnMap, changeMapView, ZOOM_TO_EXTENT } from '@mapstore/framework/actions/map';
import { SET_CONTROL_PROPERTY, setControlProperty } from '@mapstore/framework/actions/controls';
import { clickOnMap } from '@mapstore/framework/actions/map';
import { SET_CONTROL_PROPERTY } from '@mapstore/framework/actions/controls';
import {
SHOW_NOTIFICATION
} from '@mapstore/framework/actions/notifications';
Expand Down Expand Up @@ -257,26 +256,6 @@ describe('gnresource epics', () => {

});

it('should zoom to extent with the fitBounds control', (done) => {
const NUM_ACTIONS = 2;
const testState = {};
testEpic(gnZoomToFitBounds,
NUM_ACTIONS,
[setControlProperty('fitBounds', 'geometry', [-180, -90, 180, 90]), changeMapView()],
(actions) => {
try {
expect(actions.length).toBe(2);
expect(actions[0].type).toBe(ZOOM_TO_EXTENT);
expect(actions[1].type).toBe(SET_CONTROL_PROPERTY);
} catch (e) {
done(e);
}
done();
},
testState
);

});
it('should update resource extent on UPDATE_RESOURCE_EXTENT action', (done) => {
const NUM_ACTIONS = 3;
const pk = 1;
Expand Down
209 changes: 105 additions & 104 deletions geonode_mapstore_client/client/js/epics/gnresource.js

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions geonode_mapstore_client/client/js/epics/gnsave.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ const SaveAPI = {
...body,
data: {
...body?.data,
dimensions: timeseries?.has_time ? getDimensions({...body?.data, has_time: true}) : []
layerSettings: {
...body?.data?.layerSettings,
dimensions: timeseries?.has_time ? getDimensions({...currentResource, has_time: true}) : []
}
},
...(timeseries && { has_time: timeseries?.has_time })
};
Expand All @@ -209,7 +212,7 @@ const SaveAPI = {
if (timeseries) {
const layerId = layersSelector(state)?.find((l) => l.pk === resource?.pk)?.id;
// actions to be dispacted are added to response array
return [resource, updateNode(layerId, 'layers', { dimensions: get(resource, 'data.dimensions', []) }), ...actions];
return [resource, updateNode(layerId, 'layers', { dimensions: get(resource, 'data.layerSettings.dimensions', []) }), ...actions];
}
return [resource, ...actions];
});
Expand Down
6 changes: 2 additions & 4 deletions geonode_mapstore_client/client/js/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import SecurityPopup from "@mapstore/framework/plugins/SecurityPopup";
import BackgroundSelector from '@mapstore/framework/plugins/BackgroundSelector';
import MetadataExplorer from '@mapstore/framework/plugins/MetadataExplorer';
import CameraPosition from '@mapstore/framework/plugins/CameraPosition';
import CRSSelector from '@mapstore/framework/plugins/CRSSelector';

import OperationPlugin from '@js/plugins/Operation';
import ExecutionTrackerPlugin from '@js/plugins/ExecutionTracker';
Expand Down Expand Up @@ -95,6 +96,7 @@ export const plugins = {
BackgroundSelectorPlugin: BackgroundSelector,
MetadataExplorerPlugin: MetadataExplorer,
CameraPositionPlugin: CameraPosition,
CRSSelectorPlugin: CRSSelector,
LayerDownloadPlugin: toModulePlugin(
'LayerDownload',
() => import(/* webpackChunkName: 'plugins/layer-download' */ '@mapstore/framework/plugins/LayerDownload'),
Expand Down Expand Up @@ -469,10 +471,6 @@ export const plugins = {
'SearchByBookmark',
() => import(/* webpackChunkName: 'plugins/searchByBookmark' */ '@mapstore/framework/plugins/SearchByBookmark')
),
CRSSelectorPlugin: toModulePlugin(
'CRSSelector',
() => import(/* webpackChunkName: 'plugins/CRSSelector' */ '@mapstore/framework/plugins/CRSSelector')
),
SettingsPlugin: toModulePlugin(
'Settings',
() => import(/* webpackChunkName: 'plugins/settings' */ '@mapstore/framework/plugins/Settings')
Expand Down
9 changes: 8 additions & 1 deletion geonode_mapstore_client/client/js/reducers/gnresource.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ import {
import {
cleanCompactPermissions,
getGeoLimitsFromCompactPermissions,
getResourceAdditionalProperties
getResourceAdditionalProperties,
parseMapLayerData,
ResourceTypes
} from '@js/utils/ResourceUtils';

const defaultState = {
Expand Down Expand Up @@ -88,10 +90,15 @@ function gnresource(state = defaultState, action) {
updatedResource.linkedResources = linkedResources;
}

// Persist the dataset config payload in its own slice field so it
// survives same-resource page transitions, where the SET_RESOURCE
// reducer otherwise strips `data` from `state.gnresource.data`.
const isDataset = state.type === ResourceTypes.DATASET;
return {...state,
error: null,
initialResource: { ...actionData },
data: updatedResource,
...(isDataset && { mapLayerData: parseMapLayerData(data) }),
loading: false,
isNew: false
};
Expand Down
41 changes: 31 additions & 10 deletions geonode_mapstore_client/client/js/selectors/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { compareMapChanges } from '@mapstore/framework/utils/MapUtils';
import { currentStorySelector } from '@mapstore/framework/selectors/geostory';
import { originalDataSelector } from '@mapstore/framework/selectors/dashboard';
import { widgetsConfig } from '@mapstore/framework/selectors/widgets';
import { ResourceTypes, RESOURCE_PUBLISHING_PROPERTIES, RESOURCE_OPTIONS_PROPERTIES, resourceToLayerConfig } from '@js/utils/ResourceUtils';
import { ResourceTypes, RESOURCE_PUBLISHING_PROPERTIES, RESOURCE_OPTIONS_PROPERTIES, resourceToLayerConfig, STYLE_SUPPORTED_LAYER_TYPES } from '@js/utils/ResourceUtils';
import {
getCurrentResourceDeleteLoading,
getCurrentResourceCopyLoading
Expand All @@ -29,6 +29,7 @@ import isNil from 'lodash/isNil';
import { generateContextResource } from '@mapstore/framework/selectors/contextcreator';
import { layerSettingSelector, getSelectedLayer as getSelectedNode } from '@mapstore/framework/selectors/layers';
import { saveLayer } from '@mapstore/framework/utils/LayersUtils';
import { crsProjectionsConfigSelector } from '@mapstore/framework/selectors/crsselector';

const RESOURCE_MANAGEMENT_PROPERTIES_KEYS = Object.keys({...RESOURCE_PUBLISHING_PROPERTIES, ...RESOURCE_OPTIONS_PROPERTIES});

Expand Down Expand Up @@ -95,6 +96,13 @@ export const getResourceData = (state) => {
return state?.gnresource?.data;
};

// Returns the dataset persisted payload `{ layerSettings, mapConfig }` from
// `resource.data`. Source of truth for same-resource page transitions where
// `gnresource.data` has been stripped of its `data` field by SET_RESOURCE.
export const getMapLayerData = (state) => {
return state?.gnresource?.mapLayerData ?? { layerSettings: {}, mapConfig: {} };
};

export const getLayerResourceData = (state) => {
return state?.gnresource?.layerDataset;
};
Expand Down Expand Up @@ -177,16 +185,29 @@ export const getDataPayload = (state, resourceType) => {
currentLayerSettings = omitBy(currentLayerSettings,
(value, key) => key === "opacity" && value === 1); // skip default value
const selectedLayer = getSelectedNode(state);
const omitKeys = ['extendedParams', 'availableStyles', 'infoFormats', 'style'];
const omitKeys = [
'extendedParams',
'availableStyles',
'infoFormats',
...(STYLE_SUPPORTED_LAYER_TYPES.includes(state?.gnresource?.subtype) ? ['style'] : [])
Comment thread
allyoucanmap marked this conversation as resolved.
];
const data = saveLayer(selectedLayer ?? {});
const crsSelector = state?.crsselector?.config;
const currentProjection = mapSelector(state)?.projection;
return omit({
...data,
...currentLayerSettings,
...(selectedLayer && {fields: selectedLayer?.fields ?? {}}),
...(crsSelector && {crsSelector: {...crsSelector, currentProjection}})
}, omitKeys);
const mapConfig = mapSaveSelector(state);
const crsSelectorConfig = crsProjectionsConfigSelector(state);
return {
layerSettings: omit({
...data,
...currentLayerSettings,
...(selectedLayer && { fields: selectedLayer?.fields ?? {} })
}, omitKeys),
mapConfig: {
map: pick(mapConfig?.map || {}, [
'projection',
'projections'
]),
...(!isEmpty(crsSelectorConfig) && { crsSelector: crsSelectorConfig })
}
};
}
default:
return null;
Expand Down
Loading
Loading