@@ -51,7 +51,9 @@ import {
5151 updateDocument ,
5252 setMapThumbnail ,
5353 updateCompactPermissionsByPk ,
54- getResourceByUuid
54+ getResourceByUuid ,
55+ updateDatasetTimeSeries ,
56+ updateResource as updateResourceAPI
5557} from '@js/api/geonode/v2' ;
5658import { parseDevHostname } from '@js/utils/APIUtils' ;
5759import uuid from 'uuid' ;
@@ -79,13 +81,13 @@ import {
7981 cleanCompactPermissions ,
8082 toGeoNodeMapConfig ,
8183 RESOURCE_MANAGEMENT_PROPERTIES ,
82- getDimensions
84+ getDimensions ,
85+ isDefaultDatasetSubtype
8386} from '@js/utils/ResourceUtils' ;
8487import {
8588 ProcessTypes ,
8689 ProcessStatus
8790} from '@js/utils/ResourceServiceUtils' ;
88- import { updateDatasetTimeSeries } from '@js/api/geonode/v2/index' ;
8991import { updateNode , updateSettingsParams } from '@mapstore/framework/actions/layers' ;
9092import { layersSelector , getSelectedLayer as getSelectedNode } from '@mapstore/framework/selectors/layers' ;
9193import { styleServiceSelector , getUpdatedLayer , selectedStyleSelector } from '@mapstore/framework/selectors/styleeditor' ;
@@ -170,21 +172,23 @@ const SaveAPI = {
170172 ...( timeseries && { has_time : timeseries ?. has_time } )
171173 } ;
172174 const { request, actions } = setDefaultStyle ( state , id ) ; // set default style, if modified
173-
174- return request ( ) . then ( ( ) => ( id
175+ return request ( ) . then ( ( ) => {
176+ const patchResource = ! isDefaultDatasetSubtype ( currentResource ?. subtype ) ? updateResourceAPI : updateDataset ;
177+ return ( id
175178 // perform dataset and timeseries updates sequentially to avoid race conditions
176- ? updateDataset ( id , updatedBody ) . then ( ( resource ) =>
177- updateDatasetTimeSeries ( id , timeseries ) . then ( ( ) => resource )
178- ) : Promise . resolve ( ) )
179- . then ( ( _resource ) => {
180- let resource = omit ( _resource , 'default_style' ) ;
181- if ( timeseries ) {
182- const layerId = layersSelector ( state ) ?. find ( ( l ) => l . pk === resource ?. pk ) ?. id ;
183- // actions to be dispacted are added to response array
184- return [ resource , updateNode ( layerId , 'layers' , { dimensions : get ( resource , 'data.dimensions' , [ ] ) } ) , ...actions ] ;
185- }
186- return [ resource , ...actions ] ;
187- } ) ) ;
179+ ? patchResource ( id , updatedBody ) . then ( ( resource ) =>
180+ timeseries ? updateDatasetTimeSeries ( id , timeseries ) . then ( ( ) => resource ) : Promise . resolve ( resource )
181+ ) : Promise . resolve ( ) )
182+ . then ( ( _resource ) => {
183+ let resource = omit ( _resource , 'default_style' ) ;
184+ if ( timeseries ) {
185+ const layerId = layersSelector ( state ) ?. find ( ( l ) => l . pk === resource ?. pk ) ?. id ;
186+ // actions to be dispacted are added to response array
187+ return [ resource , updateNode ( layerId , 'layers' , { dimensions : get ( resource , 'data.dimensions' , [ ] ) } ) , ...actions ] ;
188+ }
189+ return [ resource , ...actions ] ;
190+ } ) ;
191+ } ) ;
188192 } ,
189193 [ ResourceTypes . VIEWER ] : ( state , id , body ) => {
190194 const user = userSelector ( state ) ;
0 commit comments