Merge pull request #1151 from umap-project/ctrl-shift-click

Document Shift-Click and add Ctrl-Shift-click to edit datalayer
This commit is contained in:
Yohan Boniface 2023-06-20 20:24:50 +02:00 committed by GitHub
commit 615498d3bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 6 deletions

View file

@ -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)'),
},
},

View file

@ -333,8 +333,12 @@ L.U.FeatureMixin = {
this.view(e)
} else if (!this.isReadOnly()) {
if (e.originalEvent.shiftKey) {
if (e.originalEvent.ctrlKey || e.originalEvent.metaKey) {
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') + ' (⇧+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+⇧+Click)',
callback: this.datalayer.edit,
context: this.datalayer,
iconCls: 'umap-edit',

View file

@ -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')

View file

@ -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')
)