commit e315e63e798cbd8de4231ac350b165088a985a90
parent 63e58d25dcb0bf11b7239aa237d8e94e62b2eee2
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date: Mon, 14 Oct 2024 11:03:35 -0700
Support arrays properly in the editor selector function
Instead of the indices themselves, the values the indices point to
are used.
Diffstat:
3 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/files/floorplans/floorplan/backend.js b/files/floorplans/floorplan/backend.js
@@ -328,15 +328,10 @@ export class FloorplanBackend {
points: {},
/*
- * { pointMapId: { type: mapType*, from: pointId, to: pointId } }
- *
- * [*] The only map types I think are needed are wall and door
- * at the moment.
+ * { pointMapId: { type: mapType, from: pointId, to: pointId } }
*/
pointmaps: {},
- // There will be here more later, such as furnature
-
/*
* Furniture definitions:
* { id: { type: furnitureType, name: name, width: width, depth: depth } }
@@ -499,7 +494,7 @@ export class FloorplanBackend {
type: {
required: true,
validate: function(type) {
- return type === "wall" || type === "door"
+ return type === "wall" || type === "door" || type === "window" || type === "railing"
}
},
a: {
diff --git a/files/floorplans/floorplan/editor.js b/files/floorplans/floorplan/editor.js
@@ -659,9 +659,6 @@ export class FloorplanEditor {
}
},
pointmaps: function(id, value) {
- if (value.type !== "wall" && value.type !== "door") {
- throw new Error("Only walls and doors currently supported")
- }
let a = editor.backend.obj(value.a)
let b = editor.backend.obj(value.b)
let wall = editor.draw.findOneMax(byId(id))
diff --git a/files/floorplans/floorplan/main.js b/files/floorplans/floorplan/main.js
@@ -353,7 +353,11 @@ function selector(things, select, options) {
}
let list = form.appendChild(document.createElement("ul"))
+ let isArray = Array.isArray(things)
for (let thing in things) {
+ if (isArray) {
+ thing = things[thing]
+ }
console.debug("selector", options.text ?? "something", thing)
let item = list.appendChild(document.createElement("li"))
let selector = item