Skip to content

Commit 1384026

Browse files
committed
wegue-oss#122 andd ShareButton and fix unit tests
1 parent 7590572 commit 1384026

File tree

7 files changed

+32
-10
lines changed

7 files changed

+32
-10
lines changed

app-starter/components/AppHeader.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import LayerListToggleButton from '../../src/components/layerlist/ToggleButton'
5858
import HelpWinToggleButton from '../../src/components/helpwin/ToggleButton'
5959
import MeasureToolToggleButton from '../../src/components/measuretool/ToggleButton'
6060
import InfoClickButton from '../../src/components/infoclick/ToggleButton'
61-
import ShareButton from '../../src/sharebutton/ShareButton'
61+
import ShareButton from '../../src/components/sharebutton/ShareButton'
6262
import ZoomToMaxExtentButton from '../../src/components/maxextentbutton/ZoomToMaxExtentButton'
6363
import Geocoder from '../../src/components/geocoder/Geocoder'
6464

app-starter/static/app-conf-projected.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"layers": true,
3333
"extent": true,
3434
"paramPrefix": "pl_",
35-
"history": true,
35+
"history": false,
3636
"precision": 6
3737
},
3838

@@ -161,7 +161,10 @@
161161
"wgu-helpwin": {
162162
"target": "toolbar",
163163
"darkLayout": true
164+
},
165+
"wgu-share": {
166+
"target": "toolbar",
167+
"darkLayout": true
164168
}
165169
}
166-
167170
}

app-starter/static/app-conf.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
"mapCenter": [0, 0],
1616

1717
"permalink": {
18-
"location": "search",
18+
"location": "hash",
1919
"layers": true,
2020
"extent": false,
2121
"projection": "EPSG:4326",
2222
"paramPrefix": "",
23-
"history": false
23+
"history": true,
24+
"precision": 6
2425
},
2526

2627
"mapLayers": [

src/components/ol/Map.vue

+12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
import Vue from 'vue';
66
import Map from 'ol/Map'
7+
import Group from 'ol/layer/Group'
78
import View from 'ol/View'
89
import Attribution from 'ol/control/Attribution';
910
import Zoom from 'ol/control/Zoom';
@@ -119,13 +120,24 @@ export default {
119120
this.permalinkController.setup();
120121
}
121122
},
123+
beforeDestroy () {
124+
if (this.$appConfig.permalink) {
125+
this.permalinkController.teardown();
126+
this.permalinkController = undefined;
127+
}
128+
// Remove all Layers from Map.
129+
this.map.setLayerGroup(new Group());
130+
},
122131
123132
methods: {
124133
/**
125134
* Creates the OL layers due to the "mapLayers" array in app config.
126135
* @return {ol.layer.Base[]} Array of OL layer instances
127136
*/
128137
createLayers () {
138+
// Remove all Layers from Map.
139+
this.map.setLayerGroup(new Group());
140+
129141
const me = this;
130142
let layers = [];
131143
const appConfig = this.$appConfig;

src/components/ol/PermalinkController.js

+3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ export default class PermalinkController {
8484
}
8585
});
8686
}
87+
teardown () {
88+
this.unsubscribeLayers();
89+
}
8790

8891
/**
8992
* Subscribe to Layer visibility changes.

src/components/sharebutton/ShareButton.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<v-icon medium>email</v-icon>
3636
</v-list-tile-action>
3737
<v-list-tile-content>
38-
<v-list-tile-title v-html="mailToUrl"/>
38+
<v-list-tile-title><a :href="mailToUrl">{{emailUrlText}}</a></v-list-tile-title>
3939
</v-list-tile-content>
4040
</v-list-tile>
4141
</v-list>
@@ -71,7 +71,7 @@ export default {
7171
copyUrlText: {type: String, required: false, default: 'Copy Hyperlink'},
7272
copyEmbedHtmlText: {type: String, required: false, default: 'Copy HTML Embed Code'},
7373
emailUrlText: {type: String, required: false, default: 'Email Hyperlink'},
74-
emailSubjectText: {type: String, required: false, default: 'NPLH Url Share'}
74+
emailSubjectText: {type: String, required: false, default: 'Wegue Url Share'}
7575
},
7676
data () {
7777
return {
@@ -143,7 +143,7 @@ export default {
143143
try {
144144
const permalinkController = this.map.get('permalinkcontroller');
145145
const url = encodeURIComponent(permalinkController.getShareUrl());
146-
this.mailToUrl = `<a href="mailto:?subject=${this.emailSubjectText}&body=${url}">${this.emailUrlText}</a>`
146+
this.mailToUrl = `mailto:?subject=${this.emailSubjectText}&body=${url}`;
147147
} catch (error) {
148148
this.showAlert(this.alertErrorText);
149149
}
@@ -160,7 +160,7 @@ export default {
160160
</script>
161161

162162
<!-- Add "scoped" attribute to limit CSS to this component only -->
163-
<style>
163+
<style scoped>
164164
.v-alert.wgu-alert {
165165
position: fixed;
166166
top: 5em;

test/unit/specs/components/ol/PermalinkController.spec.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Vue from 'vue';
2-
import { shallowMount } from '@vue/test-utils';
2+
import {enableAutoDestroy, shallowMount} from '@vue/test-utils';
33
import Map from '@/components/ol/Map';
44
import VectorLayer from 'ol/layer/Vector';
55
const permalinkDef = {
@@ -39,6 +39,9 @@ const permalinkDef = {
3939
}
4040
};
4141

42+
// calls wrapper.destroy() after each test
43+
enableAutoDestroy(afterEach);
44+
4245
describe('ol/Map.vue', () => {
4346
describe('data - Map NOT Provides PermalinkController when NOT defined', () => {
4447
let comp;

0 commit comments

Comments
 (0)