-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathAppHeader.vue
125 lines (110 loc) · 3.71 KB
/
AppHeader.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<template>
<v-app-bar
class="wgu-app-toolbar onprimary--text"
color="primary"
fixed
app
clipped-left
clipped-right
>
<!-- slot to inject components at the beginning (before title) -->
<slot name="wgu-tb-start"></slot>
<v-toolbar-title>{{ $t('app.title') }}</v-toolbar-title>
<!-- slot to inject components after the title text -->
<slot name="wgu-tb-after-title"></slot>
<v-spacer></v-spacer>
<!-- slot to inject components before the auto-generated buttons (by config) -->
<slot name="wgu-tb-before-auto-buttons"></slot>
<template v-for="(tbButton, index) in tbButtons">
<component
:is="tbButton.type" :key="index"
v-bind="tbButton"
/>
</template>
<!-- slot to inject components after the auto-generated buttons (by config) -->
<slot name="wgu-tb-after-auto-buttons"></slot>
<v-menu v-if="menuButtons.length" offset-y nudge-bottom="15">
<template v-slot:activator="{on}">
<v-btn icon v-on="on"
color="onprimary"
:title="$t('wgu-toolbar-menu.title')">
<v-icon medium>menu</v-icon>
</v-btn>
</template>
<v-list color="primary">
<template v-for="(tbButton, index) in menuButtons">
<v-list-item :key="index">
<component
:is="tbButton.type" :key="index"
v-bind="tbButton"
/>
</v-list-item>
</template>
</v-list>
</v-menu>
<!-- slot to inject components at the end of the toolbar (after menu) -->
<slot name="wgu-tb-end"></slot>
</v-app-bar>
</template>
<script>
import Vue from 'vue'
import ToggleButton from '../../src/components/modulecore/ToggleButton'
import ZoomToMaxExtentButton from '../../src/components/maxextentbutton/ZoomToMaxExtentButton'
import Geocoder from '../../src/components/geocoder/Geocoder'
import Geolocator from '../../src/components/geolocator/Geolocator'
import LocaleSwitcher from '../../src/components/localeswitcher/LocaleSwitcher'
import ThemeSwitcher from '../../src/components/themeswitcher/ThemeSwitcher'
export default {
name: 'wgu-app-header',
components: {
'wgu-toggle-btn': ToggleButton,
'wgu-geocoder-btn': Geocoder,
'wgu-zoomtomaxextent-btn': ZoomToMaxExtentButton,
'wgu-geolocator-btn': Geolocator,
'wgu-localeswitcher-btn': LocaleSwitcher,
'wgu-themeswitcher-btn': ThemeSwitcher
},
props: {},
data () {
return {
menuButtons: this.getModuleButtons('menu'),
tbButtons: this.getModuleButtons('toolbar')
}
},
methods: {
/**
* Determines the module button configuration objects from app-config:
* If the module button toggles a window, then a generic wgu-toggle-btn will
* be returned - otherwise the button is custom.
*
* menuButtons: [
* {type: 'wgu-layerlist-toggle-btn'},
* {type: 'wgu-helpwin-toggle-btn'},
* {type: 'wgu-measuretool-toggle-btn'}
* ]
* @param {String} target Either 'menu' or 'toolbar'
* @return {Array} module button configuration objects
*/
getModuleButtons (target) {
const appConfig = Vue.prototype.$appConfig || {};
const modulesConfs = appConfig.modules || {};
let buttons = [];
for (const key of Object.keys(modulesConfs)) {
const moduleOpts = appConfig.modules[key];
if (moduleOpts.target === target) {
buttons.push({
type: moduleOpts.win ? 'wgu-toggle-btn' : key + '-btn',
moduleName: key,
color: 'onprimary',
...moduleOpts
});
}
}
return buttons;
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style>
</style>