@7365admin1/layer-common 4.97.1-staging.691 → 4.97.1-staging.693
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/components/BuildingForm.vue +17 -46
- package/components/HidUserEnrollment.vue +1 -1
- package/components/PeopleForm.vue +3 -2
- package/components/SiteSettings.vue +5 -1
- package/composables/usePropertyPermission.ts +8 -0
- package/composables/useSecurityUtils.ts +1 -1
- package/composables/useSiteSettings.ts +2 -2
- package/package.json +1 -1
- package/types/building.d.ts +2 -2
- package/utils/building-block.ts +18 -1
|
@@ -13,18 +13,8 @@
|
|
|
13
13
|
<v-row no-gutters>
|
|
14
14
|
<InputLabel class="text-capitalize font-weight-bold" title="Block No." required />
|
|
15
15
|
<v-col cols="12">
|
|
16
|
-
<v-
|
|
17
|
-
|
|
18
|
-
requiredRule,
|
|
19
|
-
() =>
|
|
20
|
-
(building.block && building.block > 0) ||
|
|
21
|
-
'Block is required',
|
|
22
|
-
]" type="number">
|
|
23
|
-
<template v-slot:item="{ props: itemProps, item }">
|
|
24
|
-
<v-list-item v-bind="itemProps" :disabled="item?.raw?.disabled"></v-list-item>
|
|
25
|
-
</template>
|
|
26
|
-
|
|
27
|
-
</v-select>
|
|
16
|
+
<v-text-field v-model.trim="building.block" class="filter-field" density="comfortable"
|
|
17
|
+
placeholder="e.g. 12 or 12A" maxlength="5" :rules="[requiredRule, blockRule]"></v-text-field>
|
|
28
18
|
</v-col>
|
|
29
19
|
</v-row>
|
|
30
20
|
</v-col>
|
|
@@ -197,7 +187,7 @@
|
|
|
197
187
|
|
|
198
188
|
<script setup lang="ts">
|
|
199
189
|
import InputLabel from './InputLabel.vue';
|
|
200
|
-
import { blockLabel } from "../utils/building-block";
|
|
190
|
+
import { blockLabel, normaliseBlock, BLOCK_NO_MESSAGE } from "../utils/building-block";
|
|
201
191
|
|
|
202
192
|
const prop = defineProps({
|
|
203
193
|
site: {
|
|
@@ -224,40 +214,11 @@ const prop = defineProps({
|
|
|
224
214
|
},
|
|
225
215
|
});
|
|
226
216
|
|
|
227
|
-
const { getSiteById } = useSite();
|
|
228
217
|
const { getFileById } = useFile();
|
|
229
218
|
const { deleteById, batchUpdateLevels } = useBuildingLevel();
|
|
230
219
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
const { data: getSiteReq } = useLazyAsyncData(
|
|
234
|
-
"get-site-by-id-" + prop.site,
|
|
235
|
-
async () => getSiteById(prop.site)
|
|
236
|
-
);
|
|
237
|
-
|
|
238
|
-
watchEffect(() => {
|
|
239
|
-
if (getSiteReq.value) {
|
|
240
|
-
site.value = getSiteReq.value;
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
const blocks = computed(() => {
|
|
245
|
-
if (!site.value) return [];
|
|
246
|
-
// return
|
|
247
|
-
// return [ { label: "1", value: 1, disabled: true }, { label: "2", value: 2 }, { label: "3", value: 3 } ];
|
|
248
|
-
const array = Array.from({ length: site.value?.metadata?.block || 0 }, (_, i) => i + 1);
|
|
249
|
-
|
|
250
|
-
const formattedArray = array.map((num) => {
|
|
251
|
-
const isDisabled = prop.blocks.some((block) => block.block === num)
|
|
252
|
-
return {
|
|
253
|
-
label: num.toString(),
|
|
254
|
-
value: num,
|
|
255
|
-
disabled: isDisabled
|
|
256
|
-
};
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
return formattedArray;
|
|
260
|
-
});
|
|
220
|
+
// Block No: digits with at most one letter (12, 12A). The site's "number of blocks" no longer caps it.
|
|
221
|
+
const blockRule = (v: unknown) => normaliseBlock(v) !== null || BLOCK_NO_MESSAGE;
|
|
261
222
|
|
|
262
223
|
const emit = defineEmits(["cancel", "success", "success:create-more", "refresh"]);
|
|
263
224
|
|
|
@@ -393,8 +354,18 @@ async function submit() {
|
|
|
393
354
|
if (prop.mode === "add") {
|
|
394
355
|
const buildingPayload = { ...building.value };
|
|
395
356
|
// One block field only: the stored name is derived from the number ("Blk 3").
|
|
396
|
-
const
|
|
397
|
-
if (
|
|
357
|
+
const blockNo = normaliseBlock(buildingPayload.block);
|
|
358
|
+
if (blockNo === null) {
|
|
359
|
+
message.value = BLOCK_NO_MESSAGE;
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
buildingPayload.block = blockNo;
|
|
363
|
+
if (prop.blocks.some((b) => normaliseBlock(b.block) === blockNo)) {
|
|
364
|
+
message.value = `Block ${blockNo} already exists. Choose a different Block No.`;
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
const name = blockLabel(blockNo);
|
|
368
|
+
if (prop.blocks.some((b) => b.name?.trim().toLowerCase() === name.toLowerCase() && b.block !== blockNo)) {
|
|
398
369
|
message.value = `Another block is already named "${name}". Rename it first, or choose a different Block No.`;
|
|
399
370
|
return;
|
|
400
371
|
}
|
|
@@ -1512,7 +1512,7 @@ type OccupiedLevel = { _id: string; name: string; units?: OccupiedUnit[] };
|
|
|
1512
1512
|
type OccupiedBlock = {
|
|
1513
1513
|
_id: string;
|
|
1514
1514
|
name: string;
|
|
1515
|
-
block: number | null;
|
|
1515
|
+
block: number | string | null;
|
|
1516
1516
|
levels?: OccupiedLevel[];
|
|
1517
1517
|
};
|
|
1518
1518
|
type UnitPerson = {
|
|
@@ -119,6 +119,7 @@
|
|
|
119
119
|
|
|
120
120
|
<script setup lang="ts">
|
|
121
121
|
import { property } from 'zod/v4';
|
|
122
|
+
import { normaliseBlock } from '../utils/building-block';
|
|
122
123
|
|
|
123
124
|
const prop = defineProps({
|
|
124
125
|
org: {
|
|
@@ -205,14 +206,14 @@ const { data: levelsData, refresh: refreshLevelsData, status: levelsStatus } = u
|
|
|
205
206
|
`fetch-levels-data-${prop.site}-${form.block}`,
|
|
206
207
|
async () => {
|
|
207
208
|
if (!form.block) return Promise.resolve(null);
|
|
208
|
-
return await getSiteLevels(prop.site, { block:
|
|
209
|
+
return await getSiteLevels(prop.site, { block: normaliseBlock(form.block) ?? form.block })
|
|
209
210
|
}, { watch: [() => form.block],});
|
|
210
211
|
|
|
211
212
|
const { data: unitsData, refresh: refreshUnitsData, status: unitsStatus } = useLazyAsyncData(
|
|
212
213
|
`fetch-units-data-${prop.site}-${form.level}`,
|
|
213
214
|
async () => {
|
|
214
215
|
if (!form.level) return Promise.resolve(null);
|
|
215
|
-
return await getSiteUnits(prop.site,
|
|
216
|
+
return await getSiteUnits(prop.site, normaliseBlock(form.block) ?? form.block, form.level)
|
|
216
217
|
}, { watch: [()=> form.level]});
|
|
217
218
|
|
|
218
219
|
watch(
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
</v-expansion-panel>
|
|
110
110
|
|
|
111
111
|
<!-- ANPR CAMERA -->
|
|
112
|
-
<v-expansion-panel v-if="showAnprCamera && canManageANPRCamera">
|
|
112
|
+
<v-expansion-panel v-if="showAnprCamera && canManageANPRCamera && anprModuleOn">
|
|
113
113
|
<v-expansion-panel-title>
|
|
114
114
|
<v-icon class="mr-2">mdi-camera</v-icon>
|
|
115
115
|
ANPR Camera
|
|
@@ -319,6 +319,7 @@ import useSiteSettings from "../composables/useSiteSettings";
|
|
|
319
319
|
import useUtils from "../composables/useUtils";
|
|
320
320
|
import useANPRSettings from "../composables/useANPRSettings";
|
|
321
321
|
import useVehicle from "../composables/useVehicle";
|
|
322
|
+
import { permissionsDenied } from "../utils/module-routes";
|
|
322
323
|
import { SERIAL_DEFAULT_DIGITS, SERIAL_PREFIX_PATTERN, cleanSerialPrefix, formatStickerSerial } from "../utils/vehicle-qr-blank";
|
|
323
324
|
|
|
324
325
|
const props = defineProps({
|
|
@@ -347,6 +348,9 @@ const { canManageSiteInformation,
|
|
|
347
348
|
canManageSiteSettings: canManageAnySiteSetting,
|
|
348
349
|
} = useSettingsPermission();
|
|
349
350
|
const { canManageHidSettings } = useHidAccessPermission();
|
|
351
|
+
// ANPR serves vehicles and visitors: hide the panel when the client has neither module (denied list, same as the menu gate).
|
|
352
|
+
const { userAppModulesDenied } = useLocalSetup();
|
|
353
|
+
const anprModuleOn = computed(() => !permissionsDenied(["vehicle-mgmt:x", "visitor-mgmt:x"], userAppModulesDenied?.value));
|
|
350
354
|
|
|
351
355
|
const { getSiteById, updateSitebyId, updateSiteInformation } =
|
|
352
356
|
useSiteSettings();
|
|
@@ -438,6 +438,14 @@ export default function usePropertyPermission() {
|
|
|
438
438
|
check: true,
|
|
439
439
|
description: "Allows the user to approve or reject incident report.",
|
|
440
440
|
},
|
|
441
|
+
"add-incident-report": {
|
|
442
|
+
check: true,
|
|
443
|
+
description: "Allows the user to add a new incident report.",
|
|
444
|
+
},
|
|
445
|
+
"update-incident-report": {
|
|
446
|
+
check: true,
|
|
447
|
+
description: "Allows the user to update an incident report.",
|
|
448
|
+
},
|
|
441
449
|
},
|
|
442
450
|
|
|
443
451
|
"vehicle-mgmt": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default function(){
|
|
2
2
|
|
|
3
|
-
const formatLocation = ({block, level, unit}: {block: number, level: string, unit: string | TBuildingUnit}) => {
|
|
3
|
+
const formatLocation = ({block, level, unit}: {block: number | string, level: string, unit: string | TBuildingUnit}) => {
|
|
4
4
|
const parts = [];
|
|
5
5
|
|
|
6
6
|
if (block?.name) parts.push(`${block.name}`);
|
|
@@ -8,7 +8,7 @@ export default function () {
|
|
|
8
8
|
);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
async function getSiteLevels(siteId: string, query: { block: number }) {
|
|
11
|
+
async function getSiteLevels(siteId: string, query: { block: number | string }) {
|
|
12
12
|
return await useNuxtApp().$api<Record<string, any>>(
|
|
13
13
|
`/api/buildings/site/${siteId}`,
|
|
14
14
|
{
|
|
@@ -18,7 +18,7 @@ export default function () {
|
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
async function getSiteUnits(siteId: string, block: number, level: string) {
|
|
21
|
+
async function getSiteUnits(siteId: string, block: number | string, level: string) {
|
|
22
22
|
return await useNuxtApp().$api<Record<string, any>>(
|
|
23
23
|
`/api/building-units/site/${siteId}/block/${block}/level/${level}`,
|
|
24
24
|
{
|
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.693",
|
|
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/types/building.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ declare type TBuilding = {
|
|
|
2
2
|
_id?: string;
|
|
3
3
|
site: string;
|
|
4
4
|
name: string;
|
|
5
|
-
block: number | null;
|
|
5
|
+
block: number | string | null;
|
|
6
6
|
levels: { _id: string; name: string }[];
|
|
7
7
|
buildingFiles: { id: string, name: string }[] | string[];
|
|
8
8
|
};
|
|
@@ -15,7 +15,7 @@ declare type TBuildingUnit = {
|
|
|
15
15
|
ownerName?: string;
|
|
16
16
|
building: string;
|
|
17
17
|
buildingName?: string;
|
|
18
|
-
block: number | null;
|
|
18
|
+
block: number | string | null;
|
|
19
19
|
level: { _id: string; name: string } | null;
|
|
20
20
|
category: string;
|
|
21
21
|
status: string;
|
package/utils/building-block.ts
CHANGED
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
/** The one block label used everywhere: "Blk 3". Block names are no longer typed; they come from the number. */
|
|
1
|
+
/** The one block label used everywhere: "Blk 3", "Blk 12A". Block names are no longer typed; they come from the number. */
|
|
2
2
|
export const blockLabel = (block: number | string | null | undefined): string => `Blk ${block}`;
|
|
3
|
+
|
|
4
|
+
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
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Block No: 1-4 digits and at most one capital letter. Same rule as the API (core): trim, capitals,
|
|
8
|
+
* drop "Blk"/"Block" and leading zeros. Digits only -> a number; with a letter -> a string ("12A").
|
|
9
|
+
*/
|
|
10
|
+
export function normaliseBlock(input: unknown): number | string | null {
|
|
11
|
+
if (typeof input === "number") return Number.isInteger(input) && input >= 1 && input <= 9999 ? input : null;
|
|
12
|
+
if (typeof input !== "string") return null;
|
|
13
|
+
const s = input.trim().toUpperCase().replace(/^(BLK|BLOCK)\.?\s*/, "").replace(/^0+(?=\d)/, "");
|
|
14
|
+
const m = /^(\d{1,4})([A-Z]?)$/.exec(s);
|
|
15
|
+
if (!m) return null;
|
|
16
|
+
const n = Number(m[1]);
|
|
17
|
+
if (n < 1) return null;
|
|
18
|
+
return m[2] ? `${n}${m[2]}` : n;
|
|
19
|
+
}
|