mirror of
https://github.com/umap-project/umap.git
synced 2025-04-30 20:12:37 +02:00
Merge pull request #1898 from umap-project/fix-js-circular-import
fix: django cannot run collectstatic with circular imports in modules
This commit is contained in:
commit
610367c3a1
3 changed files with 37 additions and 26 deletions
|
@ -1,5 +1,4 @@
|
||||||
import { translate } from '../../modules/i18n.js'
|
import { translate } from '../../modules/i18n.js'
|
||||||
import { ServerRequest } from '../../modules/request.js'
|
|
||||||
import { uMapElement } from '../base.js'
|
import { uMapElement } from '../base.js'
|
||||||
|
|
||||||
class uMapAlert extends uMapElement {
|
class uMapAlert extends uMapElement {
|
||||||
|
@ -77,9 +76,14 @@ class uMapAlertCreation extends uMapAlert {
|
||||||
// biome-ignore lint/style/useNumberNamespace: Number.Infinity returns undefined by default
|
// biome-ignore lint/style/useNumberNamespace: Number.Infinity returns undefined by default
|
||||||
duration = Infinity,
|
duration = Infinity,
|
||||||
editLink = undefined,
|
editLink = undefined,
|
||||||
sendLink = undefined
|
sendCallback = undefined
|
||||||
) {
|
) {
|
||||||
uMapAlertCreation.emit('alertCreation', { message, duration, editLink, sendLink })
|
uMapAlertCreation.emit('alertCreation', {
|
||||||
|
message,
|
||||||
|
duration,
|
||||||
|
editLink,
|
||||||
|
sendCallback,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -94,7 +98,7 @@ class uMapAlertCreation extends uMapAlert {
|
||||||
duration = 5000,
|
duration = 5000,
|
||||||
message = '',
|
message = '',
|
||||||
editLink = undefined,
|
editLink = undefined,
|
||||||
sendLink = undefined,
|
sendCallback = undefined,
|
||||||
} = event.detail
|
} = event.detail
|
||||||
uMapAlert.prototype.onAlert.call(this, { detail: { level, duration, message } })
|
uMapAlert.prototype.onAlert.call(this, { detail: { level, duration, message } })
|
||||||
this.linkWrapper.querySelector('input[type="url"]').value = editLink
|
this.linkWrapper.querySelector('input[type="url"]').value = editLink
|
||||||
|
@ -104,15 +108,14 @@ class uMapAlertCreation extends uMapAlert {
|
||||||
L.Util.copyToClipboard(editLink)
|
L.Util.copyToClipboard(editLink)
|
||||||
event.target.value = translate('✅ Copied!')
|
event.target.value = translate('✅ Copied!')
|
||||||
})
|
})
|
||||||
if (sendLink) {
|
if (sendCallback) {
|
||||||
this.formWrapper.removeAttribute('hidden')
|
this.formWrapper.removeAttribute('hidden')
|
||||||
const form = this.formWrapper.querySelector('form')
|
const form = this.formWrapper.querySelector('form')
|
||||||
form.addEventListener('submit', async (event) => {
|
form.addEventListener('submit', async (event) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
const formData = new FormData(form)
|
const formData = new FormData(form)
|
||||||
const server = new ServerRequest()
|
sendCallback(formData)
|
||||||
this.removeAttribute('open')
|
this.removeAttribute('open')
|
||||||
await server.post(sendLink, {}, formData)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,12 +127,8 @@ class uMapAlertCreation extends uMapAlert {
|
||||||
}
|
}
|
||||||
|
|
||||||
class uMapAlertConflict extends uMapAlert {
|
class uMapAlertConflict extends uMapAlert {
|
||||||
static error(
|
static error(message, forceCallback) {
|
||||||
message,
|
uMapAlertConflict.emit('alertConflict', { level: 'error', message, forceCallback })
|
||||||
// biome-ignore lint/style/useNumberNamespace: Number.Infinity returns undefined by default
|
|
||||||
duration = Infinity
|
|
||||||
) {
|
|
||||||
uMapAlertConflict.emit('alertConflict', { level: 'error', message, duration })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -138,14 +137,20 @@ class uMapAlertConflict extends uMapAlert {
|
||||||
}
|
}
|
||||||
|
|
||||||
onAlertConflict(event) {
|
onAlertConflict(event) {
|
||||||
const { level = 'info', duration = 5000, message = '' } = event.detail
|
// biome-ignore lint/style/useNumberNamespace: Number.Infinity returns undefined by default
|
||||||
|
const {
|
||||||
|
level = 'info',
|
||||||
|
duration = Infinity,
|
||||||
|
message = '',
|
||||||
|
forceCallback = undefined,
|
||||||
|
} = event.detail
|
||||||
uMapAlert.prototype.onAlert.call(this, { detail: { level, duration, message } })
|
uMapAlert.prototype.onAlert.call(this, { detail: { level, duration, message } })
|
||||||
const form = this.conflictWrapper.querySelector('form')
|
const form = this.conflictWrapper.querySelector('form')
|
||||||
form.addEventListener('submit', (event) => {
|
form.addEventListener('submit', (event) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
switch (event.submitter.id) {
|
switch (event.submitter.id) {
|
||||||
case 'your-changes':
|
case 'your-changes':
|
||||||
uMapAlertConflict.emit('alertConflictOverride')
|
forceCallback()
|
||||||
break
|
break
|
||||||
case 'their-changes':
|
case 'their-changes':
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
|
|
|
@ -13,7 +13,7 @@ L.Map.mergeOptions({
|
||||||
// we cannot rely on this because of the y is overriden by Leaflet
|
// we cannot rely on this because of the y is overriden by Leaflet
|
||||||
// See https://github.com/Leaflet/Leaflet/pull/9201
|
// See https://github.com/Leaflet/Leaflet/pull/9201
|
||||||
// And let's remove this -y when this PR is merged and released.
|
// And let's remove this -y when this PR is merged and released.
|
||||||
demoTileInfos: { s: 'a', z: 9, x: 265, y: 181, '-y': 181, r: '' },
|
demoTileInfos: { 's': 'a', 'z': 9, 'x': 265, 'y': 181, '-y': 181, 'r': '' },
|
||||||
licences: [],
|
licences: [],
|
||||||
licence: '',
|
licence: '',
|
||||||
enableMarkerDraw: true,
|
enableMarkerDraw: true,
|
||||||
|
@ -1063,17 +1063,14 @@ U.Map = L.Map.extend({
|
||||||
this.permissions.setOptions(data.permissions)
|
this.permissions.setOptions(data.permissions)
|
||||||
this.permissions.commit()
|
this.permissions.commit()
|
||||||
if (data?.permissions?.anonymous_edit_url) {
|
if (data?.permissions?.anonymous_edit_url) {
|
||||||
const send_edit_link_url =
|
|
||||||
this.options.urls.map_send_edit_link &&
|
|
||||||
this.urls.get('map_send_edit_link', {
|
|
||||||
map_id: this.options.umap_id,
|
|
||||||
})
|
|
||||||
this.once('saved', () => {
|
this.once('saved', () => {
|
||||||
U.AlertCreation.info(
|
U.AlertCreation.info(
|
||||||
L._('Your map has been created with an anonymous account!'),
|
L._('Your map has been created with an anonymous account!'),
|
||||||
Number.Infinity,
|
Number.Infinity,
|
||||||
data.permissions.anonymous_edit_url,
|
data.permissions.anonymous_edit_url,
|
||||||
send_edit_link_url
|
this.options.urls.map_send_edit_link
|
||||||
|
? this.sendEditLinkEmail.bind(this)
|
||||||
|
: null
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
@ -1887,4 +1884,13 @@ U.Map = L.Map.extend({
|
||||||
})
|
})
|
||||||
return bounds
|
return bounds
|
||||||
},
|
},
|
||||||
|
|
||||||
|
sendEditLinkEmail: async function (formData) {
|
||||||
|
const sendLink =
|
||||||
|
this.options.urls.map_send_edit_link &&
|
||||||
|
this.urls.get('map_send_edit_link', {
|
||||||
|
map_id: this.options.umap_id,
|
||||||
|
})
|
||||||
|
await this.server.post(sendLink, {}, formData)
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -1708,11 +1708,11 @@ U.DataLayer = L.Evented.extend({
|
||||||
L._(
|
L._(
|
||||||
'Whoops! Other contributor(s) changed some of the same map elements as you. ' +
|
'Whoops! Other contributor(s) changed some of the same map elements as you. ' +
|
||||||
'This situation is tricky, you have to choose carefully which version is pertinent.'
|
'This situation is tricky, you have to choose carefully which version is pertinent.'
|
||||||
)
|
),
|
||||||
|
async () => {
|
||||||
|
await this._trySave(url, {}, formData)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
document.addEventListener('umap:alertConflictOverride', async (event) => {
|
|
||||||
await this._trySave(url, {}, formData)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Response contains geojson only if save has conflicted and conflicts have
|
// Response contains geojson only if save has conflicted and conflicts have
|
||||||
|
|
Loading…
Reference in a new issue