@7365admin1/layer-common 4.97.1-staging.675 → 4.97.1-staging.677

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.
@@ -42,7 +42,7 @@
42
42
  Export CSV
43
43
  </v-btn>
44
44
  <v-btn
45
- v-if="canManageAttendanceSettings || canManageSiteDeviceMode"
45
+ v-if="!readOnly && (canManageAttendanceSettings || canManageSiteDeviceMode)"
46
46
  variant="outlined"
47
47
  class="text-none screen-btn-ghost"
48
48
  @click="dialogShowSettings = true"
@@ -131,6 +131,12 @@ const props = defineProps({
131
131
  canViewAllAttendance: { type: Boolean, default: false },
132
132
  canViewAttendanceDetails: { type: Boolean, default: false },
133
133
  canManageAttendanceSettings: { type: Boolean, default: false },
134
+ /**
135
+ * View-only screen (the managing agent's view of a provider's attendance).
136
+ * Hides Settings even for a `*` role, whose site-device-mode right comes from
137
+ * `useAttendancePermission` (the provider apps' catalogue), not from a prop.
138
+ */
139
+ readOnly: { type: Boolean, default: false },
134
140
  });
135
141
 
136
142
  const canViewAllAttendance = computed(() => props.canViewAllAttendance);
@@ -7,6 +7,7 @@
7
7
  :site="site"
8
8
  :service-type="serviceType"
9
9
  :schedule-route="scheduleRoute"
10
+ :read-only="readOnly"
10
11
  text="The app makes a new checklist for every area automatically each midnight. Staff tick off each unit on their mobile app; you follow progress here."
11
12
  how-title="How the Daily Checklist works"
12
13
  how-key="daily-checklist"
@@ -208,6 +209,8 @@ const props = defineProps({
208
209
  canDownloadSchedule: { type: Boolean, default: false },
209
210
  canManageScheduleTasks: { type: Boolean, default: false },
210
211
  canGenerateChecklist: { type: Boolean, default: false },
212
+ /** View-only screen (the managing agent's view): hides the setup link. Pass every can-manage flag false too. */
213
+ readOnly: { type: Boolean, default: false },
211
214
  });
212
215
 
213
216
  // "Daily Checklist – Cleaning" / "– Landscape" / "– Pest" / "– Pool" / "– Technician"
@@ -1365,6 +1365,13 @@ const props = defineProps({
1365
1365
  orgSlug: { type: String, default: "" },
1366
1366
  siteSlug: { type: String, default: "" },
1367
1367
  printMode: { type: Boolean, default: false },
1368
+ /**
1369
+ * Where a tile's "view all" / row click goes, by route key (`attendance`,
1370
+ * `scheduleTask`, `feedbacks`, ...), relative to `/{org}/{site}/`. Overrides
1371
+ * the built-in paths for an app whose pages live elsewhere - e.g. Property
1372
+ * Management shows a provider's Daily Checklist under `services/cleaning/checklist`.
1373
+ */
1374
+ routes: { type: Object as () => Record<string, string>, default: () => ({}) },
1368
1375
  });
1369
1376
 
1370
1377
  const emit = defineEmits<{
@@ -3602,7 +3609,7 @@ function goToDashboardRoute(routeKey: string) {
3602
3609
  calendar: "calendar",
3603
3610
  "incident-reports": "incident-reports",
3604
3611
  };
3605
- const path = pathMap[routeKey] || routeKey;
3612
+ const path = props.routes[routeKey] || pathMap[routeKey] || routeKey;
3606
3613
  router.push(`/${props.orgId}/${props.site}/${path}`);
3607
3614
  }
3608
3615
 
@@ -3620,7 +3627,7 @@ function goToListItem(item: TaskItem | FeedbackItem, routeKey: string) {
3620
3627
  feedbacks: "feedbacks",
3621
3628
  scheduleTask: getSchedulePath(),
3622
3629
  };
