commit b8444cbe4632897ce848e23ebb8fec04333a09f4
parent bf6876fba0878f92fb9645077ad9dab0629b20d3
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date: Sun, 25 Aug 2024 14:04:19 -0700
Add replacePoint method to backend
Diffstat:
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/files/floorplans/floorplan/backend.js b/files/floorplans/floorplan/backend.js
@@ -444,12 +444,19 @@ export class FloorplanBackend {
}
addPoint(point, options) {
+ options = options ?? {}
+
if (typeof point.x !== "number" || typeof point.y !== "number") {
- console.error("Backend.addPoint", point)
- throw new Error("Point must have x and y be numbers")
+ throw new Error(`Point's x (${point.x}) and y (${point.y}) are not numbers`)
}
- // I suppose point could have other keys, that's okay though
- return this.addData("points", { x: Math.round(point.x), y: Math.round(point.y) }, options)
+ return this.addData("points", { x: Math.round(point.x), y: Math.round(point.y) },
+ options.replace, options)
+ }
+
+ replacePoint(id, newpoint, options) {
+ options = options ?? {}
+ options.replace = id
+ return this.addPoint(newpoint, options)
}
removePoint(id, options) {