@7365admin1/layer-common 4.97.1-staging.695 → 4.97.1-staging.697
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.
|
@@ -19,6 +19,18 @@
|
|
|
19
19
|
</v-row>
|
|
20
20
|
</v-col>
|
|
21
21
|
|
|
22
|
+
<v-col cols="12">
|
|
23
|
+
<v-row no-gutters>
|
|
24
|
+
<InputLabel class="text-capitalize font-weight-bold" title="Block Name (optional)" />
|
|
25
|
+
<v-col cols="12">
|
|
26
|
+
<v-text-field v-model="building.name" class="filter-field" density="comfortable" maxlength="60"
|
|
27
|
+
:placeholder="building.block ? `Leave empty for Blk ${building.block}` : 'e.g. Barbeque Pit'"
|
|
28
|
+
hint="Use a name for a facility guards send visitors to, e.g. Barbeque Pit. Empty = Blk + Block No."
|
|
29
|
+
persistent-hint></v-text-field>
|
|
30
|
+
</v-col>
|
|
31
|
+
</v-row>
|
|
32
|
+
</v-col>
|
|
33
|
+
|
|
22
34
|
<v-col cols="6" class="mt-2">
|
|
23
35
|
<v-row no-gutters>
|
|
24
36
|
<InputLabel class="text-capitalize font-weight-bold" title="No. of Levels" required />
|
|
@@ -47,6 +59,12 @@
|
|
|
47
59
|
|
|
48
60
|
<v-expand-transition>
|
|
49
61
|
<v-row v-if="prop.mode === 'edit'" no-gutters class="px-6">
|
|
62
|
+
<v-col cols="12" class="mb-2">
|
|
63
|
+
<InputLabel class="text-capitalize font-weight-bold" title="Block Name (optional)" />
|
|
64
|
+
<v-text-field v-model="building.name" class="filter-field" density="comfortable" maxlength="60"
|
|
65
|
+
:placeholder="`Leave empty for Blk ${building.block}`"
|
|
66
|
+
hint="Empty = Blk + Block No. Another property may use the same name." persistent-hint></v-text-field>
|
|
67
|
+
</v-col>
|
|
50
68
|
<template v-for="(level, levelIndex) in building.levels" :key="levelIndex">
|
|
51
69
|
<v-col cols="12">
|
|
52
70
|
<v-row no-gutters>
|
|
@@ -187,7 +205,7 @@
|
|
|
187
205
|
|
|
188
206
|
<script setup lang="ts">
|
|
189
207
|
import InputLabel from './InputLabel.vue';
|
|
190
|
-
import {
|
|
208
|
+
import { blockNameFor, normaliseBlock, BLOCK_NO_MESSAGE } from "../utils/building-block";
|
|
191
209
|
|
|
192
210
|
const prop = defineProps({
|
|
193
211
|
site: {
|
|
@@ -353,7 +371,7 @@ async function submit() {
|
|
|
353
371
|
try {
|
|
354
372
|
if (prop.mode === "add") {
|
|
355
373
|
const buildingPayload = { ...building.value };
|
|
356
|
-
//
|
|
374
|
+
// The block's own name if typed (e.g. "Barbeque Pit"), else "Blk 3". Unique within this site only.
|
|
357
375
|
const blockNo = normaliseBlock(buildingPayload.block);
|
|
358
376
|
if (blockNo === null) {
|
|
359
377
|
message.value = BLOCK_NO_MESSAGE;
|
|
@@ -364,9 +382,9 @@ async function submit() {
|
|
|
364
382
|
message.value = `Block ${blockNo} already exists. Choose a different Block No.`;
|
|
365
383
|
return;
|
|
366
384
|
}
|
|
367
|
-
const name =
|
|
385
|
+
const name = blockNameFor(blockNo, buildingPayload.name);
|
|
368
386
|
if (prop.blocks.some((b) => b.name?.trim().toLowerCase() === name.toLowerCase() && b.block !== blockNo)) {
|
|
369
|
-
message.value = `Another block is already named "${name}".
|
|
387
|
+
message.value = `Another block in this site is already named "${name}". Choose a different name.`;
|
|
370
388
|
return;
|
|
371
389
|
}
|
|
372
390
|
|
|
@@ -390,8 +408,13 @@ async function submit() {
|
|
|
390
408
|
|
|
391
409
|
const newLevels = [...newLevelsArray.value, ...(activeNewLevelInput.value.trim() ? [activeNewLevelInput.value.trim()] : [])];
|
|
392
410
|
|
|
411
|
+
const editedName = blockNameFor(building.value.block, building.value.name);
|
|
412
|
+
if (prop.blocks.some((b: any) => b._id !== building.value._id && b.name?.trim().toLowerCase() === editedName.toLowerCase())) {
|
|
413
|
+
message.value = `Another block in this site is already named "${editedName}". Choose a different name.`;
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
393
416
|
await updateById(building.value._id ?? "", {
|
|
394
|
-
name:
|
|
417
|
+
name: editedName,
|
|
395
418
|
block: building.value.block,
|
|
396
419
|
// levels: building.value.levels,
|
|
397
420
|
buildingFiles: (building.value.buildingFiles as string[] || []).map((id) => ({ id, name: buildingFilesNames.value[id] ?? "" })),
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
<template #prepend-additional>
|
|
23
23
|
<AppField v-model="searchInput" search compact placeholder="Search" klass="app-toolbar__search" />
|
|
24
24
|
</template>
|
|
25
|
-
<template #item.block="{ value }">{{ value
|
|
25
|
+
<template #item.block="{ value, item }">{{ blockDisplay(value, (item as any)?.name) }}</template>
|
|
26
26
|
<template #item.createdAt="{ value }">
|
|
27
27
|
{{ new Date(value).toLocaleDateString() }}
|
|
28
28
|
</template>
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
<v-row no-gutters class="mb-4">
|
|
56
56
|
<v-col cols="12">
|
|
57
57
|
<strong>Block:</strong>
|
|
58
|
-
{{ selectedBuilding?.block ?
|
|
58
|
+
{{ selectedBuilding?.block ? blockDisplay(selectedBuilding.block, selectedBuilding?.name) : "N/A" }}
|
|
59
59
|
</v-col>
|
|
60
60
|
|
|
61
61
|
<v-col cols="12">
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
// Relative import, never Nuxt auto-import: this layer's `utils/` are auto-imported
|
|
159
159
|
// into the consuming apps but not reliably into the layer's own components.
|
|
160
160
|
import { levelCount } from "../../utils/data";
|
|
161
|
-
import {
|
|
161
|
+
import { blockDisplay } from "../../utils/building-block";
|
|
162
162
|
|
|
163
163
|
|
|
164
164
|
const props = defineProps({
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
<AppField v-model="searchInput" search compact placeholder="Search" klass="app-toolbar__search" />
|
|
51
51
|
</template>
|
|
52
52
|
<template #item.block="{ value, item }">
|
|
53
|
-
{{ value
|
|
53
|
+
{{ blockDisplay(value, (item as any)?.buildingName) }}
|
|
54
54
|
</template>
|
|
55
55
|
</TableMain>
|
|
56
56
|
|
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
|
|
175
175
|
<script setup lang="ts">
|
|
176
176
|
import useImportTemplates from "../../composables/useImportTemplates";
|
|
177
|
-
import {
|
|
177
|
+
import { blockDisplay } from "../../utils/building-block";
|
|
178
178
|
import { saveBlob } from "../../composables/useInventory";
|
|
179
179
|
import { useDisplay } from 'vuetify/lib/composables/display.mjs';
|
|
180
180
|
|
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.97.1-staging.
|
|
5
|
+
"version": "4.97.1-staging.697",
|
|
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.",
|
package/utils/building-block.ts
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
|
-
/** The
|
|
1
|
+
/** The default block label: "Blk 3", "Blk 12A" - used as the block's name when no name is typed. */
|
|
2
2
|
export const blockLabel = (block: number | string | null | undefined): string => `Blk ${block}`;
|
|
3
3
|
|
|
4
|
+
/** The name a block is saved with: what was typed (e.g. "Barbeque Pit"), or "Blk N" when left empty. */
|
|
5
|
+
export function blockNameFor(block: number | string | null | undefined, typed?: string | null): string {
|
|
6
|
+
return String(typed ?? "").trim() || blockLabel(block);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** How a block shows in lists: "Blk 7", or "Blk 7 - Barbeque Pit" when it has its own name. */
|
|
10
|
+
export function blockDisplay(block: number | string | null | undefined, name?: string | null): string {
|
|
11
|
+
if (block === null || block === undefined || block === "") return String(name ?? "").trim();
|
|
12
|
+
const label = blockLabel(block);
|
|
13
|
+
const own = String(name ?? "").trim();
|
|
14
|
+
return own && own.toLowerCase() !== label.toLowerCase() ? `${label} - ${own}` : label;
|
|
15
|
+
}
|
|
16
|
+
|
|
4
17
|
export const BLOCK_NO_MESSAGE = "Block No must be a number from 1 to 9999, optionally followed by one letter (for example 12 or 12A).";
|
|
5
18
|
|
|
6
19
|
/**
|
|
@@ -391,6 +391,18 @@ function plateSizeMm(plate: string, boxW: number, max = 4.6): number {
|
|
|
391
391
|
return Math.round(Math.min(max, (boxW / Math.max(plate.length, 1) - 0.3) / 0.74) * 100) / 100;
|
|
392
392
|
}
|
|
393
393
|
|
|
394
|
+
/**
|
|
395
|
+
* Plate size inside a shape's tag. With the serial printed under it (a blank
|
|
396
|
+
* sticker's two-line code + its number), the plate shrinks so both fit the tag:
|
|
397
|
+
* lines at 1.1 x size, the serial row 1.2 x 5.8 pt, 0.6 mm between.
|
|
398
|
+
*/
|
|
399
|
+
export function tagPlateSizeMm(longest: string, tag: { w: number; h: number }, lines: number, withSerial: boolean, k = 1): number {
|
|
400
|
+
const size = plateSizeMm(longest, tag.w, 4.6 * k);
|
|
401
|
+
if (!withSerial || !lines) return size;
|
|
402
|
+
const room = (tag.h - 1.2 * 5.8 * PT - 0.6) / (1.1 * lines);
|
|
403
|
+
return Math.round(Math.max(0.5, Math.min(size, room)) * 100) / 100;
|
|
404
|
+
}
|
|
405
|
+
|
|
394
406
|
/**
|
|
395
407
|
* One full HTML document: A4 sheets of stickers. `faceSvgs` is parallel to
|
|
396
408
|
* `items` (each sticker's frame + QR, already drawn for the chosen design).
|
|
@@ -425,14 +437,14 @@ function cardHtml(item: StickerItem, face: string, c: CardContext): string {
|
|
|
425
437
|
const longest = lines.reduce((a, l) => (l.length > a.length ? l : a), "");
|
|
426
438
|
// a two-line code has no room for the words under it inside the tag
|
|
427
439
|
const label = c.label && !(c.tag && lines.length > 1) ? `<div class="hint">${escapeHtml(c.label)}</div>` : "";
|
|
428
|
-
// the serial takes the words' place inside a shape's tag
|
|
440
|
+
// the serial takes the words' place inside a shape's tag; a two-line blank code shrinks to make room for it
|
|
429
441
|
const serial = serialText ? `<div class="serial">${escapeHtml(serialText)}</div>` : "";
|
|
430
|
-
const tagWords = serial && c.tag ?
|
|
442
|
+
const tagWords = serial && c.tag ? serial : label;
|
|
431
443
|
const words = c.shaped && !c.tag
|
|
432
444
|
? ""
|
|
433
445
|
: c.tag
|
|
434
446
|
? `<div class="words band" style="left:${c.tag.x}mm;right:auto;top:${c.tag.y}mm;width:${c.tag.w}mm;height:${c.tag.h}mm">` +
|
|
435
|
-
(lines.length ? `<div class="plate" style="font-size:${
|
|
447
|
+
(lines.length ? `<div class="plate" style="font-size:${tagPlateSizeMm(longest, c.tag, lines.length, !!serial && lines.length > 1, c.k)}mm">${plate}</div>` : "") +
|
|
436
448
|
tagWords +
|
|
437
449
|
`</div>`
|
|
438
450
|
: `<div class="words" style="top:${c.wordsTop}mm${!lines.length && !label ? ";justify-content:center" : ""}">` +
|
|
@@ -457,9 +469,8 @@ export function buildStickerDocument(
|
|
|
457
469
|
const design = opts.design ?? DEFAULT_STICKER_DESIGN;
|
|
458
470
|
const n = opts.modules ?? STICKER_QR_MODULES;
|
|
459
471
|
const c = cardContext(design, opts.siteName, n);
|
|
460
|
-
// the strip carries the number when chosen - and when the sticker has no
|
|
461
|
-
|
|
462
|
-
const noRoom = (item: StickerItem) => (c.shaped && !c.tag) || (!!c.tag && shownPlateLines(item, c.hidePlate).length > 1);
|
|
472
|
+
// the strip carries the number when chosen - and when the sticker has no words at all (a bare shape)
|
|
473
|
+
const noRoom = (_item: StickerItem) => c.shaped && !c.tag;
|
|
463
474
|
const stripSerial = (item: StickerItem) => design.serial === "strip" || design.serial === "both" || (c.serial && noRoom(item));
|
|
464
475
|
const cells = items.map((item, i) => {
|
|
465
476
|
const { place, owner } = installerLine(item);
|
|
@@ -500,7 +511,7 @@ function cardWordsSvg(item: StickerItem, c: CardContext): string {
|
|
|
500
511
|
const longest = lines.reduce((a, l) => (l.length > a.length ? l : a), "");
|
|
501
512
|
const box = c.tag ?? { x: 3, y: c.wordsTop, w: c.cardW - 6, h: c.layout.cardH - 2 - c.wordsTop };
|
|
502
513
|
const plateSize = c.tag
|
|
503
|
-
?
|
|
514
|
+
? tagPlateSizeMm(longest, c.tag, lines.length, !!serialText && lines.length > 1, c.k)
|
|
504
515
|
: lines.length > 1 ? plateSizeMm(longest, c.cardW - 6, 4.6) : 13 * PT;
|
|
505
516
|
const small = 5.8 * PT;
|
|
506
517
|
type Row = { h: number; draw: (top: number) => string };
|
|
@@ -519,7 +530,7 @@ function cardWordsSvg(item: StickerItem, c: CardContext): string {
|
|
|
519
530
|
});
|
|
520
531
|
const label = c.label && !(c.tag && lines.length > 1) ? c.label : "";
|
|
521
532
|
if (c.tag) {
|
|
522
|
-
if (serialText
|
|
533
|
+
if (serialText) rows.push(word(serialText, true));
|
|
523
534
|
else if (!serialText && label) rows.push(word(label, false));
|
|
524
535
|
} else {
|
|
525
536
|
if (serialText) rows.push(word(serialText, true));
|