Skip to content

Commit

Permalink
#107 dataList -> dataset, initConf fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sookoll committed May 29, 2020
1 parent 1f987fe commit 7914ecc
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 52 deletions.
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/geop/components/geocache/GeocacheInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class GeocacheInfo extends Component {
// click on coords
this.$.on('click', el, e => {
e.preventDefault()
this.mapCoordinates(e.target.dataList.coordinates, e.target.textContent)
this.mapCoordinates(e.target.dataset.coordinates, e.target.textContent)
})
})
}
Expand Down
6 changes: 3 additions & 3 deletions src/geop/components/geocache/Geotrip.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,14 @@ class Geotrip extends Component {
this.$.get('li button.close', this.el, true).forEach(el => {
this.$.on('click', el, e => {
e.preventDefault()
this.remove(e.currentTarget.closest('li').dataList.id)
this.remove(e.currentTarget.closest('li').dataset.id)
})
})
// zoom to
this.$.get('li a', this.el, true).forEach(el => {
this.$.on('click', el, e => {
e.preventDefault()
this.zoomTo(e.currentTarget.closest('li').dataList.id)
this.zoomTo(e.currentTarget.closest('li').dataset.id)
})
})
// clear trip
Expand Down Expand Up @@ -244,7 +244,7 @@ class Geotrip extends Component {
reorderTrip () {
const order = []
this.$.get('li.sort-item', this.el).forEach(el => {
order.push(el.dataList.id)
order.push(el.dataset.id)
})
this.reorderCollection(this.state.collection, order)
}
Expand Down
18 changes: 9 additions & 9 deletions src/geop/components/layer/LayerManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class LayerManager extends Component {
this.$.on('click', el, e => {
e.preventDefault()
e.stopPropagation()
const id = e.currentTarget.closest('li').dataList.id
const id = e.currentTarget.closest('li').dataset.id
if (this.state.activeBaseLayer && id === this.state.activeBaseLayer.get('id')) {
this.toggleLayer('base', id)
} else {
Expand All @@ -147,7 +147,7 @@ class LayerManager extends Component {
this.$.on('click', el, e => {
e.preventDefault()
e.stopPropagation()
const data = e.currentTarget.closest('li').dataList
const data = e.currentTarget.closest('li').dataset
this.toggleLayer(data.group, data.id)
})
})
Expand All @@ -161,21 +161,21 @@ class LayerManager extends Component {
this.$.on('click', el, e => {
e.preventDefault()
e.stopPropagation()
const data = e.currentTarget.closest('li').dataList
const data = e.currentTarget.closest('li').dataset
this.fitTo(data.group, data.id)
})
})
this.$.get('a.remove-layer', ul, true).forEach(el => {
this.$.on('click', el, e => {
e.preventDefault()
e.stopPropagation()
const data = e.currentTarget.closest('li').dataList
const data = e.currentTarget.closest('li').dataset
this.removeLayer(data.group, data.id)
})
})
this.$.get('input[type=color]', ul, true).forEach(el => {
this.$.on('change', el, e => {
const data = e.currentTarget.closest('li').dataList
const data = e.currentTarget.closest('li').dataset
this.setLayerColor(data.group, data.id)
this.$.get('.dot', e.currentTarget.closest('.color')).css({ background: e.target.value })
})
Expand All @@ -192,9 +192,9 @@ class LayerManager extends Component {
this.$.on('click', el, e => {
e.preventDefault()
e.stopPropagation()
const data = e.currentTarget.closest('li').dataList
const data = e.currentTarget.closest('li').dataset
const url = this.getWMSUrl(data.group, data.id)
const target = this.$.get(e.currentTarget.dataList.target)
const target = this.$.get(e.currentTarget.dataset.target)
if (url) {
// FIXME
// $($(e.currentTarget).data('target')).modal()
Expand Down Expand Up @@ -333,8 +333,8 @@ class LayerManager extends Component {

reorderLayers (e) {
if (e.oldDraggableIndex !== e.newDraggableIndex) {
const layerId = e.item.dataList.id
const groupId = e.item.dataList.group
const layerId = e.item.dataset.id
const groupId = e.item.dataset.group
this.state[groupId].forEach(layer => {
if (layer.get('id') === layerId) {
// store reordering state
Expand Down
2 changes: 1 addition & 1 deletion src/geop/components/mouseposition/MousePosition.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class MousePosition extends Component {
})
this.$.get('a[data-format]', this.el, true).forEach(el => {
this.$.on('click', el, e => {
this.state.format = e.currentTarget.dataList.format
this.state.format = e.currentTarget.dataset.format
setState('map/coordinateFormat', this.state.format, true)
this.state.control.setProjection(coordFormats[this.state.format].projection)
this.state.control.setCoordinateFormat(coordFormats[this.state.format].coordinateFormat)
Expand Down
2 changes: 1 addition & 1 deletion src/geop/components/search/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class Search extends Component {
e.preventDefault()
e.stopPropagation()
const map = getState('map')
const id = e.currentTarget.dataList.id
const id = e.currentTarget.dataset.id
const item = this.state.results.filter(item => {
return String(id) === String(item.id)
})[0]
Expand Down
14 changes: 7 additions & 7 deletions src/geop/components/settings/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class Config extends Component {
// language change
this.$.get('button.set-locale-btn', this.el, true).forEach(el => {
this.$.on('click', el, e => {
changeLocale(e.currentTarget.dataList.locale)
changeLocale(e.currentTarget.dataset.locale)
this.$.get('button.set-locale-btn', this.el, true).forEach(elem => {
elem.classList.remove('active')
})
Expand All @@ -191,7 +191,7 @@ class Config extends Component {
reloadApp()
})
if (getState('app/debug')) {
console.debug(`Config.render: Locale changed to ${e.currentTarget.dataList.locale}`)
console.debug(`Config.render: Locale changed to ${e.currentTarget.dataset.locale}`)
}
})
})
Expand Down Expand Up @@ -230,7 +230,7 @@ class Config extends Component {
// routing
this.$.get('button.set-locale-btn', this.el, true).forEach(el => {
this.$.on('click', el, e => {
setState('routing/infoFromRoute', e.currentTarget.dataList.share === 'on', true)
setState('routing/infoFromRoute', e.currentTarget.dataset.share === 'on', true)
this.$.get('button.set-locale-btn', this.el, true).forEach(elem => {
elem.classList.remove('active')
})
Expand All @@ -240,7 +240,7 @@ class Config extends Component {
// cache import
this.$.get('button.set-cacheimport-btn', this.el, true).forEach(el => {
this.$.on('click', el, e => {
setState('cache/import/appendLayer', e.currentTarget.dataList.import === 'append', true)
setState('cache/import/appendLayer', e.currentTarget.dataset.import === 'append', true)
this.$.get('button.set-cacheimport-btn', this.el, true).forEach(elem => {
elem.classList.remove('active')
})
Expand All @@ -250,7 +250,7 @@ class Config extends Component {
// share change
this.$.get('button.set-share-btn', this.el, true).forEach(el => {
this.$.on('click', el, e => {
setState('app/shareOnlyTripFeatures', e.currentTarget.dataList.share === 'on', true)
setState('app/shareOnlyTripFeatures', e.currentTarget.dataset.share === 'on', true)
this.$.get('button.set-share-btn', this.el, true).forEach(elem => {
elem.classList.remove('active')
})
Expand All @@ -271,7 +271,7 @@ class Config extends Component {
// debug change
this.$.get('button.set-debug-btn', this.el, true).forEach(el => {
this.$.on('click', el, e => {
setState('app/debug', e.currentTarget.dataList.debug === 'on', true)
setState('app/debug', e.currentTarget.dataset.debug === 'on', true)
this.$.get('button.set-debug-btn', this.el, true).forEach(elem => {
elem.classList.remove('active')
})
Expand All @@ -280,7 +280,7 @@ class Config extends Component {
reloadApp()
})
if (getState('app/debug')) {
console.debug(`Config.render: Debug changed to ${e.currentTarget.dataList.debug}`)
console.debug(`Config.render: Debug changed to ${e.currentTarget.dataset.debug}`)
}
})
})
Expand Down
2 changes: 1 addition & 1 deletion src/geop/components/statusbar/StatusBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class StatusBar extends Component {
this.toggleMobileVisible(this.state.visibleMobile)
this.$.get('#screen a[data-visible]', this.el, true).forEach(el => {
this.$.on('click', el, e => {
this.toggleMobileVisible(e.currentTarget.dataList.visible)
this.toggleMobileVisible(e.currentTarget.dataset.visible)
})
})
}
Expand Down
28 changes: 13 additions & 15 deletions src/geop/utilities/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@ import { getBookmarkState } from 'Components/bookmark/Bookmark'
/**
* Init conf - merge static conf with saved store
*/
export function initConf () {
export async function initConf () {
const conf = {}
const permalink = getPermalink('b')
let storageState
let bookmarkState
try {
storageState = await getAppState()
bookmarkState = permalink && permalink.length
? await getBookmarkState(permalink) : {}
} catch (e) {
storageState = {}
bookmarkState = {}
}
return new Promise((resolve, reject) => {
const conf = {}
const permalink = getPermalink('b')
let storageState
let bookmarkState
try {
// storageState = await getAppState()
storageState = Promise.resolve(() => getAppState())
// bookmarkState = permalink && permalink.length
// ? await getBookmarkState(permalink) : {}
bookmarkState = Promise.resolve(() => getBookmarkState(permalink))
} catch (e) {
storageState = {}
bookmarkState = {}
}
Object.keys(appConf).forEach(key => {
conf['app/' + key] = appConf[key]
})
Expand Down

0 comments on commit 7914ecc

Please sign in to comment.