-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from chrismayer/refactor-infoclick-win
Refactor InfoClickWin
- Loading branch information
Showing
7 changed files
with
313 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<template> | ||
|
||
<table class="coords" v-if="coordRows" :style="tableStyles"> | ||
<thead> | ||
<tr> | ||
<th v-for="entry in coordRows" | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr v-for="(value, key) in coordRows"> | ||
<td class="key-td"> | ||
{{key}} | ||
</td> | ||
<td class="val-td"> | ||
{{value}} | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
</template> | ||
|
||
<script> | ||
// helper function to detect a CSS color | ||
// Taken from Vuetify sources | ||
// https://github.com/vuetifyjs/vuetify/blob/master/packages/vuetify/src/mixins/colorable.ts | ||
function isCssColor (color) { | ||
return !!color && !!color.match(/^(#|(rgb|hsl)a?\()/) | ||
} | ||
import vColors from 'vuetify/es5/util/colors'; | ||
import {transform} from 'ol/proj.js'; | ||
import {toStringHDMS} from 'ol/coordinate'; | ||
export default { | ||
name: 'wgu-coords-table', | ||
props: { | ||
color: {type: String, required: false, default: 'red darken-3'}, | ||
coordsData: {type: Object}, | ||
showMapPos: {type: Boolean, required: false, default: true}, | ||
showWgsPos: {type: Boolean, required: false, default: true}, | ||
showHdms: {type: Boolean, required: false, default: true} | ||
}, | ||
data: function () { | ||
return { | ||
coordRows: null | ||
} | ||
}, | ||
computed: { | ||
tableStyles () { | ||
// calculate border color of tables due to current color property | ||
let borderColor = this.color; | ||
if (!isCssColor(this.color)) { | ||
let [colorName, colorModifier] = this.color.toString().trim().split(' ', 2); | ||
borderColor = vColors[colorName]; | ||
if (colorModifier) { | ||
colorModifier = colorModifier.replace('-', ''); | ||
borderColor = vColors[colorName][colorModifier]; | ||
} | ||
} | ||
return { | ||
'border': '2px solid ' + borderColor | ||
}; | ||
} | ||
}, | ||
methods: { | ||
}, | ||
watch: { | ||
coordsData () { | ||
const me = this; | ||
const coordinate = me.coordsData.coordinate; | ||
const projection = me.coordsData.projection; | ||
const coordinateWgs84 = transform(coordinate, projection, 'EPSG:4326'); | ||
let coordRows = {}; | ||
if (me.showMapPos) { | ||
// show coordinate in map' SRS | ||
coordRows['MAP PROJ'] = | ||
coordinate[1].toFixed(2) + ' ' + coordinate[0].toFixed(2); | ||
} | ||
if (me.showWgsPos) { | ||
// show coordinate in WGS 84 | ||
const coordinateWgs84 = transform(coordinate, projection, 'EPSG:4326'); | ||
coordRows['WGS 84'] = | ||
coordinateWgs84[1].toFixed(7) + '° ' + coordinateWgs84[0].toFixed(7) + '°' | ||
} | ||
if (me.showHdms) { | ||
// show coordinate in WGS 84 as formatted deegree / min / secs | ||
const hdms = toStringHDMS(coordinateWgs84); | ||
coordRows['HDMS'] = hdms | ||
} | ||
me.coordRows = coordRows; | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<!-- Add "scoped" attribute to limit CSS to this component only --> | ||
<style> | ||
.wgu-infoclick-win table.coords { | ||
margin-top: 12px; | ||
width: 100%; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<template> | ||
|
||
<table v-if="this.properties" :style="tableStyles"> | ||
<thead> | ||
<tr> | ||
<th v-for="entry in properties" | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody class="attr-tbody"> | ||
<tr v-for="(value, key) in properties"> | ||
<td class="key-td"> | ||
{{key}} | ||
</td> | ||
<td class="val-td"> | ||
{{value}} | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
</template> | ||
|
||
<script> | ||
// helper function to detect a CSS color | ||
// Taken from Vuetify sources | ||
// https://github.com/vuetifyjs/vuetify/blob/master/packages/vuetify/src/mixins/colorable.ts | ||
function isCssColor (color) { | ||
return !!color && !!color.match(/^(#|(rgb|hsl)a?\()/) | ||
} | ||
import vColors from 'vuetify/es5/util/colors'; | ||
export default { | ||
name: 'wgu-property-table', | ||
props: { | ||
color: {type: String, required: false, default: 'red darken-3'}, | ||
properties: {type: Object} | ||
}, | ||
computed: { | ||
tableStyles () { | ||
// calculate border color of tables due to current color property | ||
let borderColor = this.color; | ||
if (!isCssColor(this.color)) { | ||
let [colorName, colorModifier] = this.color.toString().trim().split(' ', 2); | ||
borderColor = vColors[colorName]; | ||
if (colorModifier) { | ||
colorModifier = colorModifier.replace('-', ''); | ||
borderColor = vColors[colorName][colorModifier]; | ||
} | ||
} | ||
return { | ||
'border': '2px solid ' + borderColor | ||
}; | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<!-- Add "scoped" attribute to limit CSS to this component only --> | ||
<style> | ||
</style> |
Oops, something went wrong.