Skip to content

Commit

Permalink
Layer selection in identifyViewer.jsx (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
cazitouni authored Dec 19, 2024
1 parent 4298bc5 commit 218c114
Show file tree
Hide file tree
Showing 21 changed files with 75 additions and 8 deletions.
35 changes: 27 additions & 8 deletions components/IdentifyViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ class IdentifyViewer extends React.Component {
currentLayer: null,
exportFormat: 'geojson',
selectedAggregatedReport: null,
generatingReport: false
generatingReport: false,
selectedLayer: ''
};
constructor(props) {
super(props);
Expand Down Expand Up @@ -241,8 +242,10 @@ class IdentifyViewer extends React.Component {
};
setHighlightedResults = (results, resultTree) => {
if (!results && this.props.highlightAllResults) {
const selectedLayer = this.state.selectedLayer || '';
results = Object.keys(resultTree).reduce((res, layer) => {
return res.concat(resultTree[layer].map(result => ({...result, id: layer + "." + result.id})));
const layerData = resultTree[selectedLayer || layer];
return res.concat(layerData.map(result => ({ ...result, id: `${selectedLayer || layer}.${result.id}` })));
}, []);
}
results = (results || []).filter(result => result.type.toLowerCase() === "feature").map(feature => {
Expand Down Expand Up @@ -302,15 +305,17 @@ class IdentifyViewer extends React.Component {
if (isEmpty(newResultTree[layer])) {
delete newResultTree[layer];
}
const selectedLayer = isEmpty(newResultTree[layer]) ? '' : state.selectedLayer;
return {
resultTree: newResultTree,
currentResult: state.currentResult === result ? null : state.currentResult
currentResult: state.currentResult === result ? null : state.currentResult,
selectedLayer: selectedLayer
};
});
};
exportResults = (clipboard = false) => {
const filteredResults = {};
Object.keys(this.state.resultTree).map(key => {
Object.keys(this.state.selectedLayer !== '' ? { [this.state.selectedLayer]: this.state.resultTree[this.state.selectedLayer] } : this.state.resultTree).map(key => {
if (!isEmpty(this.state.resultTree[key])) {
filteredResults[key] = this.state.resultTree[key];
}
Expand Down Expand Up @@ -525,20 +530,34 @@ class IdentifyViewer extends React.Component {
} else {
body = (
<div className="identify-flat-results-list">
{Object.keys(this.state.resultTree).map(layer => {
<div className="identify-selectbox">
<select className="identify-layer-select" onChange={(e) => {const selectedLayer = e.target.value; this.setState({ selectedLayer });}}>
<option value=''>{LocaleUtils.tr("identify.layerall")}</option>
{Object.keys(this.state.resultTree).sort().map(
layer => (
<option key={layer} value={layer}>
{layer}
</option>
))}
</select>
<span className="identify-buttonbox-spacer" />
<span>{LocaleUtils.tr("identify.featurecount")}: {Object.values(this.state.resultTree || {}).flat().length}</span>
</div>
{Object.keys(this.state.selectedLayer !== '' ? { [this.state.selectedLayer]: this.state.resultTree[this.state.selectedLayer] } : this.state.resultTree).map(layer => {
const layerResults = this.state.resultTree[layer];
return layerResults.map(result => {
const resultClass = this.state.currentResult === result ? 'identify-result-frame-highlighted' : 'identify-result-frame-normal';
return (
<div key={result.id}
onMouseEnter={() => this.setState({currentResult: result, currentLayer: layer})}
onMouseLeave={() => this.setState({currentResult: null, currentLayer: null})}
onMouseEnter={() => this.setState({ currentResult: result, currentLayer: layer })}
onMouseLeave={() => this.setState({ currentResult: null, currentLayer: null })}
>
{this.renderResultAttributes(layer, result, resultClass, reportFeatures)}
</div>
);
});
})}
})
}
</div>
);
}
Expand Down
10 changes: 10 additions & 0 deletions components/style/IdentifyViewer.css
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,16 @@ div.identify-body div.identify-buttonbox {
align-items: center;
}

div.identify-body div.identify-selectbox {
flex: 0 0 auto;
display: flex;
align-items: center;
}

select:focus {
outline: none;
}

div.identify-body table.identify-attr-subtable {
width: 100%;
}
Expand Down
2 changes: 2 additions & 0 deletions translations/ca-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
"export": "Exportar",
"exportformat": "Exportar format",
"featureReport": "Informe d'element",
"featurecount": "",
"layerall": "",
"link": "Link",
"noattributes": "Sense atributs",
"noresults": "Sense informació disponible sobre el punt seleccionat",
Expand Down
2 changes: 2 additions & 0 deletions translations/cs-CZ.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
"export": "Exportovat",
"exportformat": "Formát exportu",
"featureReport": "Report prvku",
"featurecount": "",
"layerall": "",
"link": "Odkaz",
"noattributes": "Bez atributů",
"noresults": "V tomto bodu nejsou k dispozici informace o žádném prvku",
Expand Down
2 changes: 2 additions & 0 deletions translations/de-CH.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
"export": "Exportieren",
"exportformat": "Exportformat",
"featureReport": "Objektblatt",
"featurecount": "",
"layerall": "",
"link": "Link",
"noattributes": "Keine Attribute",
"noresults": "Keine Resultate an der ausgewählten Position",
Expand Down
2 changes: 2 additions & 0 deletions translations/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
"export": "Exportieren",
"exportformat": "Exportformat",
"featureReport": "Objektblatt",
"featurecount": "",
"layerall": "",
"link": "Link",
"noattributes": "Keine Attribute",
"noresults": "Keine Resultate an der ausgewählten Position",
Expand Down
2 changes: 2 additions & 0 deletions translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
"export": "Export",
"exportformat": "Export format:",
"featureReport": "Feature report",
"featurecount": "Feature count",
"layerall": "All layers",
"link": "Link",
"noattributes": "No attributes",
"noresults": "No information available for the selected point",
Expand Down
2 changes: 2 additions & 0 deletions translations/es-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
"export": "Exportar",
"exportformat": "Exportar formato",
"featureReport": "Informe del elemento",
"featurecount": "",
"layerall": "",
"link": "Link",
"noattributes": "Sin atributos",
"noresults": "Sin información disponible sobre el punto seleccionado",
Expand Down
2 changes: 2 additions & 0 deletions translations/fi-FI.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
"export": "Vienti",
"exportformat": "Viennin formaatti:",
"featureReport": "Ominaisuustietoraportti",
"featurecount": "",
"layerall": "",
"link": "Linkki",
"noattributes": "Attribuutteja ei löytynyt",
"noresults": "Valitulla pisteellä ei ole informaatiota",
Expand Down
2 changes: 2 additions & 0 deletions translations/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
"export": "Exporter",
"exportformat": "Format d'export:",
"featureReport": "Données de l'objet",
"featurecount": "Éléments sélectionnés",
"layerall": "Toutes les couches",
"link": "Lien",
"noattributes": "Pas d'attribut",
"noresults": "Pas de résultats pour la position sélectionnée",
Expand Down
2 changes: 2 additions & 0 deletions translations/hu-HU.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
"export": "Exportálás",
"exportformat": "",
"featureReport": "Lekérdezés eredménye",
"featurecount": "",
"layerall": "",
"link": "Link",
"noattributes": "",
"noresults": "Nincs információ a kiválasztott pontról",
Expand Down
2 changes: 2 additions & 0 deletions translations/it-IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
"export": "Esporta",
"exportformat": "Formato d'esportazione",
"featureReport": "Oggetto formulario",
"featurecount": "",
"layerall": "",
"link": "Link",
"noattributes": "Nessun attributo",
"noresults": "Nessun risultato",
Expand Down
2 changes: 2 additions & 0 deletions translations/no-NO.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
"export": "Eksporter",
"exportformat": "",
"featureReport": "Objektrapport",
"featurecount": "",
"layerall": "",
"link": "Lenke",
"noattributes": "Ingen attributt",
"noresults": "Ingen informasjon for valgt punkt",
Expand Down
2 changes: 2 additions & 0 deletions translations/pl-PL.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
"export": "Eksport",
"exportformat": "",
"featureReport": "Feature report",
"featurecount": "",
"layerall": "",
"link": "Link",
"noattributes": "Brak atrybutów",
"noresults": "Brak dostępnych danych dla wybranego punktu",
Expand Down
2 changes: 2 additions & 0 deletions translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
"export": "Exportação",
"exportformat": "Formato de exportação",
"featureReport": "Relatório de recurso",
"featurecount": "",
"layerall": "",
"link": "Link",
"noattributes": "Sem atributos",
"noresults": "Nenhuma informação disponível para o ponto selecionado",
Expand Down
2 changes: 2 additions & 0 deletions translations/pt-PT.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
"export": "Exportar",
"exportformat": "Formato de Exportação",
"featureReport": "Relatório de Recurso",
"featurecount": "",
"layerall": "",
"link": "Link",
"noattributes": "Sem Atributos",
"noresults": "Nenhuma informação disponível para o ponto selecionado",
Expand Down
2 changes: 2 additions & 0 deletions translations/ro-RO.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
"export": "Export",
"exportformat": "Formatul de export:",
"featureReport": "Raport obiect spațial",
"featurecount": "",
"layerall": "",
"link": "Link",
"noattributes": "Fără atribute",
"noresults": "Nu există informații în punctul selectat",
Expand Down
2 changes: 2 additions & 0 deletions translations/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
"export": "Экспорт",
"exportformat": "",
"featureReport": "Отчёт об объекте",
"featurecount": "",
"layerall": "",
"link": "гиперссылка",
"noattributes": "Аттрибуты отсутствуют",
"noresults": "Для выбранной точки нет доступной информации",
Expand Down
2 changes: 2 additions & 0 deletions translations/sv-SE.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
"export": "Exportera",
"exportformat": "",
"featureReport": "Objektrapport",
"featurecount": "",
"layerall": "",
"link": "Länk",
"noattributes": "Inga attribut",
"noresults": "Ingen information för vald punkt",
Expand Down
2 changes: 2 additions & 0 deletions translations/tr-TR.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
"export": "Dışarıya aktar",
"exportformat": "Dışarı aktarma formatı:",
"featureReport": "Obje raporu",
"featurecount": "",
"layerall": "",
"link": "Bağlantı",
"noattributes": "Öznitelik yok",
"noresults": "Seçilen nokta için geçerli bilgi yok",
Expand Down
2 changes: 2 additions & 0 deletions translations/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@
"identify.export",
"identify.exportformat",
"identify.featureReport",
"identify.featurecount",
"identify.layerall",
"identify.link",
"identify.noattributes",
"identify.noresults",
Expand Down

0 comments on commit 218c114

Please sign in to comment.