Skip to content

Commit

Permalink
Merge pull request #248 from Dataport/feature/add-download-button-in-…
Browse files Browse the repository at this point in the history
…bgw-gfi

Feature/add download button in bgw gfi
  • Loading branch information
jedi-of-the-sea authored Feb 25, 2025
2 parents 46439af + 4ad15f4 commit e960ad2
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 11 deletions.
21 changes: 21 additions & 0 deletions packages/clients/bgw/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,24 @@ Please see the `CHANGELOG.md` for all changes after the initial release.
## Usage

Usage as a HTML page is simply offered by hosting the client package with the included .html file.

## Client specific gfi configuration

| fieldName | type | description |
| - | - | - |
| infoFields | object[] | Array of key-label pair objects. The property of the feature that should be displayed has to be set as `key`. The description of this property has to be set as `label`. |

### Example configuration:

```js
infoFields: [
{ key: 'fid', label: 'Id' },
{ key: 'ort', label: 'Ort' },
{ key: 'bgw_kreis', label: 'Kreis' },
{ key: 'bgw_gwkategory', label: 'Kategorie' },
{ key: 'bgw_laenge', label: 'geographische Länge' },
{ key: 'bgw_breite', label: 'geographische Breite' },
{ key: 'bgw_laenge_bgw', label: 'Länge Uferlinie (m)'},
{ key: 'bgw_umfeld', label: 'Umfeld (m)' },
],
```
2 changes: 2 additions & 0 deletions packages/clients/bgw/src/addPlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Scale from '@polar/plugin-scale'
import Toast from '@polar/plugin-toast'
import Zoom from '@polar/plugin-zoom'
import merge from 'lodash.merge'
import BgwGfiContent from './plugins/Gfi/Content.vue'
import {
badestellenSearch,
badestellenSearchResult,
Expand Down Expand Up @@ -45,6 +46,7 @@ export default (core) => {
plugin: Gfi({
layers: {},
renderType: 'iconMenu',
gfiContentComponent: BgwGfiContent,
activeLayerPath: 'plugin/layerChooser/activeMaskIds',
coordinateSources: ['plugin/addressSearch/chosenAddress'],
}),
Expand Down
45 changes: 34 additions & 11 deletions packages/clients/bgw/src/mapConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,23 @@ const mapConfig = {
},
},
},
gfi: {
button: {
details: 'Details der Badestelle',
},
infoLabels: {
fid: 'EU-IRD',
name: 'Name',
ort: 'Gemeinde',
bgw_kreis: 'Kreis',
bgw_kategory: 'Kategorie',
bgw_gwkategory: 'Gewässerkategorie',
bgw_laenge: 'geographische Länge',
bgw_breite: 'geographische Breite',
bgw_laenge_bgw: 'Länge Uferlinie (m)',
bgw_umfeld: 'Umfeld (m)',
},
},
},
},
},
Expand Down Expand Up @@ -204,17 +221,6 @@ const mapConfig = {
14003: {
window: true,
geometry: false,
properties: {
bgw_name: 'Name',
fid: 'EU-IRD',
ort: 'Gemeinde',
bgw_kreis: 'Kreis',
bgw_gwkategory: 'Gewässerkategorie',
bgw_laenge: 'geographische Länge',
bgw_breite: 'geographische Breite',
bgw_laenge_bgw: 'Länge Uferlinie (m)',
bgw_umfeld: 'Umfeld (Infrastruktur)',
},
showTooltip: (feature) =>
feature.get('features').length > 1
? [
Expand All @@ -227,6 +233,23 @@ const mapConfig = {
],
},
},
// client specific gfi configuration. See Readme for more information
infoFields: [
{ key: 'fid', label: 'plugins.gfi.infoLabels.fid' },
{ key: 'ort', label: 'plugins.gfi.infoLabels.ort' },
{ key: 'bgw_kreis', label: 'plugins.gfi.infoLabels.bgw_kreis' },
{
key: 'bgw_gwkategory',
label: 'plugins.gfi.infoLabels.bgw_gwkategory',
},
{ key: 'bgw_laenge', label: 'plugins.gfi.infoLabels.bgw_laenge' },
{ key: 'bgw_breite', label: 'plugins.gfi.infoLabels.bgw_breite' },
{
key: 'bgw_laenge_bgw',
label: 'plugins.gfi.infoLabels.bgw_laenge_bgw',
},
{ key: 'bgw_umfeld', label: 'plugins.gfi.infoLabels.bgw_umfeld' },
],
},
featureStyles: './style.json',
}
Expand Down
37 changes: 37 additions & 0 deletions packages/clients/bgw/src/plugins/Gfi/ActionButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<template>
<v-btn
class="text-none bgw-link-button"
text
:href="link"
target="_blank"
:title="$t('plugins.gfi.button.details')"
:aria-label="$t('plugins.gfi.button.details')"
onmousedown="return false"
>
{{ $t('plugins.gfi.button.details') }}
</v-btn>
</template>

<script lang="ts">
import Vue from 'vue'
import { mapGetters } from 'vuex'
export default Vue.extend({
name: 'ActionButton',
computed: {
...mapGetters('plugin/gfi', ['currentProperties']),
link() {
return `https://www.schleswig-holstein.de/DE/fachinhalte/B/badegewaesser/DarstellungBadestelle.html#bgst=${this.currentProperties.fid}`
},
},
})
</script>
<style lang="scss" scoped>
.bgw-link-button {
margin-right: 0.4em;
margin-top: 0.5em;
box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.2), 0 4px 5px 0 rgba(0, 0, 0, 0.14),
0 1px 10px 0 rgba(0, 0, 0, 0.12);
border: 3px solid transparent;
}
</style>
71 changes: 71 additions & 0 deletions packages/clients/bgw/src/plugins/Gfi/Content.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<template>
<v-card
v-if="infoFields.length > 0 && currentProperties"
class="bgw-gfi-content"
>
<v-card-actions v-if="!hasWindowSize || !hasSmallWidth">
<v-spacer></v-spacer>
<v-btn
icon
small
:aria-label="$t('plugins.gfi.header.close')"
@click="close(true)"
>
<v-icon small>fa-xmark</v-icon>
</v-btn>
</v-card-actions>
<v-card-title class="bgw-gfi-title">
{{ currentProperties.bgw_name }}
</v-card-title>
<v-card-text>
<v-simple-table dense>
<tbody>
<tr v-for="item in info" :key="item[0]">
<td>{{ $t(item[0]) }}</td>
<td>{{ item[1] }}</td>
</tr>
</tbody>
</v-simple-table>
<ActionButton></ActionButton>
</v-card-text>
</v-card>
</template>

<script lang="ts">
import Vue from 'vue'
import { mapActions, mapGetters } from 'vuex'
import ActionButton from './ActionButton.vue'
export default Vue.extend({
name: 'BgwGfiContent',
components: { ActionButton },
data: () => ({
infoFields: [],
}),
computed: {
...mapGetters(['map', 'configuration']),
...mapGetters('plugin/gfi', ['currentProperties']),
...mapGetters(['hasSmallWidth', 'hasWindowSize']),
info(): Array<string[]> {
return this.infoFields.map(({ key, label }) => [
label,
this.currentProperties[key],
])
},
},
mounted() {
this.infoFields = this.configuration.gfi.infoFields
},
methods: {
...mapActions('plugin/gfi', ['close']),
},
})
</script>

<style lang="scss" scoped>
.bgw-gfi-title {
word-break: break-word;
font-size: medium;
font-weight: bold;
}
</style>

0 comments on commit e960ad2

Please sign in to comment.