Skip to content

Commit

Permalink
Add option to hide map filter geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Apr 22, 2024
1 parent cf25a92 commit c7cba56
Show file tree
Hide file tree
Showing 21 changed files with 39 additions and 8 deletions.
21 changes: 13 additions & 8 deletions components/MapSelection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,24 @@ import MeasureUtils from '../utils/MeasureUtils';

class MapSelection extends React.Component {
static propTypes = {
/* Whether the selection tool is active */
/** Whether the selection tool is active */
active: PropTypes.bool,
/* Optional, a css-cursor to use when drawing */
/** Optional, a css-cursor to use when drawing */
cursor: PropTypes.string,
/* The selection geometry type (Point, LineString, Polygon, Circle, DragBox, Box) */
/** The selection geometry type (Point, LineString, Polygon, Circle, DragBox, Box) */
geomType: PropTypes.string,
/* Initial geometry or geometry to update. */
/** Initial geometry or geometry to update. */
geometry: PropTypes.object,
/* The callback which is invoked with a drawn geometry. */
/** The callback which is invoked with a drawn geometry. */
geometryChanged: PropTypes.func,
/* Whether to show measurements while drawing. */
/** Whether to hide the current selection (except while drawing). */
hideGeometry: PropTypes.bool,
/** Whether to show measurements while drawing. */
measure: PropTypes.bool,
projection: PropTypes.string,
/* Optional: the selection feature style name. */
/** Optional: the selection feature style name. */
styleName: PropTypes.string,
/* Optional: the selection feature style options. */
/** Optional: the selection feature style options. */
styleOptions: PropTypes.object
};
static defaultProps = {
Expand Down Expand Up @@ -64,6 +66,9 @@ class MapSelection extends React.Component {
}
}
componentDidUpdate(prevProps, prevState) {
if (this.props.hideGeometry !== prevProps.hideGeometry) {
this.selectionLayer.setVisible(!this.props.hideGeometry);
}
if (this.props.geomType !== prevProps.geomType) {
this.selectionLayer.getSource().clear();
}
Expand Down
7 changes: 7 additions & 0 deletions plugins/MapFilter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ class MapFilter extends React.Component {
geomType={selGeomType}
geometry={this.state.geomFilter?.geom}
geometryChanged={this.setFilterGeometry}
hideGeometry={this.state.geomFilter?.hideFilterGeom}
key="MapSelection"
styleOptions={this.props.highlightStyle} />
];
Expand Down Expand Up @@ -545,6 +546,9 @@ class MapFilter extends React.Component {
</div>
<div className="map-filter-entry-body">
<ButtonBar active={active} buttons={filterButtons} onClick={this.triggerGeometryFilter} />
<div>
<label><input checked={!!geomFilter.hideFilterGeom} onChange={this.toggleHideFilterGeom} type="checkbox" /> {LocaleUtils.tr("mapfilter.hidefiltergeom")}</label>
</div>
</div>
</div>
);
Expand All @@ -562,6 +566,9 @@ class MapFilter extends React.Component {
filterGeomPicked = (layer, feature) => {
this.setState((state) => ({geomFilter: {...state.geomFilter, geom: feature.geometry, geomType: feature.geometry.type}}));
};
toggleHideFilterGeom = (ev) => {
this.setState((state) => ({geomFilter: {...state.geomFilter, hideFilterGeom: ev.target.checked}}));
};
toggleFilter = (filterId, active) => {
this.setState((state) => ({
filters: {
Expand Down
1 change: 1 addition & 0 deletions translations/ca-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"brokenrendering": "",
"cancel": "",
"geomfilter": "",
"hidefiltergeom": "",
"invalidfilter": "",
"save": "",
"select": "",
Expand Down
1 change: 1 addition & 0 deletions translations/cs-CZ.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"brokenrendering": "",
"cancel": "",
"geomfilter": "",
"hidefiltergeom": "",
"invalidfilter": "",
"save": "",
"select": "",
Expand Down
1 change: 1 addition & 0 deletions translations/de-CH.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"brokenrendering": "Die Kartendarstellung könnte aufgrund eines ungültigen Filterausdrucks fehlerhaft sein",
"cancel": "Abbrechen",
"geomfilter": "Geometrie",
"hidefiltergeom": "Filtergeometrie ausblenden",
"invalidfilter": "Ungültiger Filterausdruck",
"save": "Speichern",
"select": "Auswählen...",
Expand Down
1 change: 1 addition & 0 deletions translations/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"brokenrendering": "Die Kartendarstellung könnte aufgrund eines ungültigen Filterausdrucks fehlerhaft sein",
"cancel": "Abbrechen",
"geomfilter": "Geometrie",
"hidefiltergeom": "",
"invalidfilter": "Ungültiger Filterausdruck",
"save": "Speichern",
"select": "Auswählen...",
Expand Down
1 change: 1 addition & 0 deletions translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"brokenrendering": "Map rendering may be broken due to an invalid filter expression",
"cancel": "Cancel",
"geomfilter": "Geometry",
"hidefiltergeom": "Hide filter geometry",
"invalidfilter": "Invalid filter expression",
"save": "Save",
"select": "Select...",
Expand Down
1 change: 1 addition & 0 deletions translations/es-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"brokenrendering": "",
"cancel": "",
"geomfilter": "",
"hidefiltergeom": "",
"invalidfilter": "",
"save": "",
"select": "",
Expand Down
1 change: 1 addition & 0 deletions translations/fi-FI.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"brokenrendering": "",
"cancel": "",
"geomfilter": "",
"hidefiltergeom": "",
"invalidfilter": "",
"save": "",
"select": "",
Expand Down
1 change: 1 addition & 0 deletions translations/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"brokenrendering": "Le rendu de la carte peut être interrompu à cause d'une expression filtre invalide",
"cancel": "Annuler",
"geomfilter": "Géométrique",
"hidefiltergeom": "Masquer la géométrie du filtre",
"invalidfilter": "Expression de filtre non valide",
"save": "Enregistrer",
"select": "Sélectionner...",
Expand Down
1 change: 1 addition & 0 deletions translations/hu-HU.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"brokenrendering": "",
"cancel": "",
"geomfilter": "",
"hidefiltergeom": "",
"invalidfilter": "",
"save": "",
"select": "",
Expand Down
1 change: 1 addition & 0 deletions translations/it-IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"brokenrendering": "Il rendering della mappa potrebbe essere interrotto a causa di un'espressione filtro invalida",
"cancel": "Annulla",
"geomfilter": "Geometrico",
"hidefiltergeom": "Nascondi geometria filtro",
"invalidfilter": "Espressione filtro non valida",
"save": "Salva",
"select": "Seleziona...",
Expand Down
1 change: 1 addition & 0 deletions translations/no-NO.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"brokenrendering": "",
"cancel": "",
"geomfilter": "",
"hidefiltergeom": "",
"invalidfilter": "",
"save": "",
"select": "",
Expand Down
1 change: 1 addition & 0 deletions translations/pl-PL.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"brokenrendering": "",
"cancel": "",
"geomfilter": "",
"hidefiltergeom": "",
"invalidfilter": "",
"save": "",
"select": "",
Expand Down
1 change: 1 addition & 0 deletions translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"brokenrendering": "",
"cancel": "",
"geomfilter": "",
"hidefiltergeom": "",
"invalidfilter": "",
"save": "",
"select": "",
Expand Down
1 change: 1 addition & 0 deletions translations/pt-PT.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"brokenrendering": "",
"cancel": "",
"geomfilter": "",
"hidefiltergeom": "",
"invalidfilter": "",
"save": "",
"select": "",
Expand Down
1 change: 1 addition & 0 deletions translations/ro-RO.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"brokenrendering": "",
"cancel": "",
"geomfilter": "",
"hidefiltergeom": "",
"invalidfilter": "",
"save": "",
"select": "",
Expand Down
1 change: 1 addition & 0 deletions translations/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"brokenrendering": "",
"cancel": "",
"geomfilter": "",
"hidefiltergeom": "",
"invalidfilter": "",
"save": "",
"select": "",
Expand Down
1 change: 1 addition & 0 deletions translations/sv-SE.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"brokenrendering": "",
"cancel": "",
"geomfilter": "",
"hidefiltergeom": "",
"invalidfilter": "",
"save": "",
"select": "",
Expand Down
1 change: 1 addition & 0 deletions translations/tr-TR.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"brokenrendering": "",
"cancel": "",
"geomfilter": "",
"hidefiltergeom": "",
"invalidfilter": "",
"save": "",
"select": "",
Expand Down
1 change: 1 addition & 0 deletions translations/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@
"mapfilter.brokenrendering",
"mapfilter.cancel",
"mapfilter.geomfilter",
"mapfilter.hidefiltergeom",
"mapfilter.invalidfilter",
"mapfilter.save",
"mapfilter.select",
Expand Down

0 comments on commit c7cba56

Please sign in to comment.