Add a "Copy link" button near to the anonymous edit link
This commit is contained in:
parent
8f77b63b08
commit
5d6afdfb1b
3 changed files with 17 additions and 12 deletions
|
@ -1339,7 +1339,7 @@ L.U.Map.include({
|
||||||
let duration = 3000,
|
let duration = 3000,
|
||||||
alert = { content: L._('Map has been saved!'), level: 'info' }
|
alert = { content: L._('Map has been saved!'), level: 'info' }
|
||||||
if (!this.options.umap_id) {
|
if (!this.options.umap_id) {
|
||||||
alert.duration = Infinity
|
alert.content = L._('Congratulations, your map has been created!')
|
||||||
this.options.umap_id = data.id
|
this.options.umap_id = data.id
|
||||||
this.permissions.setOptions(data.permissions)
|
this.permissions.setOptions(data.permissions)
|
||||||
if (
|
if (
|
||||||
|
@ -1347,6 +1347,12 @@ L.U.Map.include({
|
||||||
data.permissions.anonymous_edit_url &&
|
data.permissions.anonymous_edit_url &&
|
||||||
this.options.urls.map_send_edit_link
|
this.options.urls.map_send_edit_link
|
||||||
) {
|
) {
|
||||||
|
alert.duration = Infinity
|
||||||
|
alert.content =
|
||||||
|
L._(
|
||||||
|
'Your map has been created! As you are not logged in, here is your secret link to edit the map, please keep it safe:'
|
||||||
|
) + `<br>${data.permissions.anonymous_edit_url}`
|
||||||
|
|
||||||
alert.actions = [
|
alert.actions = [
|
||||||
{
|
{
|
||||||
label: L._('Send me the link'),
|
label: L._('Send me the link'),
|
||||||
|
@ -1354,6 +1360,14 @@ L.U.Map.include({
|
||||||
callback: this.sendEditLink,
|
callback: this.sendEditLink,
|
||||||
callbackContext: this,
|
callbackContext: this,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: L._('Copy link'),
|
||||||
|
callback: () => {
|
||||||
|
navigator.clipboard.writeText(data.permissions.anonymous_edit_url)
|
||||||
|
this.ui.alert({content: L._('Copied!'), level: 'info'})
|
||||||
|
},
|
||||||
|
callbackContext: this,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
} else if (!this.permissions.isDirty) {
|
} else if (!this.permissions.isDirty) {
|
||||||
|
|
|
@ -84,7 +84,7 @@ L.U.UI = L.Evented.extend({
|
||||||
this._alert.innerHTML = ''
|
this._alert.innerHTML = ''
|
||||||
L.DomUtil.addClass(this.parent, 'umap-alert')
|
L.DomUtil.addClass(this.parent, 'umap-alert')
|
||||||
L.DomUtil.addClass(this._alert, level_class)
|
L.DomUtil.addClass(this._alert, level_class)
|
||||||
function close() {
|
const close = () => {
|
||||||
if (timeoutID !== this.ALERT_ID) {
|
if (timeoutID !== this.ALERT_ID) {
|
||||||
return
|
return
|
||||||
} // Another alert has been forced
|
} // Another alert has been forced
|
||||||
|
@ -124,7 +124,7 @@ L.U.UI = L.Evented.extend({
|
||||||
if (action.callback)
|
if (action.callback)
|
||||||
L.DomEvent.on(el, 'click', () => {
|
L.DomEvent.on(el, 'click', () => {
|
||||||
action.callback.bind(action.callbackContext || this.map)()
|
action.callback.bind(action.callbackContext || this.map)()
|
||||||
close.bind(this)()
|
close()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -540,14 +540,6 @@ class MapCreate(FormLessEditMixin, PermissionsMixin, CreateView):
|
||||||
form.instance.owner = self.request.user
|
form.instance.owner = self.request.user
|
||||||
self.object = form.save()
|
self.object = form.save()
|
||||||
anonymous_url = self.object.get_anonymous_edit_url()
|
anonymous_url = self.object.get_anonymous_edit_url()
|
||||||
if not self.request.user.is_authenticated:
|
|
||||||
msg = _(
|
|
||||||
"Your map has been created! As you are not logged in, here is your "
|
|
||||||
"secret link to edit the map, please keep it safe:"
|
|
||||||
+ f"<br>{anonymous_url}"
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
msg = _("Congratulations, your map has been created!")
|
|
||||||
permissions = self.get_permissions()
|
permissions = self.get_permissions()
|
||||||
# User does not have the cookie yet.
|
# User does not have the cookie yet.
|
||||||
permissions["anonymous_edit_url"] = anonymous_url
|
permissions["anonymous_edit_url"] = anonymous_url
|
||||||
|
@ -555,7 +547,6 @@ class MapCreate(FormLessEditMixin, PermissionsMixin, CreateView):
|
||||||
id=self.object.pk,
|
id=self.object.pk,
|
||||||
url=self.object.get_absolute_url(),
|
url=self.object.get_absolute_url(),
|
||||||
permissions=permissions,
|
permissions=permissions,
|
||||||
info=msg,
|
|
||||||
)
|
)
|
||||||
if not self.request.user.is_authenticated:
|
if not self.request.user.is_authenticated:
|
||||||
key, value = self.object.signed_cookie_elements
|
key, value = self.object.signed_cookie_elements
|
||||||
|
|
Loading…
Reference in a new issue