Add share_status in edit toolbar
This commit is contained in:
parent
a74439ac47
commit
4e606d81bc
3 changed files with 27 additions and 9 deletions
|
@ -67,13 +67,11 @@ L.U.Map.include({
|
||||||
initialize: function (el, geojson) {
|
initialize: function (el, geojson) {
|
||||||
// Locale name (pt_PT, en_US…)
|
// Locale name (pt_PT, en_US…)
|
||||||
// To be used for Django localization
|
// To be used for Django localization
|
||||||
if (geojson.properties.locale)
|
if (geojson.properties.locale) L.setLocale(geojson.properties.locale)
|
||||||
L.setLocale(geojson.properties.locale)
|
|
||||||
|
|
||||||
// Language code (pt-pt, en-us…)
|
// Language code (pt-pt, en-us…)
|
||||||
// To be used in javascript APIs
|
// To be used in javascript APIs
|
||||||
if (geojson.properties.lang)
|
if (geojson.properties.lang) L.lang = geojson.properties.lang
|
||||||
L.lang = geojson.properties.lang
|
|
||||||
|
|
||||||
// Don't let default autocreation of controls
|
// Don't let default autocreation of controls
|
||||||
const zoomControl =
|
const zoomControl =
|
||||||
|
@ -91,7 +89,7 @@ L.U.Map.include({
|
||||||
|
|
||||||
this.ui = new L.U.UI(this._container)
|
this.ui = new L.U.UI(this._container)
|
||||||
this.xhr = new L.U.Xhr(this.ui)
|
this.xhr = new L.U.Xhr(this.ui)
|
||||||
this.xhr.on('dataloading', (e) => this.fire('dataloading', e))
|
this.xhr.on('dataloading', (e) => this.fire('dataloading', e))
|
||||||
this.xhr.on('dataload', (e) => this.fire('dataload', e))
|
this.xhr.on('dataload', (e) => this.fire('dataload', e))
|
||||||
|
|
||||||
this.initLoader()
|
this.initLoader()
|
||||||
|
@ -1811,19 +1809,31 @@ L.U.Map.include({
|
||||||
this._controlContainer
|
this._controlContainer
|
||||||
),
|
),
|
||||||
logo = L.DomUtil.add('a', 'logo', container),
|
logo = L.DomUtil.add('a', 'logo', container),
|
||||||
name = L.DomUtil.add('a', 'map-name', container, this.getDisplayName()),
|
name = L.DomUtil.create('a', 'map-name', container),
|
||||||
setName = function () {
|
share_status = L.DomUtil.create('a', 'share-status', container),
|
||||||
|
update = () => {
|
||||||
name.textContent = this.getDisplayName()
|
name.textContent = this.getDisplayName()
|
||||||
|
share_status.textContent = L._('Visibility: {status}', {
|
||||||
|
status: this.permissions.getShareStatusDisplay(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
update()
|
||||||
name.href = '#'
|
name.href = '#'
|
||||||
|
share_status.href = '#'
|
||||||
logo.href = '/'
|
logo.href = '/'
|
||||||
if (this.options.user) {
|
if (this.options.user) {
|
||||||
const userLabel = L.DomUtil.add('a', 'umap-user', container, this.options.user.name)
|
const userLabel = L.DomUtil.add(
|
||||||
|
'a',
|
||||||
|
'umap-user',
|
||||||
|
container,
|
||||||
|
this.options.user.name
|
||||||
|
)
|
||||||
userLabel.href = this.options.user.url
|
userLabel.href = this.options.user.url
|
||||||
}
|
}
|
||||||
this.help.button(container, 'edit')
|
this.help.button(container, 'edit')
|
||||||
L.DomEvent.on(name, 'click', this.edit, this)
|
L.DomEvent.on(name, 'click', this.edit, this)
|
||||||
this.on('postsync', L.bind(setName, this))
|
L.DomEvent.on(share_status, 'click', this.permissions.edit, this.permissions)
|
||||||
|
this.on('postsync', L.bind(update, this))
|
||||||
const save = L.DomUtil.create('a', 'leaflet-control-edit-save button', container)
|
const save = L.DomUtil.create('a', 'leaflet-control-edit-save button', container)
|
||||||
save.href = '#'
|
save.href = '#'
|
||||||
save.title = `${L._('Save current edits')} (Ctrl+S)`
|
save.title = `${L._('Save current edits')} (Ctrl+S)`
|
||||||
|
|
|
@ -160,6 +160,7 @@ L.U.MapPermissions = L.Class.extend({
|
||||||
this.commit()
|
this.commit()
|
||||||
this.isDirty = false
|
this.isDirty = false
|
||||||
this.map.continueSaving()
|
this.map.continueSaving()
|
||||||
|
this.map.fire('postsync')
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -194,4 +195,8 @@ L.U.MapPermissions = L.Class.extend({
|
||||||
commit: function () {
|
commit: function () {
|
||||||
L.Util.extend(this.map.options.permissions, this.options)
|
L.Util.extend(this.map.options.permissions, this.options)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getShareStatusDisplay: function () {
|
||||||
|
return Object.fromEntries(this.map.options.share_statuses)[this.options.share_status]
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -479,6 +479,9 @@ ul.photon-autocomplete {
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
.umap-main-edit-toolbox .share-status {
|
||||||
|
margin: 0 5px;
|
||||||
|
}
|
||||||
.umap-edit-enabled .umap-main-edit-toolbox {
|
.umap-edit-enabled .umap-main-edit-toolbox {
|
||||||
top: 0;
|
top: 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue