forked from geosolutions-it/geonode-mapstore-client
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement msForceVisual style metadata property to force the switch t…
…o visual mode (#724)
- Loading branch information
1 parent
15e9e14
commit e825651
Showing
4 changed files
with
92 additions
and
11 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
geonode_mapstore_client/client/js/api/geonode/style/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2022, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import { | ||
getStyleCodeByName, | ||
updateStyle | ||
} from '@mapstore/framework/api/geoserver/Styles'; | ||
|
||
export function getStyleProperties({ baseUrl, styleName }) { | ||
return import('md5').then((mod) => { | ||
const md5 = mod.default; | ||
return getStyleCodeByName({ | ||
baseUrl, | ||
styleName | ||
}) | ||
.then((style) => { | ||
const { | ||
msForceVisual, | ||
...metadata | ||
} = style?.metadata || {}; | ||
if (!msForceVisual || msForceVisual === '') { | ||
return style; | ||
} | ||
// force use of visual style editor with msForceVisual | ||
// and remove the true value | ||
const updatedMetadata = { | ||
...metadata, | ||
msForceVisual: '', | ||
msEditorType: 'visual', | ||
msStyleJSON: '', | ||
msMD5Hash: md5(style?.code) | ||
}; | ||
return updateStyle({ | ||
...style, | ||
baseUrl, | ||
styleName, | ||
metadata: updatedMetadata, | ||
options: { | ||
params: { | ||
raw: true | ||
} | ||
} | ||
}).then(() => ({ ...style, metadata: updatedMetadata })); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters