@7365admin1/layer-common 4.21.4-staging.339 → 4.21.4-staging.341

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.
@@ -9,6 +9,23 @@
9
9
  <template>
10
10
  <!-- Only drawn when the plate is on at least one camera (inactive ones
11
11
  included - a camera that went inactive still holds the plate). -->
12
+ <!-- "Sync": the plate is on fewer cameras than the site has active for its
13
+ list (e.g. it was saved while they were inactive). Puts it on every
14
+ active camera of its list that lacks it. -->
15
+ <button
16
+ v-if="showSync"
17
+ type="button"
18
+ class="anpr-badge anpr-badge--sync"
19
+ :disabled="syncing"
20
+ :aria-label="`Sync ${plateNumber} to all active ANPR cameras`"
21
+ v-tooltip:top="`On ${count} of ${expected} active camera${expected === 1 ? '' : 's'} - sync to all`"
22
+ @click.stop="sync"
23
+ >
24
+ <v-progress-circular v-if="syncing" indeterminate size="11" width="2" />
25
+ <v-icon v-else icon="mdi-sync" size="13" />
26
+ Sync
27
+ </button>
28
+
12
29
  <v-menu v-if="count > 0" location="bottom start" :close-on-content-click="false">
13
30
  <template #activator="{ props: menuProps }">
14
31
  <button
@@ -35,9 +52,9 @@
35
52
  <div v-for="cam in uniqueCameras" :key="cam.host || cam.camera || cam.name" class="anpr-badge__row">
36
53
  <span class="anpr-badge__type">{{ directionLabel(cam.direction) }}</span>
37
54
  <StatusChip
38
- :tone="cam.list === 'blocked' ? 'err' : 'ok'"
55
+ :tone="listTone(cam.list)"
39
56
  :dot="false"
40
- :label="cam.list === 'blocked' ? 'Blocked' : 'Allowed'"
57
+ :label="listLabel(cam.list)"
41
58
  />
42
59
  </div>
43
60
  </v-card>
@@ -45,14 +62,83 @@
45
62
  </template>
46
63
 
47
64
  <script setup lang="ts">
65
+ import useVehicle from "../composables/useVehicle";
66
+ import { errorConverter } from "../utils/data";
67
+
48
68
  const props = defineProps({
49
69
  cameras: {
50
70
  type: Array as PropType<TVehicleAnprCamera[]>,
51
71
  default: () => [],
52
72
  },
53
73
  plateNumber: { type: String, default: "" },
74
+ /** For Sync: the plate's own record, its status and list. */
75
+ plateId: { type: String, default: "" },
76
+ status: { type: String, default: "" },
77
+ type: { type: String, default: "" },
78
+ /** The pass's expiry: once passed, "Allowed" reads "Expired" in red. */
79
+ end: { type: [String, Date] as PropType<string | Date | null>, default: null },
80
+ /** Active cameras per list at the site; null hides Sync. */
81
+ activeCounts: {
82
+ type: Object as PropType<{ allowed: number; blocked: number } | null>,
83
+ default: null,
84
+ },
54
85
  });
55
86
 
87
+ const emit = defineEmits<{
88
+ (event: "synced", result: { ok: boolean; message: string }): void;
89
+ }>();
90
+
91
+ const { syncVehicle } = useVehicle();
92
+ const syncing = ref(false);
93
+
94
+ const LIVE = ["active", "temporary", "blocked"];
95
+
96
+ /** Active cameras for this plate's list. */
97
+ const expected = computed(() => {
98
+ if (!props.activeCounts) return 0;
99
+ return props.type === "blocklist"
100
+ ? props.activeCounts.blocked
101
+ : props.activeCounts.allowed;
102
+ });
103
+
104
+ /** An allowed pass whose expiry has passed - the camera no longer opens for it. */
105
+ const expired = computed(() => {
106
+ if (!props.end) return false;
107
+ const end = new Date(props.end as any).getTime();
108
+ return !Number.isNaN(end) && end <= Date.now();
109
+ });
110
+
111
+ function listLabel(list: string) {
112
+ if (list === "blocked") return "Blocked";
113
+ return expired.value ? "Expired" : "Allowed";
114
+ }
115
+
116
+ function listTone(list: string) {
117
+ return list === "blocked" || expired.value ? "err" : "ok";
118
+ }
119
+
120
+ const showSync = computed(
121
+ () =>
122
+ !!props.plateId &&
123
+ !expired.value &&
124
+ LIVE.includes(props.status) &&
125
+ expected.value > 0 &&
126
+ count.value < expected.value
127
+ );
128
+
129
+ async function sync() {
130
+ if (syncing.value) return;
131
+ syncing.value = true;
132
+ try {
133
+ const res: any = await syncVehicle(props.plateId);
134
+ emit("synced", { ok: !res?.failed, message: res?.message || "Synced." });
135
+ } catch (error: any) {
136
+ emit("synced", { ok: false, message: errorConverter(error) });
137
+ } finally {
138
+ syncing.value = false;
139
+ }
140
+ }
141
+
56
142
  const DIRECTION_LABELS: Record<string, string> = {
57
143
  entry: "Entry",
58
144
  exit: "Exit",
@@ -79,7 +165,7 @@ const uniqueCameras = computed(() => {
79
165
  });
80
166
  });
