@7365admin1/layer-common 4.122.1 → 4.122.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @iservice365/layer-common
2
2
 
3
+ ## 4.122.2
4
+
5
+ ### Patch Changes
6
+
7
+ - ad65b64: Map editor: Add floor beside the floor list adds a floor no robot reports yet (saved as an empty level), so a lift shaft can stop on two floors at a site whose robots are all on one floor. The one-floor lift message now says how.
8
+
3
9
  ## 4.122.1
4
10
 
5
11
  ### Patch Changes
@@ -3234,11 +3240,11 @@ Monthly report: a month that had patrols opens the list of that month's patrol r
3234
3240
  `utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
3235
3241
  own rule from two endpoints the console already calls, unprojected:
3236
3242
 
3237
- GET /api/members/user/:user/app/admin the Seven365 staff membership
3238
- GET /api/roles/id/:role that membership's role document
3243
+ GET /api/members/user/:user/app/admin the Seven365 staff membership
3244
+ GET /api/roles/id/:role that membership's role document
3239
3245
 
3240
- owner = member.type === "admin" && role.type === "admin" && role.default === true
3241
- staff = member.type === "admin" && role.type === "admin"
3246
+ owner = member.type === "admin" && role.type === "admin" && role.default === true
3247
+ staff = member.type === "admin" && role.type === "admin"
3242
3248
 
3243
3249
  `role.default` is the marker because it is the only property of a platform
3244
3250
  staff role no API caller can set - `role.controller.ts` validates create and
@@ -39,6 +39,9 @@
39
39
  <select v-model.number="floor" class="hero-input hero-select hero-editor__floor" aria-label="Floor">
40
40
  <option v-for="f in allFloors" :key="f" :value="f">{{ floorName(f) }}</option>
41
41
  </select>
42
+ <div class="hero-seg" role="group" aria-label="Floors">
43
+ <button type="button" class="hero-seg__opt" title="Add a floor no robot is on yet (e.g. a lift's other stops)" @click="addFloor">Add floor</button>
44
+ </div>
42
45
  <label class="hero-editor__graphpick">
43
46
  <span>Route graph</span>
44
47
  <select v-model.number="graph" class="hero-input hero-select hero-editor__floor" aria-label="Route graph">
@@ -408,6 +411,7 @@ import {
408
411
  LIFT_MIN_M,
409
412
  NUDGE_BIG_M,
410
413
  NUDGE_M,
414
+ newFloorNo,
411
415
  ROUTE_TOOLS,
412
416
  routeProblems,
413
417
  saveErrorText,
@@ -1062,6 +1066,20 @@ function setLevel(key: "name" | "elevationM", value: string | number) {
1062
1066
  levels.value = { ...levels.value, [String(floor.value)]: { ...cur, [key]: value } };
1063
1067
  state.value = { ...state.value, dirty: true };
1064
1068
  }
1069
+ /** A floor with nothing on it yet (no robot reports it): saved as an empty level so a lift can stop there. */
1070
+ function addFloor() {
1071
+ const answer = window.prompt("Floor number to add (1 = L1, 0 = G, -1 = B1)");
1072
+ if (answer === null) return;
1073
+ const r = newFloorNo(answer, allFloors.value);
1074
+ if ("error" in r) return void dispatch({ type: "notice", text: r.error, ok: false });
1075
+ const fl = r.floorNo;
1076
+ levels.value = { ...levels.value, [String(fl)]: { name: floorName(fl), elevationM: fl * 4, floorPolys: [], holePolys: [] } };
1077
+ // A selected lift stays selected (its Stops table now lists the floor); otherwise go to the new floor.
1078
+ const liftPicked = single.value?.kind === "lift";
1079
+ if (!liftPicked) floor.value = fl;
1080
+ state.value = { ...state.value, dirty: true };
1081
+ dispatch({ type: "notice", text: `${floorName(fl)} added.${liftPicked ? ` Tick Stops for ${floorName(fl)} below,` : " Select the lift shaft, tick Stops for it,"} then Save.`, ok: true });
1082
+ }
1065
1083
  function alignNow() {
1066
1084
  const r = alignFloor(state.value.shapes, state.value.frame, floor.value, alignTo.value);
1067
1085
  if ("error" in r) return void dispatch({ type: "notice", text: r.error!, ok: false });
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@7365admin1/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "4.122.1",
5
+ "version": "4.122.2",
6
6
  "author": "7365admin1",
7
7
  "main": "./nuxt.config.ts",
8
8
  "//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
@@ -1190,6 +1190,24 @@ export function editorReduce(state: TEditorState, action: TEditorAction): TEdito
1190
1190
  }
1191
1191
  }
1192
1192
 
1193
+ /** Floor numbers the API accepts (robot-building-map floorNo). */
1194
+ export const FLOOR_MIN = -20;
1195
+ export const FLOOR_MAX = 200;
1196
+
1197
+ /**
1198
+ * The editor's "Add floor" answer, checked: a whole number (1 = L1, 0 = G,
1199
+ * -1 = B1) in the API's range and not already a floor - or the reason not.
1200
+ */
1201
+ export function newFloorNo(input: string | null | undefined, existing: number[]): { floorNo: number } | { error: string } {
1202
+ const t = String(input ?? "").trim().toUpperCase();
1203
+ const m = /^(?:([LB])(\d+)|(-?\d+))$/.exec(t);
1204
+ const n = t === "G" ? 0 : m ? (m[3] !== undefined ? Number(m[3]) : m[1] === "B" ? -Number(m[2]) : Number(m[2])) : NaN;
1205
+ if (!Number.isInteger(n)) return { error: `"${String(input ?? "").trim()}" is not a floor. Type a whole number: 1 for L1, 0 for G, -1 for B1.` };
1206
+ if (n < FLOOR_MIN || n > FLOOR_MAX) return { error: `Floors go from ${floorName(FLOOR_MIN)} to ${floorName(FLOOR_MAX)}.` };
1207
+ if (existing.includes(n)) return { error: `${floorName(n)} is already a floor - pick it in the floor list.` };
1208
+ return { floorNo: n };
1209
+ }
1210
+
1193
1211
  /**
1194
1212
  * Why Save must wait, in plain words - or null. The handoff's sentence for
1195
1213
  * an unnamed zone; then what the API would refuse (a lift on one floor,
@@ -1205,7 +1223,7 @@ export function editorProblem(state: TEditorState): string | null {
1205
1223
  const lonely = state.shapes.find((s) => s.kind === "lift" && (s.floors?.length ?? 0) < 2);
1206
1224
  if (lonely) {
1207
1225
  const a = shapeAnchor(lonely);
1208
- return `Can't save yet: the lift shaft at (${a.x}, ${a.y}) serves only one floor. A lift needs at least two floors - this building's robots report only ${floorName(lonely.floorNo)}.`;
1226
+ return `Can't save yet: the lift shaft at (${a.x}, ${a.y}) serves only one floor. A lift needs at least two floors - select it and tick Stops for another floor (use Add floor beside the floor list if that floor is not there yet).`;
1209
1227
  }
1210
1228
  const long = state.shapes.find((s) => (s.kind === "zone" || s.kind === "waypoint" || s.kind === "fiducial") && (s.name ?? "").length > 60);
1211
1229
  if (long) return `Can't save yet: the name "${long.name!.slice(0, 20)}…" is too long. Use 60 characters or fewer.`;