chore: fix help module not using umap module

This commit is contained in:
Yohan Boniface 2024-11-12 11:31:14 +01:00
parent 55f04a2f10
commit 491d0515cd
4 changed files with 18 additions and 13 deletions

View file

@ -1,5 +1,6 @@
import { DomEvent, DomUtil } from '../../vendors/leaflet/leaflet-src.esm.js' import { DomEvent, DomUtil } from '../../vendors/leaflet/leaflet-src.esm.js'
import { translate } from './i18n.js' import { translate } from './i18n.js'
import * as Utils from './utils.js'
const SHORTCUTS = { const SHORTCUTS = {
DRAW_MARKER: { DRAW_MARKER: {
@ -163,9 +164,9 @@ const ENTRIES = {
} }
export default class Help { export default class Help {
constructor(map) { constructor(umap) {
this.map = map this.umap = umap
this.dialog = new U.Dialog() this.dialog = new U.Dialog({ className: 'dark', accept: false, cancel: false })
this.isMacOS = /mac/i.test( this.isMacOS = /mac/i.test(
// eslint-disable-next-line compat/compat -- Fallback available. // eslint-disable-next-line compat/compat -- Fallback available.
navigator.userAgentData ? navigator.userAgentData.platform : navigator.platform navigator.userAgentData ? navigator.userAgentData.platform : navigator.platform
@ -199,7 +200,7 @@ export default class Help {
innerHTML: ENTRIES[name], innerHTML: ENTRIES[name],
}) })
} }
this.dialog.open({ template: container, className: 'dark', cancel: false, accept: false }) this.dialog.open({ template: container })
} }
// Special dynamic case. Do we still think this dialog is useful? // Special dynamic case. Do we still think this dialog is useful?
@ -211,7 +212,7 @@ export default class Help {
className: 'umap-help-entry', className: 'umap-help-entry',
parent: container, parent: container,
}).appendChild(this._buildEditEntry()) }).appendChild(this._buildEditEntry())
this.map.dialog.open({ content: container, className: 'dark' }) this.dialog.open({ template: container })
} }
button(container, entries) { button(container, entries) {
@ -247,9 +248,11 @@ export default class Help {
DomEvent.on(actionContainer, 'click', action.addHooks, action) DomEvent.on(actionContainer, 'click', action.addHooks, action)
DomEvent.on(actionContainer, 'click', this.dialog.close, this.dialog) DomEvent.on(actionContainer, 'click', this.dialog.close, this.dialog)
} }
for (const id in this.map.helpMenuActions) { for (const action of Object.values(Help.MENU_ACTIONS)) {
addAction(this.map.helpMenuActions[id]) addAction(action)
} }
return container return container
} }
} }
Help.MENU_ACTIONS = {}

View file

@ -36,7 +36,6 @@ const ControlsMixin = {
], ],
initControls: function () { initControls: function () {
this.helpMenuActions = {}
this._controls = {} this._controls = {}
if (this.umap.hasEditMode() && !this.options.noControl) { if (this.umap.hasEditMode() && !this.options.noControl) {

View file

@ -523,7 +523,7 @@ export default class Umap extends ServerStored {
this._leafletMap.importer.openFiles() this._leafletMap.importer.openFiles()
break break
case 'h': case 'h':
this.help.show('edit') this.help.showGetStarted()
break break
default: default:
used = false used = false
@ -1203,7 +1203,7 @@ export default class Umap extends ServerStored {
this.editPanel.close() this.editPanel.close()
this.fullPanel.close() this.fullPanel.close()
this.sync.stop() this.sync.stop()
this.closeInplaceToolbar() this._leafletMap.closeInplaceToolbar()
} }
askForReset(e) { askForReset(e) {

View file

@ -12,8 +12,8 @@ U.BaseAction = L.ToolbarAction.extend({
tooltip: this.options.tooltip, tooltip: this.options.tooltip,
} }
L.ToolbarAction.prototype.initialize.call(this) L.ToolbarAction.prototype.initialize.call(this)
if (this.options.helpMenu && !this.map.helpMenuActions[this.options.className]) if (this.options.helpMenu && !U.Help.MENU_ACTIONS[this.options.className])
this.map.helpMenuActions[this.options.className] = this U.Help.MENU_ACTIONS[this.options.className] = this
}, },
}) })
@ -675,7 +675,10 @@ U.TileLayerChooser = L.Control.extend({
const el = L.DomUtil.create('li', selectedClass, this._tilelayers_container) const el = L.DomUtil.create('li', selectedClass, this._tilelayers_container)
const img = L.DomUtil.create('img', '', el) const img = L.DomUtil.create('img', '', el)
const name = L.DomUtil.create('div', '', el) const name = L.DomUtil.create('div', '', el)
img.src = U.Utils.template(tilelayer.options.url_template, this.map.options.demoTileInfos) img.src = U.Utils.template(
tilelayer.options.url_template,
this.map.options.demoTileInfos
)
img.loading = 'lazy' img.loading = 'lazy'
name.textContent = tilelayer.options.name name.textContent = tilelayer.options.name
L.DomEvent.on( L.DomEvent.on(