www.spaceplanner.app

Web client to the spaceplanner API
git clone git://jacobedwards.org/www.spaceplanner.app
Log | Files | Refs

commit fe10e77af09aadc6cba7f6833ab5d63bc1cd359b
parent 69d235c39adce6d589f64985e7848ed7fa45ac6c
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date:   Thu,  3 Oct 2024 10:28:56 -0700

Add point operation selector to selectHandler

This will be used in future updates as the new way of determining
whether to move or create points in the point handler: I'm going
to try and avoid double and long clicks.

Diffstat:
Mfiles/floorplans/floorplan/main.js | 27++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/files/floorplans/floorplan/main.js b/files/floorplans/floorplan/main.js @@ -19,6 +19,8 @@ const buttons = { // turn off bubbling const escapeEvent = new Event("escape") +let pointOp = 'Create' + function init() { etc.authorize() etc.bar() @@ -180,10 +182,29 @@ function selectHandler(event, editor, state) { ids[i] = lib.getID(a[i]) } + let groups = {} + let cnt = 0 + for (let i = 0; i < ids.length; ++i) { + let t = backend.idType(ids[i]) + if (groups[t] === undefined) { + groups[t] = [] + } + groups[t].push(ids[i]) + ++cnt + } + + if (groups.pnt && groups.pnt.length === cnt) { + const pmode = function(mode) { pointOp = mode } + pmode('Create') + c.appendChild( + selector({ Create: true, Move: true }, pmode, { current: pointOp }) + ) + } + let maps = [] - for (let i in ids) { - if (backend.idType(ids[i]) === "pntmap") { - maps.push(editor.backend.cache.pointmaps[ids[i]]) + if (groups.pntmap !== undefined) { + for (let i = 0; i < groups.pntmap.length; ++i) { + maps.push(editor.backend.cache.pointmaps[groups.pntmap[i]]) } }