From 3cee4fda011cff0b7e225145ac7ed3d3efaff137 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Mon, 19 Jun 2023 10:45:18 +0200 Subject: [PATCH 1/5] Document Shift-Click and add Ctrl-Shift-click to edit datalayer --- umap/static/umap/js/umap.features.js | 12 ++++++++---- umap/static/umap/js/umap.ui.js | 1 + umap/static/umap/test/Feature.js | 15 ++++++++++++++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/umap/static/umap/js/umap.features.js b/umap/static/umap/js/umap.features.js index a414d1a9..41a99294 100644 --- a/umap/static/umap/js/umap.features.js +++ b/umap/static/umap/js/umap.features.js @@ -333,8 +333,12 @@ L.U.FeatureMixin = { this.view(e) } else if (!this.isReadOnly()) { if (e.originalEvent.shiftKey) { - if (this._toggleEditing) this._toggleEditing(e) - else this.edit(e) + if (e.originalEvent.ctrlKey) { + this.datalayer.edit(e) + } else { + if (this._toggleEditing) this._toggleEditing(e) + else this.edit(e) + } } else { new L.Toolbar.Popup(e.latlng, { className: 'leaflet-inplace-toolbar', @@ -389,7 +393,7 @@ L.U.FeatureMixin = { let items = ['-'] if (this.map.editedFeature !== this) { items.push({ - text: L._('Edit this feature'), + text: L._('Edit this feature') + ' (Shift-click)', callback: this.edit, context: this, iconCls: 'umap-edit', @@ -397,7 +401,7 @@ L.U.FeatureMixin = { } items = items.concat( { - text: L._("Edit feature's layer"), + text: L._("Edit feature's layer") + ' (Ctrl-Shift-click)', callback: this.datalayer.edit, context: this.datalayer, iconCls: 'umap-edit', diff --git a/umap/static/umap/js/umap.ui.js b/umap/static/umap/js/umap.ui.js index 7e7a861f..6a87f193 100644 --- a/umap/static/umap/js/umap.ui.js +++ b/umap/static/umap/js/umap.ui.js @@ -64,6 +64,7 @@ L.U.UI = L.Evented.extend({ }, closePanel: function () { + this._panel.innerHTML = '' this.resetPanelClassName() L.DomUtil.removeClass(this.parent, 'umap-ui') this.fire('panel:closed') diff --git a/umap/static/umap/test/Feature.js b/umap/static/umap/test/Feature.js index cff88f7d..1f5c1117 100644 --- a/umap/static/umap/test/Feature.js +++ b/umap/static/umap/test/Feature.js @@ -28,8 +28,21 @@ describe('L.U.FeatureMixin', function () { assert.ok(qs('path[fill="DarkBlue"]')) // Polygon }) - it('should take into account styles changes made in the datalayer', function () { + it('should toggle edit panel on shift-clic', function () { enableEdit() + happen.click(qs('path[fill="DarkBlue"]'), {shiftKey: true}) + assert.ok(qs('form#umap-feature-properties')) + happen.click(qs('path[fill="DarkBlue"]'), {shiftKey: true}) + assert.notOk(qs('form#umap-feature-properties')) + }) + + it('should open datalayer edit panel on ctrl-shift-clic', function () { + enableEdit() + happen.click(qs('path[fill="DarkBlue"]'), {shiftKey: true, ctrlKey: true}) + assert.ok(qs('div.umap-layer-properties-container')) + }) + + it('should take into account styles changes made in the datalayer', function () { happen.click( qs('#browse_data_toggle_' + L.stamp(this.datalayer) + ' .layer-edit') ) From 58cf784b7eb6fad8d78a533d4cf31f29bc804871 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Tue, 20 Jun 2023 19:15:57 +0200 Subject: [PATCH 2/5] Make ctrl-shift-click work on MacOS too --- umap/static/umap/js/umap.features.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/umap/static/umap/js/umap.features.js b/umap/static/umap/js/umap.features.js index 41a99294..e9dc3997 100644 --- a/umap/static/umap/js/umap.features.js +++ b/umap/static/umap/js/umap.features.js @@ -333,7 +333,7 @@ L.U.FeatureMixin = { this.view(e) } else if (!this.isReadOnly()) { if (e.originalEvent.shiftKey) { - if (e.originalEvent.ctrlKey) { + if (e.originalEvent.ctrlKey || e.originalEvent.metaKey) { this.datalayer.edit(e) } else { if (this._toggleEditing) this._toggleEditing(e) From 6642d4a4f429c1fc0093935eca232e3f0867ad64 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Tue, 20 Jun 2023 19:50:11 +0200 Subject: [PATCH 3/5] =?UTF-8?q?Use=20=E2=87=A7=20instead=20of=20Shift=20in?= =?UTF-8?q?=20help=20messages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- umap/static/umap/js/umap.controls.js | 2 +- umap/static/umap/js/umap.features.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index 766c1611..56a23738 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -172,7 +172,7 @@ L.U.ToggleEditAction = L.U.BaseFeatureAction.extend({ options: { toolbarIcon: { className: 'umap-toggle-edit', - tooltip: L._('Toggle edit mode (Shift+Click)'), + tooltip: L._('Toggle edit mode (⇧+Click)'), }, }, diff --git a/umap/static/umap/js/umap.features.js b/umap/static/umap/js/umap.features.js index e9dc3997..8862ab66 100644 --- a/umap/static/umap/js/umap.features.js +++ b/umap/static/umap/js/umap.features.js @@ -393,7 +393,7 @@ L.U.FeatureMixin = { let items = ['-'] if (this.map.editedFeature !== this) { items.push({ - text: L._('Edit this feature') + ' (Shift-click)', + text: L._('Edit this feature') + ' (⇧-click)', callback: this.edit, context: this, iconCls: 'umap-edit', @@ -401,7 +401,7 @@ L.U.FeatureMixin = { } items = items.concat( { - text: L._("Edit feature's layer") + ' (Ctrl-Shift-click)', + text: L._("Edit feature's layer") + ' (Ctrl-⇧-click)', callback: this.datalayer.edit, context: this.datalayer, iconCls: 'umap-edit', From 3b466c2d19d39ee9e39ac3c3afd9acea9b3549fc Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Tue, 20 Jun 2023 20:12:38 +0200 Subject: [PATCH 4/5] Use + between keys in help texts --- umap/static/umap/js/umap.features.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/umap/static/umap/js/umap.features.js b/umap/static/umap/js/umap.features.js index 8862ab66..02d421b0 100644 --- a/umap/static/umap/js/umap.features.js +++ b/umap/static/umap/js/umap.features.js @@ -393,7 +393,7 @@ L.U.FeatureMixin = { let items = ['-'] if (this.map.editedFeature !== this) { items.push({ - text: L._('Edit this feature') + ' (⇧-click)', + text: L._('Edit this feature') + ' (⇧+click)', callback: this.edit, context: this, iconCls: 'umap-edit', @@ -401,7 +401,7 @@ L.U.FeatureMixin = { } items = items.concat( { - text: L._("Edit feature's layer") + ' (Ctrl-⇧-click)', + text: L._("Edit feature's layer") + ' (Ctrl+⇧+click)', callback: this.datalayer.edit, context: this.datalayer, iconCls: 'umap-edit', From 2f4fe8a011383857e964d9b1cc0933bf76aacb3e Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Tue, 20 Jun 2023 20:22:17 +0200 Subject: [PATCH 5/5] Uppercase "Click" --- umap/static/umap/js/umap.features.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/umap/static/umap/js/umap.features.js b/umap/static/umap/js/umap.features.js index 02d421b0..9b7ac8b2 100644 --- a/umap/static/umap/js/umap.features.js +++ b/umap/static/umap/js/umap.features.js @@ -393,7 +393,7 @@ L.U.FeatureMixin = { let items = ['-'] if (this.map.editedFeature !== this) { items.push({ - text: L._('Edit this feature') + ' (⇧+click)', + text: L._('Edit this feature') + ' (⇧+Click)', callback: this.edit, context: this, iconCls: 'umap-edit', @@ -401,7 +401,7 @@ L.U.FeatureMixin = { } items = items.concat( { - text: L._("Edit feature's layer") + ' (Ctrl+⇧+click)', + text: L._("Edit feature's layer") + ' (Ctrl+⇧+Click)', callback: this.datalayer.edit, context: this.datalayer, iconCls: 'umap-edit',