Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add global style selector button #353

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix eslint errors
  • Loading branch information
jblanchg authored Feb 10, 2025
commit 297e642c9a0d88bc23bf4520a690b05cedf20b1a
12 changes: 6 additions & 6 deletions plugins/LayerTree.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -796,21 +796,21 @@ class LayerTree extends React.Component {
};

manageStyleSelector = () => {
let styleList = this.getLayerStyles(this.props.layers);
const styleList = this.getLayerStyles(this.props.layers);
if (styleList.length > 0) {
this.setState({ styleList: styleList, activestyleselector: !this.state.activestyleselector });
this.setState((state) => ({styleList: styleList, activestyleselector: !state.activestyleselector}));
}
};
getLayerStyles = (layerList) => {
let styleList = new Set();
const styleList = new Set();
const collectStyles = (layers) => {
for (const layer of layers) {
if (layer.sublayers && layer.sublayers.length > 0) {
collectStyles(layer.sublayers);
}
if (layer.styles && Object.keys(layer.styles).length > 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole block could be shortened to

const styleList = {};
Object.assign(styleList, layer.styles);

for (const styleKey in layer.styles) {
if (layer.styles.hasOwnProperty(styleKey)) {
if (Object.prototype.hasOwnProperty.call(layer.styles, styleKey)) {
styleList.add(layer.styles[styleKey]);
}
}
Expand Down Expand Up @@ -845,8 +845,8 @@ class LayerTree extends React.Component {
}
if (layer.styles && Object.keys(layer.styles).length > 0) {
for (const styleKey in layer.styles) {
if (layer.styles.hasOwnProperty(styleKey) && styleKey === style) {
const wmsLayer = this.props.layers.find(layer => layer.type === "wms");
if (Object.prototype.hasOwnProperty.call(layer.styles, styleKey) && styleKey === style) {
const wmsLayer = this.props.layers.find(l => l.type === "wms");
this.props.changeLayerProperty(wmsLayer.uuid, "style", style, adjustedPath);
}
}
Expand Down
Loading