fix: proper way to deal with 412

This commit is contained in:
Yohan Boniface 2024-01-30 17:30:27 +01:00
parent d07d9f61d2
commit d1df70b0f4

View file

@ -926,7 +926,7 @@ L.U.DataLayer = L.Evented.extend({
}) })
} }
this.map.ui.alert({ content: message, level: 'error', duration: 10000 }) this.map.ui.alert({ content: message, level: 'error', duration: 10000 })
console.log(err) console.error(err)
} }
if (result && result.features.length) { if (result && result.features.length) {
callback(result) callback(result)
@ -1570,8 +1570,8 @@ L.U.DataLayer = L.Evented.extend({
_trySave: async function (url, headers, formData) { _trySave: async function (url, headers, formData) {
const [data, response, error] = await this.map.server.post(url, headers, formData) const [data, response, error] = await this.map.server.post(url, headers, formData)
if (!error) { if (error) {
if (response.status === 412) { if (response && response.status === 412) {
const msg = L._( const msg = L._(
'Woops! Someone else seems to have edited the data. You can save anyway, but this will erase the changes made by others.' 'Woops! Someone else seems to have edited the data. You can save anyway, but this will erase the changes made by others.'
) )
@ -1588,13 +1588,14 @@ L.U.DataLayer = L.Evented.extend({
label: L._('Cancel'), label: L._('Cancel'),
}, },
] ]
this.ui.alert({ this.map.ui.alert({
content: msg, content: msg,
level: 'error', level: 'error',
duration: 100000, duration: 100000,
actions: actions, actions: actions,
}) })
} }
} else {
// Response contains geojson only if save has conflicted and conflicts have // Response contains geojson only if save has conflicted and conflicts have
// been resolved. So we need to reload to get extra data (added by someone else) // been resolved. So we need to reload to get extra data (added by someone else)
if (data.geojson) { if (data.geojson) {