Skip to content

Commit 5686fce

Browse files
authored
Merge branch 'main' into refactor/multiple-diplan-clients
2 parents a4b7f08 + 0531076 commit 5686fce

File tree

9 files changed

+104
-22
lines changed

9 files changed

+104
-22
lines changed

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
"pages:build:serve": "http-server pages -o index.html",
4545
"clean": "nx reset && rimraf --glob packages/**/{.cache,dist,docs} && rimraf --glob {.cache,dist} && node ./scripts/clean",
4646
"docs:afm": "tsx ./scripts/makeDocs afm",
47-
"docs:bgw": "tsx ./scripts/makeDocs bgw",
4847
"docs:diplan": "npm run diplan:build && cp -r ./packages/clients/diplan/dist ./packages/clients/diplan/example ./packages/clients/diplan/docs",
4948
"docs:generic": "tsx ./scripts/makeDocs generic",
5049
"docs:meldemichel": "tsx ./scripts/makeDocs meldemichel && npm run meldemichel:build && cp -r ./packages/clients/meldemichel/dist ./packages/clients/meldemichel/example ./packages/clients/meldemichel/docs",

packages/clients/bgw/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Usage as a HTML page is simply offered by hosting the client package with the in
1515
| fieldName | type | description |
1616
| - | - | - |
1717
| 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`. |
18+
| highlightStyleBadestraende | highlightStyleBadestraende? | Highlight style for the layer 'Badestraende'. |
1819

1920
### Example configuration:
2021

@@ -29,4 +30,21 @@ infoFields: [
2930
{ key: 'bgw_laenge_bgw', label: 'Länge Uferlinie (m)'},
3031
{ key: 'bgw_umfeld', label: 'Umfeld (m)' },
3132
],
33+
highlightStyleBadestraende: {
34+
stroke: { color: '#FF4500', width: 10 },
35+
}
36+
```
37+
38+
### gfi.highlightStyleBadestraende
39+
40+
| fieldName | type | description |
41+
| - | - | - |
42+
| stroke | stroke | Stroke style for the layer 'Badestraende'. Please see example below for styling options. |
43+
44+
#### Example configuration:
45+
46+
```js
47+
highlightStyleBadestraende: {
48+
stroke: { color: '#FF4500', width: 10 },
49+
}
3250
```

packages/clients/bgw/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
},
1515
"files": [
1616
"dist/**/**.*",
17-
"docs/**/**.*",
1817
"CHANGELOG.md",
1918
"README.md"
2019
],
@@ -45,6 +44,7 @@
4544
"@repositoryname/vuex-generators": "^1.1.2",
4645
"vue": "^2.x",
4746
"vuex": "^3.x",
47+
"ol": "^10.3.1",
4848
"lodash.merge": "^4.6.2"
4949
},
5050
"nx": {

packages/clients/bgw/src/mapConfiguration.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ const mapConfig = {
250250
},
251251
{ key: 'bgw_umfeld', label: 'plugins.gfi.infoLabels.bgw_umfeld' },
252252
],
253+
highlightStyleBadestraende: {
254+
stroke: { color: '#FF4500', width: 10 },
255+
},
253256
},
254257
featureStyles: './style.json',
255258
}

