@7365admin1/layer-common 4.97.1-staging.695 → 4.97.1-staging.696
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.696",
|
|
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
|
/**
|