3623
- const path = pathMap[routeKey] || routeKey;
3630
+ const path = props.routes[routeKey] || pathMap[routeKey] || routeKey;
3624
3631
  const scheduleId = item.raw?.schedule?._id || item.raw?.schedule;
3625
3632
  if (routeKey === "scheduleTask" && scheduleId) {
3626
3633
  router.push(`/${props.orgId}/${props.site}/${path}/${scheduleId}/${id}`);
@@ -6,6 +6,7 @@
6
6
  :site="site"
7
7
  :service-type="serviceType"
8
8
  :schedule-route="scheduleRoute"
9
+ :read-only="readOnly"
9
10
  text="These are the areas on this day's checklist. Click an area to see each unit, tick it as done, or send it back to be redone. Visits today counts the area's normal visits plus any extra checks added today."
10
11
  />
11
12
  <!--
@@ -194,6 +195,8 @@ const props = defineProps({
194
195
  // Common / Toilet is a cleaning distinction; apps without it hide the Type
195
196
  // filter and column (saved `type` values are untouched).
196
197
  showAreaType: { type: Boolean, default: true },
198
+ /** View-only screen (the managing agent's view): hides the setup link. Pass every can-manage flag false too. */
199
+ readOnly: { type: Boolean, default: false },
197
200
  });
198
201
 
199
202
  // "Daily Checklist – Cleaning" / "– Landscape" / ... (same title as the day list)
@@ -43,7 +43,7 @@
43
43
  <ul class="schedule-guide__list">
44
44
  <li v-for="p in problems" :key="p">{{ p }}</li>
45
45
  </ul>
46
- <template #append>
46
+ <template v-if="!readOnly" #append>
47
47
  <v-btn
48
48
  :to="areaLink"
49
49
  variant="outlined"
@@ -71,6 +71,8 @@ const props = defineProps({
71
71
  howTitle: { type: String, default: "" },
72
72
  /** Remembers open/closed per panel on this browser. */
73
73
  howKey: { type: String, default: "" },
74
+ /** View-only screen (e.g. the managing agent's view): no "Set up Areas and Units" link. */
75
+ readOnly: { type: Boolean, default: false },
74
76
  });
75
77
 
76
78
  const HOW_STORE = () => `schedule-guide-how:${props.howKey || props.howTitle}`;
@@ -218,6 +218,33 @@
218
218
  When on, staff can print a QR sticker for each vehicle from Vehicle Mgmt, and guards can scan it to see
219
219
  which unit the vehicle belongs to.
220
220
  </p>
221
+ <v-divider class="my-4" />
222
+ <div class="text-subtitle-2 mb-2">Sticker serial number</div>
223
+ <v-row dense>
224
+ <v-col cols="12" sm="6" md="4">
225
+ <v-text-field v-model="vehicleQrPrefix" label="Serial number prefix (optional)" placeholder="e.g. TLR"
226
+ density="compact" variant="outlined" maxlength="8" :rules="[vehicleQrPrefixRule]"
227
+ hint="Letters, numbers or dashes, up to 8" persistent-hint data-test="vehicle-qr-serial-prefix"
228
+ @update:model-value="(v: string) => (vehicleQrPrefix = cleanSerialPrefix(v))" />
229
+ </v-col>
230
+ <v-col cols="12" sm="6" md="3">
231
+ <v-select v-model="vehicleQrDigits" :items="[1, 2, 3, 4, 5, 6]" label="Digits" density="compact"
232
+ variant="outlined" :disabled="!vehicleQrPrefix" hint="Zeros in front, e.g. 3 = 001" persistent-hint
233
+ data-test="vehicle-qr-serial-digits" />
234
+ </v-col>
235
+ <v-col cols="12" md="5" class="d-flex align-center flex-wrap">
236
+ <span class="text-body-2 mr-3" data-test="vehicle-qr-serial-example">
237
+ First sticker: <b>{{ vehicleQrExample }}</b>
238
+ </span>
239
+ <v-btn color="primary" variant="flat" size="small" class="text-none" :loading="vehicleQrSerialSaving"
240
+ :disabled="!vehicleQrSerialChanged || vehicleQrPrefixRule(vehicleQrPrefix) !== true"
241
+ data-test="vehicle-qr-serial-save" @click="saveVehicleQrSerial">Save</v-btn>
242
+ </v-col>
243
+ </v-row>
244
+ <p class="text-caption text-medium-emphasis mt-2 mb-0">
245
+ Changes how sticker numbers are printed and shown from now on (the numbers themselves stay the same).
246
+ Stickers already on cars keep what was printed on them.
247
+ </p>
221
248
  </v-expansion-panel-text>
222
249
  </v-expansion-panel>
223
250
 
@@ -292,6 +319,7 @@ import useSiteSettings from "../composables/useSiteSettings";
292
319
  import useUtils from "../composables/useUtils";
293
320
  import useANPRSettings from "../composables/useANPRSettings";
294
321
  import useVehicle from "../composables/useVehicle";
322
+ import { SERIAL_DEFAULT_DIGITS, SERIAL_PREFIX_PATTERN, cleanSerialPrefix, formatStickerSerial } from "../utils/vehicle-qr-blank";
295
323
 
296
324
  const props = defineProps({
297
325
  siteId: { type: String, required: true },
@@ -494,17 +522,54 @@ const route = useRoute();
494
522
  const { getVehicleQrSettings, setVehicleQrSettings } = useVehicle();
495
523
  const vehicleQrEnabled = ref(false);
496
524
  const vehicleQrSaving = ref(false);
525
+ // Sticker serial number: prefix ("" = none, prints "No. 1") and digits.
526
+ const vehicleQrPrefix = ref("");
527
+ const vehicleQrDigits = ref(SERIAL_DEFAULT_DIGITS);
528
+ const vehicleQrSaved = ref({ prefix: "", digits: SERIAL_DEFAULT_DIGITS });
529
+ const vehicleQrSerialSaving = ref(false);
530
+ const vehicleQrPrefixRule = (v: string) =>
531
+ SERIAL_PREFIX_PATTERN.test(cleanSerialPrefix(v)) || "Use letters, numbers or dashes only (up to 8)";
532
+ const vehicleQrExample = computed(() => formatStickerSerial(1, vehicleQrPrefix.value, vehicleQrDigits.value));
533
+ const vehicleQrSerialChanged = computed(
534
+ () => vehicleQrPrefix.value !== vehicleQrSaved.value.prefix || vehicleQrDigits.value !== vehicleQrSaved.value.digits,
535
+ );
536
+
537
+ function applyVehicleQrSerial(res: { serialPrefix?: string; serialDigits?: number } | null | undefined) {
538
+ const prefix = res?.serialPrefix ?? "";
539
+ const digits = res?.serialDigits ?? SERIAL_DEFAULT_DIGITS;
540
+ vehicleQrSaved.value = { prefix, digits };
541
+ vehicleQrPrefix.value = prefix;
542
+ vehicleQrDigits.value = digits;
543
+ }
497
544
 
498
545
  await useLazyAsyncData(`vehicle-qr-${props.siteId}`, async () => {
499
546
  if (!canManageVehicleQr.value) return null;
500
547
  try {
501
- vehicleQrEnabled.value = !!(await getVehicleQrSettings(props.siteId))?.enabled;
548
+ const res = await getVehicleQrSettings(props.siteId);
549
+ vehicleQrEnabled.value = !!res?.enabled;
550
+ applyVehicleQrSerial(res);
502
551
  } catch {
503
552
  vehicleQrEnabled.value = false;
504
553
  }
505
554
  return null;
506
555
  });
507
556
 
557
+ async function saveVehicleQrSerial() {
558
+ vehicleQrSerialSaving.value = true;
559
+ try {
560
+ const res = await setVehicleQrSettings(props.siteId, {
561
+ serialPrefix: cleanSerialPrefix(vehicleQrPrefix.value),
562
+ serialDigits: vehicleQrDigits.value,
563
+ });
564
+ applyVehicleQrSerial(res);
565
+ show("Sticker serial number saved", "success");
566
+ } catch (e: any) {
567
+ show(e?.data?.message || "Could not save the sticker serial number", "error");
568
+ } finally {
569
+ vehicleQrSerialSaving.value = false;
570
+ }
571
+ }
572
+
508
573
  async function saveVehicleQr(value: boolean | null) {
509
574
  const enabled = !!value;
510
575
  vehicleQrSaving.value = true;
@@ -162,14 +162,18 @@
162
162
  hide-details />
163
163
  </v-col>
164
164
  <v-col cols="12" sm="6" md="4">
165
- <v-select v-model="design.serial" :items="SERIAL_OPTIONS" label="Serial number (No. 1, 2, 3 ...)" density="compact"
165
+ <v-select v-model="design.serial" :items="SERIAL_OPTIONS" label="Serial number" density="compact"
166
166
  hide-details data-test="vehicle-qr-serial" />
167
167
  </v-col>
168
168
  <v-col v-if="!isBlank" cols="12" sm="6" md="4">
169
- <v-select v-model="design.plate" :items="PLATE_OPTIONS" label="Vehicle number on print-out" density="compact"
169
+ <v-select v-model="design.plate" :items="PLATE_OPTIONS" label="Plate number on the sticker" density="compact"
170
170
  hide-details data-test="vehicle-qr-plate" />
171
171
  </v-col>
172
172
  </v-row>
173
+ <v-alert v-if="!isBlank && design.plate === 'hide' && design.serial === 'off'" type="info" variant="tonal"
174
+ density="compact" class="mt-2" data-test="vehicle-qr-qr-only-hint">
175
+ No plate number and no serial number: each sticker will print the QR code only.
176
+ </v-alert>
173
177
  <div class="d-flex align-center flex-wrap">
174
178
  <v-switch v-model="design.cutLines" label="Show cut lines" color="primary" density="compact" hide-details
175
179
  inset class="mt-1 mr-4" data-test="vehicle-qr-cut-lines" />
@@ -669,6 +669,25 @@ export default function usePropertyPermission() {
669
669
  },
670
670
  "robot-mgmt": robotPermissions,
671
671
  "cctv-engine": cctvEnginePermissions,
672
+ // The managing agent's VIEW of the providers at the site (owner, 13 Nov 2026):
673
+ // "Services at this site" > Cleaning / M&E / Pest Control / Pool / Garden >
674
+ // Dashboard, Daily Checklist, Attendance. View only - the strings are the
675
+ // providers' own "see all" keys, which API-core's staff-lists guard and the
676
+ // dashboard tiles already accept, so no new string is invented.
677
+ "cleaning-schedule-mgmt": {
678
+ "see-all-schedules": {
679
+ check: true,
680
+ description:
681
+ "Allows the user to view the service providers' daily checklists at the site (areas, units and history). View only.",
682
+ },
683
+ },
684
+ "attendance-mgmt": {
685
+ "see-all-attendance": {
686
+ check: true,
687
+ description:
688
+ "Allows the user to view the service providers' staff attendance at the site. View only.",
689
+ },
690
+ },
672
691
  "site-settings": siteSettingsPermissions
673
692
  };
674
693
 
@@ -276,17 +276,23 @@ function getSpecificVehicleById(id: string){
276
276
 
277
277
  // Vehicle QR stickers (core vehicle-qr). Per-site switch, bulk sticker data,
278
278
  // and re-issue (the old sticker stops working).
279
+ type VehicleQrSettings = { site: string; enabled: boolean; serialPrefix: string; serialDigits: number };
280
+
279
281
  function getVehicleQrSettings(site: string) {
280
- return useNuxtApp().$api<{ site: string; enabled: boolean }>(
282
+ return useNuxtApp().$api<VehicleQrSettings>(
281
283
  `/api/vehicles/qr/settings/site/${site}`,
282
284
  { method: "GET" },
283
285
  );
284
286
  }
285
287
 
286
- function setVehicleQrSettings(site: string, enabled: boolean) {
287
- return useNuxtApp().$api<{ site: string; enabled: boolean }>(
288
+ /** Only the fields sent change (`true`/`false` = the switch alone). */
289
+ function setVehicleQrSettings(
290
+ site: string,
291
+ change: boolean | Partial<Pick<VehicleQrSettings, "enabled" | "serialPrefix" | "serialDigits">>,
292
+ ) {
293
+ return useNuxtApp().$api<VehicleQrSettings>(
288
294
  `/api/vehicles/qr/settings/site/${site}`,
289
- { method: "PUT", body: { enabled } },
295
+ { method: "PUT", body: typeof change === "boolean" ? { enabled: change } : change },
290
296
  );
291
297
  }
292
298
 
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.675",
5
+ "version": "4.97.1-staging.677",
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.",
@@ -15,7 +15,7 @@ export const BLANK_TOKEN_LENGTH = 24;
15
15
  /** What the installer strip says under a blank sticker. */
16
16
  export const BLANK_STRIP_NOTE = "Not linked yet - link it in Vehicles > Link QR sticker, or scan it with iMA365 / iSecure365";
17
17
 
18
- export type BlankItem = { token: string; qr: string; code: string; serialNo?: number };
18
+ export type BlankItem = { token: string; qr: string; code: string; serialNo?: number; serialLabel?: string | null };
19
19
 
20
20
  /** A whole number 1..500, or 0 when the field is empty or not a number. */
21
21
  export function blankCount(value: unknown): number {
@@ -25,7 +25,7 @@ export function blankCount(value: unknown): number {
25
25
 
26
26
  /** Sticker items for the normal sticker flow: token = the unique key, the code is printed in the plate slot. */
27
27
  export function blankStickerItems(items: BlankItem[]): StickerItem[] {
28
- return items.map((i) => ({ vehicleId: i.token, qr: i.qr, token: i.token, plateNumber: i.code, status: "active", blank: true, ...(i.serialNo ? { serialNo: i.serialNo } : {}) }));
28
+ return items.map((i) => ({ vehicleId: i.token, qr: i.qr, token: i.token, plateNumber: i.code, status: "active", blank: true, ...(i.serialNo ? { serialNo: i.serialNo, serialLabel: i.serialLabel ?? null } : {}) }));
29
29
  }
30
30
 
31
31
  /**
@@ -94,12 +94,29 @@ export function qrStickerSummary(plates: Array<{ hasQrSticker?: boolean }>): { l
94
94
  return { label: `${linked} of ${total}`, color: "warning" };
95
95
  }
96
96
 
97
- /** The list's sticker numbers for one row ("No. 5", or "SBA123A: No. 5" when the row has several plates). */
98
- export function qrStickerNumbers(plates: Array<{ hasQrSticker?: boolean; qrSerial?: number; plateNumber?: string }>): string[] {
97
+ /** The list's sticker numbers for one row ("TLR005" / "No. 5", or "SBA123A: TLR005" when the row has several plates). */
98
+ export function qrStickerNumbers(plates: Array<{ hasQrSticker?: boolean; qrSerial?: number; qrSerialLabel?: string | null; plateNumber?: string }>): string[] {
99
99
  const many = plates.length > 1;
100
100
  return plates
101
101
  .filter((p) => p?.hasQrSticker === true && Number.isInteger(p.qrSerial) && Number(p.qrSerial) > 0)
102
- .map((p) => (many ? `${p.plateNumber}: No. ${p.qrSerial}` : `No. ${p.qrSerial}`));
102
+ .map((p) => {
103
+ const label = String(p.qrSerialLabel ?? "").trim() || `No. ${p.qrSerial}`;
104
+ return many ? `${p.plateNumber}: ${label}` : label;
105
+ });
106
+ }
107
+
108
+ /** The site's sticker number settings (Site Settings > Vehicle QR stickers). */
109
+ export const SERIAL_PREFIX_PATTERN = /^[A-Z0-9-]{0,8}$/;
110
+ export const SERIAL_DEFAULT_DIGITS = 3;
111
+
112
+ /** Same rule as the server: (1, "TLR", 3) -> "TLR001", (1234, "TLR", 3) -> "TLR1234", no prefix -> "No. 1". */
113
+ export function formatStickerSerial(n: number, prefix?: string | null, digits: number = SERIAL_DEFAULT_DIGITS): string {
114
+ return prefix ? prefix + String(n).padStart(digits, "0") : `No. ${n}`;
115
+ }
116
+
117
+ /** What a person typed as the prefix, as it will be saved: trimmed, capitals. */
118
+ export function cleanSerialPrefix(input: unknown): string {
119
+ return String(input ?? "").trim().toUpperCase();
103
120
  }
104
121
 
105
122
  export type BlankSummary = { printed: number; linked: number; available: number };
@@ -150,8 +150,8 @@ export const SERIAL_OPTIONS: { value: SerialChoice; title: string }[] = [
150
150
  ];
151
151
 
152
152
  export const PLATE_OPTIONS: { value: PlateChoice; title: string }[] = [
153
- { value: "show", title: "Show" },
154
- { value: "hide", title: "Hide (not printed)" },
153
+ { value: "show", title: "Show (default)" },
154
+ { value: "hide", title: "Hide - QR and serial number only" },
155
155
  ];
156
156
 
157
157
  export const LABEL_OPTIONS: { value: LabelChoice; title: string }[] = [
@@ -179,6 +179,8 @@ export type StickerItem = {
179
179
  blank?: boolean;
180
180
  /** The sticker's running number at its site (1, 2, 3 ...). */
181
181
  serialNo?: number;
182
+ /** That number as the site prints it ("TLR001", or "No. 1" with no prefix) - from the server. */
183
+ serialLabel?: string | null;
182
184
  };
183
185
 
184
186
  export type StickerPlateRow = {
@@ -194,13 +196,16 @@ export type StickerPlateRow = {
194
196
  const text = (v: unknown) => (v == null ? "" : String(v).trim());
195
197
 
196
198
  /**
197
- * The sticker's running number at its site, "No. 12": the server gives each
198
- * sticker the next number when it is first printed (1, 2, 3 ...) and it never
199
- * changes, so No. 1 stays Mrs Tan's sticker. "" when the server sent none.
199
+ * The sticker's running number at its site as the site prints it: the
200
+ * server's `serialLabel` ("TLR001" with a prefix set in Site Settings), else
201
+ * "No. 12". The server gives each sticker the next number when it is first
202
+ * printed (1, 2, 3 ...) and it never changes, so No. 1 stays Mrs Tan's
203
+ * sticker. "" when the server sent no number.
200
204
  */
201
- export function stickerSerial(item: Pick<StickerItem, "serialNo">): string {
205
+ export function stickerSerial(item: Pick<StickerItem, "serialNo" | "serialLabel">): string {
202
206
  const n = Number(item?.serialNo);
203
- return Number.isInteger(n) && n > 0 ? `No. ${n}` : "";
207
+ if (!Number.isInteger(n) || n < 1) return "";
208
+ return text(item?.serialLabel) || `No. ${n}`;
204
209
  }
205
210
 
206
211
  /** What a saved picture is named after: the plate - or, with the plate hidden, the sticker's number (the file name must not give the plate away either). */