packages/clients/bgw/src/plugins/Gfi/Content.vue

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
<template>
2-
<v-card
3-
v-if="infoFields.length > 0 && currentProperties"
4-
class="bgw-gfi-content"
5-
>
2+
<v-card v-if="info.length > 0 && currentProperties" class="bgw-gfi-content">
63
<v-card-actions v-if="!hasWindowSize || !hasSmallWidth">
74
<v-spacer></v-spacer>
85
<v-btn
@@ -39,22 +36,16 @@ import ActionButton from './ActionButton.vue'
3936
export default Vue.extend({
4037
name: 'BgwGfiContent',
4138
components: { ActionButton },
42-
data: () => ({
43-
infoFields: [],
44-
}),
4539
computed: {
46-
...mapGetters(['map', 'configuration']),
40+
...mapGetters([
41+
'map',
42+
'configuration',
43+
'selected',
44+
'hasSmallWidth',
45+
'hasWindowSize',
46+
]),
4747
...mapGetters('plugin/gfi', ['currentProperties']),
48-
...mapGetters(['hasSmallWidth', 'hasWindowSize']),
49-
info(): Array<string[]> {
50-
return this.infoFields.map(({ key, label }) => [
51-
label,
52-
this.currentProperties[key],
53-
])
54-
},
55-
},
56-
mounted() {
57-
this.infoFields = this.configuration.gfi.infoFields
48+
...mapGetters('bgw', ['info']),
5849
},
5950
methods: {
6051
...mapActions('plugin/gfi', ['close']),

packages/clients/bgw/src/polar-client.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import packageInfo from '../package.json'
33
import addPlugins from './addPlugins'
44
import services from './services'
55
import mapConfiguration from './mapConfiguration'
6+
import bgwModule from './store/module'
67

78
// eslint-disable-next-line no-console
89
console.info(`@polar/client-bgw: running in v${packageInfo.version}.`)
@@ -13,13 +14,16 @@ addPlugins(client)
1314
async function initializeClient() {
1415
client.rawLayerList.initializeLayerList(services)
1516

16-
await client.createMap({
17+
const clientInstance = await client.createMap({
1718
containerId,
1819
mapConfiguration: {
1920
...mapConfiguration,
2021
layerConf: services,
2122
},
2223
})
24+
25+
clientInstance.$store.registerModule('bgw', bgwModule)
26+
clientInstance.$store.dispatch('bgw/setupModule')
2327
}
2428

2529
initializeClient()
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { PolarModule } from '@polar/lib-custom-types'
2+
import { Stroke, Style } from 'ol/style'
3+
4+
interface BgwGetters {
5+
info: string[][]
6+
highlightStyle: Style
7+
}
8+
9+
/*
10+
* BGW VueX Store Module
11+
*/
12+
const bgwModule: PolarModule<Record<string, never>, BgwGetters> = {
13+
namespaced: true,
14+
state: {},
15+
actions: {
16+
setupModule({ rootGetters, dispatch }) {
17+
this.watch(
18+
() => rootGetters['plugin/gfi/currentProperties'],
19+
() => dispatch('updateFeatures'),
20+
{ deep: true }
21+
)
22+
},
23+
// handles style side effects
24+
updateFeatures({ rootGetters, getters }) {
25+
const currentProperties = rootGetters['plugin/gfi/currentProperties']
26+
27+
const features = rootGetters.map
28+
.getLayers()
29+
.getArray()
30+
.find((layer) => layer.get('id') === '14001')
31+
// @ts-expect-error | it exists on its deviations
32+
?.getSource()
33+
.getFeatures()
34+
35+
features.forEach((feature) =>
36+
feature.setStyle(
37+
feature.get('BATHINGWAT') === currentProperties.fid
38+
? getters.highlightStyle
39+
: undefined
40+
)
41+
)
42+
},
43+
},
44+
mutations: {},
45+
getters: {
46+
info(_, __, ___, rootGetters) {
47+
// @ts-expect-error | local piggyback
48+
return (rootGetters.configuration.gfi?.infoFields || []).map(
49+
({ key, label }) => [
50+
label,
51+
rootGetters['plugin/gfi/currentProperties'][key],
52+
]
53+
)
54+
},
55+
highlightStyle(_, __, ___, rootGetters) {
56+
return new Style({
57+
stroke: new Stroke(
58+
// @ts-expect-error | local piggyback
59+
rootGetters.configuration.gfi?.highlightStyleBadestraende.stroke
60+
),
61+
})
62+
},
63+
},
64+
}
65+
66+
export default bgwModule

scripts/buildPages.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
array=( afm bgw diplan generic meldemichel snowbox textLocator )
1+
array=( afm diplan generic meldemichel snowbox textLocator )
22
for i in "${array[@]}"
33
do
44
echo "Building $i docs ..."

0 commit comments

Comments
 (0)