diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js
index 57299e87..5b9d1176 100644
--- a/umap/static/umap/js/umap.js
+++ b/umap/static/umap/js/umap.js
@@ -1339,7 +1339,7 @@ L.U.Map.include({
let duration = 3000,
alert = { content: L._('Map has been saved!'), level: 'info' }
if (!this.options.umap_id) {
- alert.duration = Infinity
+ alert.content = L._('Congratulations, your map has been created!')
this.options.umap_id = data.id
this.permissions.setOptions(data.permissions)
if (
@@ -1347,6 +1347,12 @@ L.U.Map.include({
data.permissions.anonymous_edit_url &&
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:'
+ ) + `
${data.permissions.anonymous_edit_url}`
+
alert.actions = [
{
label: L._('Send me the link'),
@@ -1354,6 +1360,14 @@ L.U.Map.include({
callback: this.sendEditLink,
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) {
diff --git a/umap/static/umap/js/umap.ui.js b/umap/static/umap/js/umap.ui.js
index 3fd945be..ea6ee9d5 100644
--- a/umap/static/umap/js/umap.ui.js
+++ b/umap/static/umap/js/umap.ui.js
@@ -84,7 +84,7 @@ L.U.UI = L.Evented.extend({
this._alert.innerHTML = ''
L.DomUtil.addClass(this.parent, 'umap-alert')
L.DomUtil.addClass(this._alert, level_class)
- function close() {
+ const close = () => {
if (timeoutID !== this.ALERT_ID) {
return
} // Another alert has been forced
@@ -124,7 +124,7 @@ L.U.UI = L.Evented.extend({
if (action.callback)
L.DomEvent.on(el, 'click', () => {
action.callback.bind(action.callbackContext || this.map)()
- close.bind(this)()
+ close()
})
}
}
diff --git a/umap/views.py b/umap/views.py
index d323c353..8c6374c8 100644
--- a/umap/views.py
+++ b/umap/views.py
@@ -540,14 +540,6 @@ class MapCreate(FormLessEditMixin, PermissionsMixin, CreateView):
form.instance.owner = self.request.user
self.object = form.save()
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"
{anonymous_url}"
- )
- else:
- msg = _("Congratulations, your map has been created!")
permissions = self.get_permissions()
# User does not have the cookie yet.
permissions["anonymous_edit_url"] = anonymous_url
@@ -555,7 +547,6 @@ class MapCreate(FormLessEditMixin, PermissionsMixin, CreateView):
id=self.object.pk,
url=self.object.get_absolute_url(),
permissions=permissions,
- info=msg,
)
if not self.request.user.is_authenticated:
key, value = self.object.signed_cookie_elements