81
167
 
82
- const count = computed(() => uniqueCameras.value.length);
168
+ const count = computed<number>(() => uniqueCameras.value.length);
83
169
  const isBlocked = computed(() => props.cameras?.some((c) => c.list === "blocked"));
84
170
  </script>
85
171
 
@@ -98,6 +184,17 @@ const isBlocked = computed(() => props.cameras?.some((c) => c.list === "blocked"
98
184
  cursor: pointer;
99
185
  }
100
186
 
187
+ .anpr-badge--sync {
188
+ margin-left: 4px;
189
+ color: var(--primary, rgb(var(--v-theme-primary)));
190
+ border-color: currentColor;
191
+ }
192
+
193
+ .anpr-badge--sync:disabled {
194
+ opacity: 0.6;
195
+ cursor: progress;
196
+ }
197
+
101
198
  .anpr-badge--blocked {
102
199
  color: var(--err);
103
200
  }
@@ -8,8 +8,12 @@
8
8
  :counter="maxlength"
9
9
  @input="onInput"
10
10
  :loading="loading"
11
+ :type="masked && !shown ? 'password' : 'text'"
12
+ :append-inner-icon="masked ? (shown ? 'mdi-eye-off' : 'mdi-eye') : undefined"
13
+ autocomplete="off"
11
14
  outlined
12
15
  clearable
16
+ @click:append-inner="shown = !shown"
13
17
  />
14
18
  </template>
15
19
 
@@ -31,9 +35,16 @@ const props = defineProps({
31
35
  loading: {
32
36
  type: Boolean,
33
37
  default: false
38
+ },
39
+ /** Shown as *** with an eye to reveal it, like a password. */
40
+ masked: {
41
+ type: Boolean,
42
+ default: false
34
43
  }
35
44
  })
36
45
 
46
+ const shown = ref(false)
47
+
37
48
  const emit = defineEmits(['update:modelValue'])
38
49
 
39
50
  const model = defineModel({required: true})
@@ -41,8 +52,9 @@ const model = defineModel({required: true})
41
52
  function onInput(event) {
42
53
  const value = typeof event === 'string' ? event : event?.target?.value || ''
43
54
 
44
- let formatted = value.replace(/[^A-Za-z0-9]/g, '')
45
- formatted = formatted.toUpperCase()
55
+ // Same rule as the Whitelist (Bulk) sheet (`bulkIdNumber`): capitals,
56
+ // digits and symbols such as - or /, but no spaces, commas or dots.
57
+ const formatted = value.replace(/[\s,.]/g, '').toUpperCase()
46
58
 
47
59
  model.value = formatted || ""
48
60
  }
@@ -9,6 +9,12 @@
9
9
  v-if="showCameras"
10
10
  :cameras="plate.anprCameras ?? []"
11
11
  :plate-number="plate.plateNumber"
12
+ :plate-id="plate._id ?? ''"
13
+ :status="plate.status ?? ''"
14
+ :type="plate.type ?? ''"
15
+ :end="plate.end ?? null"
16
+ :active-counts="activeCounts"
17
+ @synced="(result) => emit('synced', result)"
12
18
  />
13
19
  </span>
14
20
  <!-- A season pass's expiry under its number: green while valid, red
@@ -59,6 +65,11 @@ const props = defineProps({
59
65
  type: Boolean,
60
66
  default: false
61
67
  },
68
+ /** Active ANPR cameras per list at the site - lets the badge offer Sync. */
69
+ activeCounts: {
70
+ type: Object as PropType<{ allowed: number; blocked: number } | null>,
71
+ default: null
72
+ },
62
73
  /** The ANPR camera badge beside each vehicle number. */
63
74
  showCameras: {
64
75
  type: Boolean,
@@ -88,6 +99,10 @@ function expiryOf(plate: any): { label: string; expired: boolean } | null {
88
99
  }
89
100
  }
90
101
 
102
+ const emit = defineEmits<{
103
+ (event: "synced", result: { ok: boolean; message: string }): void
104
+ }>()
105
+
91
106
  const shownPlates = computed<any[]>(() => {
92
107
  const plates = (props.plateNumbers ?? []).filter((v: any) => v?.plateNumber)
93
108
  return props.showAll ? plates : plates.slice(0, 2)
@@ -69,6 +69,27 @@
69
69
  the Season Pass dialog report. An empty field has nothing unresolved
70
70
  to redraw, so it has nothing to gain from the remount.
71
71
  -->
72
+ <!-- A Block Listed vehicle's block / level / unit: taken from the
73
+ visitor transaction it was blocked from, and shown read-only -
74
+ here and when the vehicle is edited later. -->
75
+ <template v-if="readonlyLocation">
76
+ <v-col cols="12">
77
+ <InputLabel class="text-capitalize" title="Block" />
78
+ <v-text-field :model-value="readonlyLocation.block || 'N/A'" density="comfortable" readonly
79
+ class="class-readonly" />
80
+ </v-col>
81
+ <v-col cols="12">
82
+ <InputLabel class="text-capitalize" title="Level" />
83
+ <v-text-field :model-value="readonlyLocation.level || 'N/A'" density="comfortable" readonly
84
+ class="class-readonly" />
85
+ </v-col>
86
+ <v-col cols="12">
87
+ <InputLabel class="text-capitalize" title="Unit" />
88
+ <v-text-field :model-value="readonlyLocation.unit || 'N/A'" density="comfortable" readonly
89
+ class="class-readonly" />
90
+ </v-col>
91
+ </template>
92
+
72
93
  <v-col v-if="shouldShowField('block')" cols="12">
73
94
  <InputLabel class="text-capitalize" title="Block" required />
74
95
  <v-autocomplete
@@ -131,6 +152,7 @@
131
152
  <InputNRICNumber
132
153
  v-model="vehicle.nric"
133
154
  density="comfortable"
155
+ masked
134
156
  :disabled="
135
157
  disablePrefilledInputs &&
136
158
  type !== 'blocklist' &&
@@ -253,7 +275,8 @@
253
275
  </v-col>
254
276
  </v-row>
255
277
 
256
- <AppButton variant="ghost" icon="mdi-plus" @click="addPlate">
278
+ <!-- One vehicle number per Block Listed vehicle. -->
279
+ <AppButton v-if="type !== 'blocklist'" variant="ghost" icon="mdi-plus" @click="addPlate">
257
280
  Add Plate
258
281
  </AppButton>
259
282
  </template>
@@ -539,6 +562,18 @@ const prop = defineProps({
539
562
  type: String,
540
563
  default: "",
541
564
  },
565
+ /**
566
+ * Blocking from a visitor transaction: the visit's block / level / unit,
567
+ * saved on the Block Listed vehicle and shown read-only.
568
+ */
569
+ presetLocation: {
570
+ type: Object as PropType<{
571
+ block?: { id: string; name: string };
572
+ level?: { id: string; name: string };
573
+ unit?: { id: string; name: string };
574
+ } | null>,
575
+ default: null,
576
+ },
542
577
  });
543
578
 
544
579
  const { requiredRule, debounce } = useUtils();
@@ -587,6 +622,40 @@ const vehicle = reactive<
587
622
  plateNumber: "",
588
623
  });
589
624
 
625
+ /**
626
+ * The read-only Block / Level / Unit of a Block Listed vehicle: from the
627
+ * visitor transaction when blocking from Visitor Mgmt, or the location the
628
+ * vehicle already has when it is edited. Null when there is none to show.
629
+ */
630
+ const readonlyLocation = computed(() => {
631
+ if (prop.type !== "blocklist") return null;
632
+
633
+ if (prop.mode === "add") {
634
+ const loc = prop.presetLocation;
635
+ if (!loc) return null;
636
+ const out = {
637
+ block: loc.block?.name ?? "",
638
+ level: loc.level?.name ?? "",
639
+ unit: loc.unit?.name ?? "",
640
+ };
641
+ return out.block || out.level || out.unit ? out : null;
642
+ }
643
+
644
+ const data: any = prop.vehicleData ?? {};
645
+ const nameOf = (value: any) => {
646
+ if (!value) return "";
647
+ if (typeof value === "object") return String(value.name ?? "");
648
+ return String(prop.nameHints?.[String(value)] ?? "");
649
+ };
650
+ const hasAny = data.block || data.level || data.unit;
651
+ if (!hasAny) return null;
652
+ return {
653
+ block: nameOf(data.block),
654
+ level: nameOf(data.level),
655
+ unit: nameOf(data.unit) || String(data.unitName ?? ""),
656
+ };
657
+ });
658
+
590
659
  const newPlateNumbers = ref<string[]>([prop.prefillPlate ? prop.prefillPlate : ""]);
591
660
 
592
661
  type TBlocklistCategory = "visitor" | "contractor" | "delivery" | "pick-up" | "drop-off";
@@ -1208,6 +1277,14 @@ async function submit() {
1208
1277
  payload = {
1209
1278
  ...payload,
1210
1279
  remarks,
1280
+ // The visit's location, when blocked from a visitor transaction.
1281
+ ...(prop.mode === "add" && prop.presetLocation
1282
+ ? {
1283
+ ...(prop.presetLocation.block?.id && { block: prop.presetLocation.block.id }),
1284
+ ...(prop.presetLocation.level?.id && { level: prop.presetLocation.level.id }),
1285
+ ...(prop.presetLocation.unit?.id && { unit: prop.presetLocation.unit.id }),
1286
+ }
1287
+ : {}),
1211
1288
  };
1212
1289
  }
1213
1290
 
@@ -49,6 +49,7 @@
49
49
 
50
50
  <template #item.plates="{ value, item }">
51
51
  <PlateNumberDisplay :plate-numbers="value" :default-value="item.plateNumber" show-cameras
52
+ :active-counts="activeCameraCounts" @synced="handleSynced"
52
53
  :show-expiry="activeTab === 'season-passes'" />
53
54
  </template>
54
55
 
@@ -171,6 +172,9 @@
171
172
  </div>
172
173
  </div>
173
174
  </template>
175
+ <template #item.remarks="{ value }">
176
+ <span class="plate-remarks">{{ String(value ?? "").trim() || "N/A" }}</span>
177
+ </template>
174
178
  <template #item.status="{ value }">
175
179
  <v-chip :color="formatVehicleStatus(value).color" size="x-small" dark>
176
180
  {{ formatVehicleStatus(value).label }}
@@ -179,7 +183,11 @@
179
183
  <template #item.plateNumber="{ value, item: plateNumberItem }">
180
184
  <span class="d-inline-flex align-center ga-2">
181
185
  {{ value }}
182
- <AnprCameraBadge :cameras="(plateNumberItem as any).anprCameras ?? []" :plate-number="value" />
186
+ <AnprCameraBadge :cameras="(plateNumberItem as any).anprCameras ?? []" :plate-number="value"
187
+ :plate-id="(plateNumberItem as any)._id ?? ''" :status="(plateNumberItem as any).status ?? ''"
188
+ :type="(plateNumberItem as any).type ?? ''" :end="(plateNumberItem as any).end ?? null"
189
+ :active-counts="activeCameraCounts"
190
+ @synced="handleSynced" />
183
191
  </span>
184
192
  </template>
185
193
  <template #item.type="{ value }">
@@ -350,16 +358,25 @@ const plateHeaders = [
350
358
  { title: "", value: "action", sortable: false },
351
359
  ]
352
360
 
353
- /** The Season Passes tab also shows each pass's start and expiry. */
354
- const plateHeadersView = computed(() =>
355
- activeTab.value === "season-passes"
356
- ? [
357
- plateHeaders[0],
358
- { title: "Start / Expiry", value: "passDates", sortable: false },
359
- ...plateHeaders.slice(2),
360
- ]
361
- : plateHeaders
362
- )
361
+ /**
362
+ * The Season Passes tab also shows each pass's start and expiry; the Block
363
+ * Listed tab shows each vehicle's remarks (why it was blocked).
364
+ */
365
+ const plateHeadersView = computed(() => {
366
+ if (activeTab.value === "season-passes")
367
+ return [
368
+ plateHeaders[0],
369
+ { title: "Start / Expiry", value: "passDates", sortable: false },
370
+ ...plateHeaders.slice(2),
371
+ ]
372
+ if (activeTab.value === "block-listed")
373
+ return [
374
+ ...plateHeaders.slice(0, 3),
375
+ { title: "Remarks", value: "remarks", sortable: false },
376
+ ...plateHeaders.slice(3),
377
+ ]
378
+ return plateHeaders
379
+ })
363
380
 
364
381
  /** Same as the form's date fields: 09/21/2036 07:35 PM. */
365
382
  function formatPassDate(value: unknown): string {
@@ -405,7 +422,27 @@ const activeTab = ref<TVehicleTab>("residents");
405
422
 
406
423
 
407
424
  const { formatCamelCaseToWords, formatDate, debounce, maskNRIC } = useUtils();
408
- const { getVehicles, deleteVehicle, formatVehicleStatus, approveVehicle, blockVehicle, unblockVehicle, getSpecificVehicleById } = useVehicle();
425
+ const { getVehicles, deleteVehicle, formatVehicleStatus, approveVehicle, blockVehicle, unblockVehicle, getSpecificVehicleById, getActiveCameraCounts } = useVehicle();
426
+
427
+ /**
428
+ * Active ANPR cameras per list at the site. A live plate on fewer cameras
429
+ * than this shows "Sync" beside its badge. Re-read on every list refresh, so a
430
+ * camera switched on elsewhere is picked up.
431
+ */
432
+ const activeCameraCounts = ref<{ allowed: number; blocked: number } | null>(null);
433
+
434
+ async function loadActiveCameraCounts() {
435
+ try {
436
+ activeCameraCounts.value = await getActiveCameraCounts(props.site);
437
+ } catch {
438
+ activeCameraCounts.value = null;
439
+ }
440
+ }
441
+
442
+ async function handleSynced(result: { ok: boolean; message: string }) {
443
+ showMessage(result.message, result.ok ? "success" : "error");
444
+ await getVehiclesRefresh();
445
+ }
409
446
 
410
447
  const items = ref<Array<Record<string, any>>>([]);
411
448
  const page = ref(1);
@@ -583,6 +620,7 @@ const { data: getVehiclesReq, refresh: getVehiclesRefresh, pending: getVehiclesP
583
620
 
584
621
 
585
622
  watch(getVehiclesReq, (newData: any) => {
623
+ loadActiveCameraCounts();
586
624
  items.value = newData?.items || [];
587
625
  pages.value = newData?.pages || 0;
588
626
  pageRange.value = newData?.pageRange || "-- - -- of --";
@@ -934,6 +972,13 @@ watch(activeTab, () => {
934
972
  </script>
935
973
 
936
974
  <style scoped>
975
+ .plate-remarks {
976
+ display: inline-block;
977
+ max-width: 220px;
978
+ white-space: pre-line;
979
+ word-break: break-word;
980
+ }
981
+
937
982
  .pass-dates {
938
983
  display: flex;
939
984
  flex-direction: column;
@@ -913,7 +913,25 @@
913
913
  <div class="visitor-preview__label">{{ label }}</div>
914
914
  <div class="visitor-preview__value d-flex align-center justify-space-between ga-2">
915
915
  <span>{{ selectedVisitorObject[key] }}</span>
916
- <AppButton variant="err" icon="mdi-cancel" @click="openBlockVehicle">
916
+ <!-- Already in Block Listed: greyed "Blocked" that only says so
917
+ when pressed, rather than opening the form again. -->
918
+ <AppButton
919
+ v-if="selectedPlateBlocked"
920
+ variant="ghost"
921
+ icon="mdi-cancel"
922
+ class="visitor-preview__blocked"
923
+ :aria-disabled="true"
924
+ @click="showMessage(`${selectedVisitorRow.plateNumber} is already in Block Listed.`, 'info')"
925
+ >
926
+ Blocked
927
+ </AppButton>
928
+ <AppButton
929
+ v-else
930
+ variant="err"
931
+ icon="mdi-cancel"
932
+ :disabled="checkingBlockedPlate"
933
+ @click="openBlockVehicle"
934
+ >
917
935
  Block
918
936
  </AppButton>
919
937
  </div>
@@ -950,6 +968,7 @@
950
968
  :vehicle-data="blockVehicleData"
951
969
  :preset-category="blockVehicleCategory"
952
970
  :prefill-plate="blockVehiclePlate"
971
+ :preset-location="blockVehicleLocation"
953
972
  @done="handleBlockVehicleDone"
954
973
  @back="dialog.blockVehicle = false"
955
974
  @close="dialog.blockVehicle = false"
@@ -1568,6 +1587,11 @@ const props = defineProps({
1568
1587
  type: Boolean,
1569
1588
  default: false,
1570
1589
  },
1590
+ /** Resident Transactions > See All Resident Transactions - shows that tab. */
1591
+ canViewResidentTransactions: {
1592
+ type: Boolean,
1593
+ default: false,
1594
+ },
1571
1595
  });
1572
1596
 
1573
1597
  const { authenticate, currentUser } = useLocalAuth();
@@ -1785,22 +1809,74 @@ const canBlockSelectedVehicle = computed(() => {
1785
1809
  const blockVehiclePlate = ref("");
1786
1810
  const blockVehicleCategory = ref("");
1787
1811
  const blockVehicleData = ref<Record<string, any>>({});
1812
+ const blockVehicleLocation = ref<Record<string, any> | null>(null);
1813
+
1814
+ /** An id and a name from a visitor field that may be an object or an id. */
1815
+ function locationPart(value: any, fallbackName = "") {
1816
+ if (!value && !fallbackName) return undefined;
1817
+ const id = typeof value === "object" && value ? String(value._id ?? "") : String(value ?? "");
1818
+ const name = (typeof value === "object" && value ? String(value.name ?? "") : "") || fallbackName;
1819
+ return id || name ? { id, name } : undefined;
1820
+ }
1788
1821
 
1789
1822
  function openBlockVehicle() {
1790
1823
  const row = selectedVisitorRow.value;
1791
1824
  blockVehiclePlate.value = String(row?.plateNumber ?? "").trim().toUpperCase();
1792
1825
  blockVehicleCategory.value = blockCategoryForVisitorType(row?.type);
1826
+ // The visit's block / level / unit, saved on the vehicle and shown read-only.
1827
+ blockVehicleLocation.value = {
1828
+ block: locationPart(row?.block),
1829
+ level: locationPart(row?.level),
1830
+ unit: locationPart(row?.unit, String(row?.unitName ?? "")),
1831
+ };
1832
+ // Remarks are left empty: the reason for blocking is not the visit's remarks.
1793
1833
  blockVehicleData.value = {
1794
1834
  name: row?.name ?? "",
1795
1835
  nric: row?.nric ?? "",
1796
1836
  phoneNumber: row?.contact ?? "",
1797
- remarks: row?.remarks ?? "",
1837
+ remarks: "",
1798
1838
  };
1799
1839
  dialog.blockVehicle = true;
1800
1840
  }
1801
1841
 
1842
+ /**
1843
+ * Whether the previewed plate is already in Block Listed (status "blocked"),
1844
+ * asked of the server each time the Preview opens and after a block.
1845
+ */
1846
+ const { checkExistingPlates } = useVehicle();
1847
+ const selectedPlateBlocked = ref(false);
1848
+ const checkingBlockedPlate = ref(false);
1849
+
1850
+ async function refreshSelectedPlateBlocked() {
1851
+ selectedPlateBlocked.value = false;
1852
+ const plate = String(selectedVisitorRow.value?.plateNumber ?? "").trim();
1853
+ if (!plate || !canBlockSelectedVehicle.value) return;
1854
+ checkingBlockedPlate.value = true;
1855
+ try {
1856
+ const res = await checkExistingPlates({ site: siteId, plateNumbers: [plate] });
1857
+ // Only if the Preview still shows the same plate when the answer arrives.
1858
+ if (String(selectedVisitorRow.value?.plateNumber ?? "").trim() !== plate) return;
1859
+ selectedPlateBlocked.value = (res?.items ?? []).some(
1860
+ (item) => item.status === "blocked"
1861
+ );
1862
+ } catch {
1863
+ // Unknown: leave Block available; the form says if the plate exists.
1864
+ } finally {
1865
+ checkingBlockedPlate.value = false;
1866
+ }
1867
+ }
1868
+
1869
+ watch(
1870
+ () => [dialog.viewVisitor, selectedVisitorId.value],
1871
+ ([open]) => {
1872
+ if (open) refreshSelectedPlateBlocked();
1873
+ }
1874
+ );
1875
+
1802
1876
  function handleBlockVehicleDone() {
1803
1877
  dialog.blockVehicle = false;
1878
+ // The form closes and the Preview's button turns to "Blocked".
1879
+ refreshSelectedPlateBlocked();
1804
1880
  showMessage(`Vehicle ${blockVehiclePlate.value} is now in Block Listed.`, "success");
1805
1881
  }
1806
1882
 
@@ -1876,7 +1952,10 @@ const tabOptions = computed(() => {
1876
1952
  ? [{ name: "Unregistered", value: "unregistered" }]
1877
1953
  : []),
1878
1954
  { name: "Guests", value: "guests" },
1879
- { name: "Resident Transactions", value: "resident-transactions" },
1955
+ // Its own right in the role editor; the server refuses the list without it.
1956
+ ...(props.canViewResidentTransactions
1957
+ ? [{ name: "Resident Transactions", value: "resident-transactions" }]
1958
+ : []),
1880
1959
  { name: "Overnight Parking", value: "overnight-parking" },
1881
1960
  ];
1882
1961
 
@@ -2987,11 +3066,11 @@ watch([searchInput, dateFrom, dateTo, filterTypes, activeTab], () => {
2987
3066
 
2988
3067
  const syncVisitorFiltersFromRoute = () => {
2989
3068
  const requestedTab = (route.query.tab as string) || "registered";
2990
- const nextTab = enableUnregisteredTab.value
2991
- ? requestedTab
2992
- : requestedTab === "unregistered"
2993
- ? "registered"
2994
- : requestedTab;
3069
+ const nextTab =
3070
+ (!enableUnregisteredTab.value && requestedTab === "unregistered") ||
3071
+ (!props.canViewResidentTransactions && requestedTab === "resident-transactions")
3072
+ ? "registered"
3073
+ : requestedTab;
2995
3074
 
2996
3075
  if (activeTab.value !== nextTab) {
2997
3076
  activeTab.value = nextTab;
@@ -3252,4 +3331,10 @@ watchEffect(async () => {
3252
3331
  border: 1px solid #dce3e8;
3253
3332
  background: #fff;
3254
3333
  }
3334
+
3335
+ /* Looks disabled, but still answers a click with "already in Block Listed". */
3336
+ .visitor-preview__blocked {
3337
+ opacity: 0.55;
3338
+ cursor: not-allowed;
3339
+ }
3255
3340
  </style>
@@ -187,6 +187,22 @@ export default function useVehicle() {
187
187
  });
188
188
  }
189
189
 
190
+ /** Active ANPR cameras per list at a site: { allowed, blocked }. */
191
+ async function getActiveCameraCounts(site: string) {
192
+ return await useNuxtApp().$api<{ allowed: number; blocked: number }>(
193
+ `/api/vehicles/anpr-cameras/site/${site}`,
194
+ { method: "GET" }
195
+ );
196
+ }
197
+
198
+ /** Put a vehicle's plate on every active camera of its list that lacks it. */
199
+ async function syncVehicle(id: string) {
200
+ return await useNuxtApp().$api<{ message: string; synced: number; failed: number }>(
201
+ `/api/vehicles/sync/id/${id}`,
202
+ { method: "PUT" }
203
+ );
204
+ }
205
+
190
206
  async function getVehicleByNRIC(search: string) {
191
207
  return await useNuxtApp().$api<Record<string, any>>(
192
208
  `/api/vehicles/nric`,
@@ -271,6 +287,8 @@ function getSpecificVehicleById(id: string){
271
287
  unblockVehicle,
272
288
  checkExistingPlates,
273
289
  moveVehicle,
290
+ getActiveCameraCounts,
291
+ syncVehicle,
274
292
  searchMultipleVehiclesByUnitId,
275
293
  getSpecificVehicleById
276
294
  };
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.21.4-staging.339",
5
+ "version": "4.21.4-staging.341",
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.",