From 759dd34ef343d359b6526ad64fd5bf03472f5c74 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Mon, 1 Jul 2024 18:58:01 +0200 Subject: [PATCH 1/4] fix: main help button from edit toolbar was broken --- umap/static/umap/js/modules/help.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/umap/static/umap/js/modules/help.js b/umap/static/umap/js/modules/help.js index fe0a8460..7587a138 100644 --- a/umap/static/umap/js/modules/help.js +++ b/umap/static/umap/js/modules/help.js @@ -191,7 +191,7 @@ export default class Help { const container = DomUtil.add('div') DomUtil.createTitle(container, translate('Help')) // Special dynamic case. Do we still think this dialog is usefull ? - if (entries === 'edit') { + if (entries[0] === 'edit') { DomUtil.element({ tagName: 'div', className: 'umap-help-entry', From 6aa74060ad64a4c3741b207eea684e3f1f2dd6f3 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 5 Jul 2024 09:52:39 +0200 Subject: [PATCH 2/4] chore: make explicit that the "show get started dialog" is a special case --- umap/static/umap/js/modules/help.js | 44 +++++++++++++++------------- umap/static/umap/js/umap.controls.js | 2 +- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/umap/static/umap/js/modules/help.js b/umap/static/umap/js/modules/help.js index 7587a138..824a0749 100644 --- a/umap/static/umap/js/modules/help.js +++ b/umap/static/umap/js/modules/help.js @@ -190,26 +190,29 @@ export default class Help { show(entries) { const container = DomUtil.add('div') DomUtil.createTitle(container, translate('Help')) - // Special dynamic case. Do we still think this dialog is usefull ? - if (entries[0] === 'edit') { + for (const name of entries) { DomUtil.element({ tagName: 'div', className: 'umap-help-entry', parent: container, - }).appendChild(this._buildEditEntry()) - } else { - for (const name of entries) { - DomUtil.element({ - tagName: 'div', - className: 'umap-help-entry', - parent: container, - innerHTML: ENTRIES[name], - }) - } + innerHTML: ENTRIES[name], + }) } this.map.dialog.open({ content: container, className: 'dark' }) } + // Special dynamic case. Do we still think this dialog is usefull ? + showGetStarted() { + const container = DomUtil.add('div') + DomUtil.createTitle(container, translate('Where do we go from here?')) + DomUtil.element({ + tagName: 'div', + className: 'umap-help-entry', + parent: container, + }).appendChild(this._buildEditEntry()) + this.map.dialog.open({ content: container, className: 'dark' }) + } + button(container, entries, classname) { const button = DomUtil.createButton( classname || 'umap-help-button', @@ -217,15 +220,18 @@ export default class Help { translate('Help') ) entries = typeof entries === 'string' ? [entries] : entries - DomEvent.on(button, 'click', DomEvent.stop).on(button, 'click', () => + DomEvent.on(button, 'click', DomEvent.stop).on(button, 'click', () => { this.show(entries) - ) + }) return button } - link(container, entries) { - const button = this.button(container, entries, 'umap-help-link') + getStartedLink(container) { + const button = DomUtil.createButton('umap-help-link', container, translate('Help')) button.textContent = translate('Help') + DomEvent.on(button, 'click', DomEvent.stop).on(button, 'click', () => { + this.showGetStarted() + }) return button } @@ -237,16 +243,14 @@ export default class Help { _buildEditEntry() { const container = DomUtil.create('div', '') - const title = DomUtil.create('h4', '', container) const actionsContainer = DomUtil.create('ul', 'umap-edit-actions', container) const addAction = (action) => { const actionContainer = DomUtil.add('li', '', actionsContainer) - DomUtil.add('i', action.options.className, actionContainer), - DomUtil.add('span', '', actionContainer, action.options.tooltip) + DomUtil.add('i', action.options.className, actionContainer) + DomUtil.add('span', '', actionContainer, action.options.tooltip) DomEvent.on(actionContainer, 'click', action.addHooks, action) DomEvent.on(actionContainer, 'click', this.map.dialog.close, this.map.dialog) } - title.textContent = translate('Where do we go from here?') for (const id in this.map.helpMenuActions) { addAction(this.map.helpMenuActions[id]) } diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index 9b481139..5b8fa700 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -751,7 +751,7 @@ const ControlsMixin = { this.options.user.url ) } - this.help.link(rightContainer, 'edit') + this.help.getStartedLink(rightContainer) const controlEditCancel = L.DomUtil.createButton( 'leaflet-control-edit-cancel', rightContainer, From ec5f8d7b3c7f691e36a4fef51343f9d709062f13 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 5 Jul 2024 18:19:00 +0200 Subject: [PATCH 3/4] Update umap/static/umap/js/modules/help.js Co-authored-by: David Larlet <3556+davidbgk@users.noreply.github.com> --- umap/static/umap/js/modules/help.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/umap/static/umap/js/modules/help.js b/umap/static/umap/js/modules/help.js index 824a0749..7bbf66dd 100644 --- a/umap/static/umap/js/modules/help.js +++ b/umap/static/umap/js/modules/help.js @@ -201,7 +201,7 @@ export default class Help { this.map.dialog.open({ content: container, className: 'dark' }) } - // Special dynamic case. Do we still think this dialog is usefull ? + // Special dynamic case. Do we still think this dialog is useful? showGetStarted() { const container = DomUtil.add('div') DomUtil.createTitle(container, translate('Where do we go from here?')) From 207860ecf527533cff7ebeafe3eafe465d7b15f2 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 5 Jul 2024 18:27:53 +0200 Subject: [PATCH 4/4] chore: refactor help.button arguments --- umap/static/umap/js/modules/help.js | 13 ++++--------- umap/static/umap/js/modules/schema.js | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/umap/static/umap/js/modules/help.js b/umap/static/umap/js/modules/help.js index 7bbf66dd..7c33a8dc 100644 --- a/umap/static/umap/js/modules/help.js +++ b/umap/static/umap/js/modules/help.js @@ -213,25 +213,20 @@ export default class Help { this.map.dialog.open({ content: container, className: 'dark' }) } - button(container, entries, classname) { + button(container, entries) { const button = DomUtil.createButton( - classname || 'umap-help-button', + 'umap-help-button', container, translate('Help') ) - entries = typeof entries === 'string' ? [entries] : entries - DomEvent.on(button, 'click', DomEvent.stop).on(button, 'click', () => { - this.show(entries) - }) + button.addEventListener('click', () => this.show(entries)) return button } getStartedLink(container) { const button = DomUtil.createButton('umap-help-link', container, translate('Help')) button.textContent = translate('Help') - DomEvent.on(button, 'click', DomEvent.stop).on(button, 'click', () => { - this.showGetStarted() - }) + button.addEventListener('click', () => this.showGetStarted()) return button } diff --git a/umap/static/umap/js/modules/schema.js b/umap/static/umap/js/modules/schema.js index a818aec9..881fe22c 100644 --- a/umap/static/umap/js/modules/schema.js +++ b/umap/static/umap/js/modules/schema.js @@ -45,7 +45,7 @@ export const SCHEMA = { impacts: ['data'], handler: 'ColorPicker', label: translate('color'), - helpEntries: 'colorValue', + helpEntries: ['colorValue'], inheritable: true, default: 'DarkBlue', }, @@ -65,7 +65,7 @@ export const SCHEMA = { type: String, impacts: ['data'], label: translate('dash array'), - helpEntries: 'dashArray', + helpEntries: ['dashArray'], inheritable: true, }, datalayersControl: { @@ -92,7 +92,7 @@ export const SCHEMA = { type: 'Text', impacts: ['ui'], label: translate('description'), - helpEntries: 'textFormatting', + helpEntries: ['textFormatting'], }, displayOnLoad: { type: Boolean, @@ -131,7 +131,7 @@ export const SCHEMA = { type: Boolean, impacts: ['data'], label: translate('fill'), - helpEntries: 'fill', + helpEntries: ['fill'], inheritable: true, default: true, }, @@ -140,7 +140,7 @@ export const SCHEMA = { impacts: ['data'], handler: 'ColorPicker', label: translate('fill color'), - helpEntries: 'fillColor', + helpEntries: ['fillColor'], inheritable: true, }, fillOpacity: { @@ -216,7 +216,7 @@ export const SCHEMA = { type: Boolean, impacts: ['data'], label: translate('Allow interactions'), - helpEntries: 'interactive', + helpEntries: ['interactive'], inheritable: true, default: true, }, @@ -243,7 +243,7 @@ export const SCHEMA = { labelKey: { type: String, impacts: ['data'], - helpEntries: 'labelKey', + helpEntries: ['labelKey'], placeholder: translate('Default: name'), label: translate('Label key'), inheritable: true, @@ -319,7 +319,7 @@ export const SCHEMA = { type: String, impacts: [], label: translate('Link to…'), - helpEntries: 'outlink', + helpEntries: ['outlink'], placeholder: 'http://...', inheritable: true, }, @@ -441,7 +441,7 @@ export const SCHEMA = { max: 10, step: 0.5, label: translate('Simplify'), - helpEntries: 'smoothFactor', + helpEntries: ['smoothFactor'], inheritable: true, default: 1.0, }, @@ -459,7 +459,7 @@ export const SCHEMA = { type: Boolean, impacts: ['data'], label: translate('stroke'), - helpEntries: 'stroke', + helpEntries: ['stroke'], inheritable: true, default: true, }, @@ -467,7 +467,7 @@ export const SCHEMA = { type: Boolean, impacts: ['sync', 'ui'], label: translate('Enable real-time collaboration'), - helpEntries: 'sync', + helpEntries: ['sync'], default: false, }, tilelayer: { @@ -526,7 +526,7 @@ export const SCHEMA = { type: Number, impacts: [], // not need to update the view placeholder: translate('Inherit'), - helpEntries: 'zoomTo', + helpEntries: ['zoomTo'], label: translate('Default zoom level'), inheritable: true, },