@7365admin1/layer-common 4.97.1-staging.528 → 4.97.1-staging.530

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/CHANGELOG.md CHANGED
@@ -2082,11 +2082,11 @@
2082
2082
  `utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
2083
2083
  own rule from two endpoints the console already calls, unprojected:
2084
2084
 
2085
- GET /api/members/user/:user/app/admin the Seven365 staff membership
2086
- GET /api/roles/id/:role that membership's role document
2085
+ GET /api/members/user/:user/app/admin the Seven365 staff membership
2086
+ GET /api/roles/id/:role that membership's role document
2087
2087
 
2088
- owner = member.type === "admin" && role.type === "admin" && role.default === true
2089
- staff = member.type === "admin" && role.type === "admin"
2088
+ owner = member.type === "admin" && role.type === "admin" && role.default === true
2089
+ staff = member.type === "admin" && role.type === "admin"
2090
2090
 
2091
2091
  `role.default` is the marker because it is the only property of a platform
2092
2092
  staff role no API caller can set - `role.controller.ts` validates create and
@@ -12,13 +12,14 @@
12
12
  :pages="pages"
13
13
  :pageRange="pageRange"
14
14
  :no-data-text="`No ${checklistTitle} found`"
15
- @refresh="getCleanerChecklistRefresh"
15
+ @refresh="onRefresh"
16
16
  @row-click="onRowClick"
17
17
  >
18
18
  <template #extension>
19
19
  <v-row no-gutters class="w-100 d-flex flex-column">
20
20
  <div class="filter-bar">
21
21
  <InputDateTimePicker
22
+ :key="`start-${filterKey}`"
22
23
  v-model:utc="startDate"
23
24
  density="compact"
24
25
  hide-details
@@ -26,6 +27,7 @@
26
27
  placeholder="Start Date"
27
28
  />
28
29
  <InputDateTimePicker
30
+ :key="`end-${filterKey}`"
29
31
  v-model:utc="endDate"
30
32
  density="compact"
31
33
  hide-details
@@ -200,10 +202,55 @@ const {
200
202
  serviceType: props.serviceType,
201
203
  }),
202
204
  {
203
- watch: [() => page.value, () => props.site, startDate, endDate, status],
205
+ watch: [() => page.value, () => props.site],
204
206
  }
205
207
  );
206
208
 
209
+ /**
210
+ * A filter change keeps no page. The filters used to sit in the fetch's own
211
+ * watch list beside `page`, so picking a Start Date while on page 3 asked for
212
+ * page 3 of the NARROWED list - usually past its end, so the table came back
213
+ * empty ("No ... found") with a pager that no longer matched. Back to page 1;
214
+ * when already on page 1 the `page` watch cannot fire, so fetch directly.
215
+ */
216
+ watch([startDate, endDate, status], () => {
217
+ if (page.value !== 1) {
218
+ page.value = 1;
219
+ return;
220
+ }
221
+ getCleanerChecklistRefresh();
222
+ });
223
+
224
+ /**
225
+ * The refresh button starts the list over: no Start Date, no End Date, Status
226
+ * "All", page 1. Only the button - the socket events still reload with the
227
+ * filters the person set.
228
+ *
229
+ * The pickers are bound by `v-model:utc` alone, and `InputDateTimePicker`
230
+ * keeps its own copy of the local value, which it shows whenever the UTC one
231
+ * is empty - so clearing `startDate` here left the old date in the field.
232
+ * Bumping `filterKey` remounts both pickers empty.
233
+ *
234
+ * When a filter actually changes, the filter watch above resets the page and
235
+ * fetches; when none was set, nothing fires it, so do the same here.
236
+ */
237
+ const filterKey = ref(0);
238
+
239
+ function onRefresh() {
240
+ const filtered =
241
+ startDate.value !== "" || endDate.value !== "" || status.value !== "all";
242
+ startDate.value = "";
243
+ endDate.value = "";
244
+ status.value = "all";
245
+ filterKey.value++;
246
+ if (filtered) return;
247
+ if (page.value !== 1) {
248
+ page.value = 1;
249
+ return;
250
+ }
251
+ getCleanerChecklistRefresh();
252
+ }
253
+
207
254
  function calculateRemainingTime(
208
255
  closeIn: Date | string | number | null | undefined
209
256
  ) {
@@ -392,6 +392,60 @@
392
392
  </v-row>
393
393
  </v-window-item>
394
394
 
395
+ <!-- ─── Tab 6: Apps ───────────────────────────────────── -->
396
+ <!--
397
+ Which apps offer the entry pass at this site. `accessDoor` above says
398
+ whether the site offers QR and Bluetooth at all; these say which apps
399
+ may show them, so the two compose - turning QR off up there hides it
400
+ everywhere regardless of what is switched on here.
401
+ -->
402
+ <v-window-item value="apps">
403
+ <v-row no-gutters class="px-6 pt-4">
404
+ <v-col cols="12">
405
+ <div class="mt-3 pb-5">
406
+ <p class="font-weight-medium mb-1">Entry Pass Apps</p>
407
+ <p class="text-caption text-medium-emphasis mb-4">
408
+ Turn an app off to hide Entry Pass QR Code and Entry Pass
409
+ Bluetooth from it. Everything else in that app is unaffected.
410
+ </p>
411
+
412
+ <template v-for="group in entrypassAppGroups" :key="group.name">
413
+ <p class="text-caption text-uppercase text-medium-emphasis mt-4 mb-1">
414
+ {{ group.name }}
415
+ </p>
416
+ <div
417
+ v-for="app in group.apps"
418
+ :key="app.value"
419
+ class="d-flex align-center py-3 pr-5 entrypass-app-row"
420
+ >
421
+ <span class="flex-grow-1 font-weight-medium">{{ app.label }}</span>
422
+ <v-switch
423
+ :data-testid="`entrypass-app-${app.value}`"
424
+ color="success"
425
+ hide-details
426
+ v-model="currentEntryPassSettings.accessApps[app.value]"
427
+ />
428
+ </div>
429
+ </template>
430
+
431
+ <v-row class="mt-4">
432
+ <v-col cols="12" md="3">
433
+ <v-btn
434
+ color="primary"
435
+ variant="flat"
436
+ prepend-icon="mdi-content-save"
437
+ block
438
+ @click="saveAccessAppsSettings()"
439
+ >
440
+ Save
441
+ </v-btn>
442
+ </v-col>
443
+ </v-row>
444
+ </div>
445
+ </v-col>
446
+ </v-row>
447
+ </v-window-item>
448
+
395
449
  <!-- ─── Tab 5: Self-Service ───────────────────────────── -->
396
450
  <v-window-item value="onboarding">
397
451
  <v-row no-gutters class="px-6 pt-4">
@@ -615,6 +669,7 @@ const entryPassTabs = [
615
669
  { value: "printer", label: "Printer", icon: "mdi-printer" },
616
670
  { value: "entrypass", label: "Entrypass", icon: "mdi-link-variant" },
617
671
  { value: "onboarding", label: "Self-Service", icon: "mdi-account-multiple-check-outline" },
672
+ { value: "apps", label: "Apps", icon: "mdi-cellphone-cog" },
618
673
  ];
619
674
 
620
675
  const currentEntryPassSettings = ref<Record<string, any>>({
@@ -631,6 +686,8 @@ const currentEntryPassSettings = ref<Record<string, any>>({
631
686
  keyPass: false,
632
687
  accessDoorQrCode: false,
633
688
  accessDoorBluetooth: false,
689
+ // Every app explicit, so a save can never switch one off by omitting it.
690
+ accessApps: entrypassAppsPayload(null),
634
691
  printerVendorId: "",
635
692
  printerProductId: "",
636
693
  qrCodeTemplateHeader: "",
@@ -819,6 +876,9 @@ watchEffect(() => {
819
876
  keyPass: data.settings?.keyPass ?? false,
820
877
  accessDoorQrCode: data.settings?.accessDoor?.qrCode ?? false,
821
878
  accessDoorBluetooth: data.settings?.accessDoor?.bluetooth ?? false,
879
+ // Absent means on, so a site that has never opened this tab shows every
880
+ // app enabled rather than every app off.
881
+ accessApps: entrypassAppsPayload(data.settings?.accessApps),
822
882
  printerVendorId: data.settings?.printer?.vendorId ? String(data.settings.printer.vendorId) : "",
823
883
  printerProductId: data.settings?.printer?.productId ? String(data.settings.printer.productId) : "",
824
884
  qrCodeTemplateHeader: data.settings?.qrTemplate?.header ?? "",
@@ -863,6 +923,7 @@ function buildPayload() {
863
923
  qrCode: currentEntryPassSettings.value.accessDoorQrCode,
864
924
  bluetooth: currentEntryPassSettings.value.accessDoorBluetooth,
865
925
  },
926
+ accessApps: entrypassAppsPayload(currentEntryPassSettings.value.accessApps),
866
927
  printer: {
867
928
  vendorId: Number(currentEntryPassSettings.value.printerVendorId) || null,
868
929
  productId: Number(currentEntryPassSettings.value.printerProductId) || null,
@@ -913,6 +974,23 @@ async function saveAccessDoorSettings() {
913
974
  getSiteEntryPassSettings();
914
975
  }
915
976
 
977
+ /** The switches, in the two groups the tab shows them under. */
978
+ const entrypassAppGroups = computed(() => {
979
+ const groups: { name: string; apps: typeof ENTRYPASS_APPS[number][] }[] = [];
980
+ for (const app of ENTRYPASS_APPS) {
981
+ const existing = groups.find((g) => g.name === app.group);
982
+ if (existing) existing.apps.push(app);
983
+ else groups.push({ name: app.group, apps: [app] });
984
+ }
985
+ return groups;
986
+ });
987
+
988
+ async function saveAccessAppsSettings() {
989
+ await _save(buildPayload());
990
+ showMessage("App settings saved successfully!", "success");
991
+ getSiteEntryPassSettings();
992
+ }
993
+
916
994
  async function savePrinterSettings() {
917
995
  await _save(buildPayload());
918
996
  showMessage("Printer settings saved successfully!", "success");
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.528",
5
+ "version": "4.97.1-staging.530",
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.",
@@ -0,0 +1,76 @@
1
+ /**
2
+ * WHICH APPS OFFER THE ENTRY PASS, PER SITE.
3
+ *
4
+ * `settings.accessDoor.{qrCode,bluetooth}` already says whether a site offers
5
+ * QR or Bluetooth at all, but it says it for every app at once. A site that
6
+ * wants its M&E crew on the entry pass and its landscapers not had no way to
7
+ * say so — the two methods were all-or-nothing across the estate.
8
+ *
9
+ * `settings.accessApps` is that second axis: one switch per app, read by the
10
+ * app itself to decide whether to offer Entry Pass QR Code and Entry Pass
11
+ * Bluetooth at all. The two compose — a method still has to be on for the site
12
+ * before any app can show it.
13
+ *
14
+ * ## Keyed by SERVICE CODE, not app name
15
+ *
16
+ * `cleaning_services`, not `hygiene`. The codes are what `/api/service-providers`
17
+ * and `members` already speak, so a site's providers line up with the switches
18
+ * without a translation table in between. The label is where "Hygiene" lives,
19
+ * because that is what the app is called — `serviceTypeLabel` deliberately says
20
+ * "Cleaning" for the same code elsewhere, and both names are correct in their
21
+ * own screen.
22
+ *
23
+ * `ma` is the odd one out: the MA app is the management app, not a service
24
+ * provider, so it has no service code of its own.
25
+ *
26
+ * ## MISSING MEANS ON
27
+ *
28
+ * No site has this field, so a closed default would switch the entry pass off
29
+ * for every app in every estate the moment it shipped. Absent, `null`, a
30
+ * non-object, an unknown key and every value that is not exactly `false` mean
31
+ * the app offers it — the same rule `accessDoor` and the resident app's module
32
+ * switches already follow. Only a switch somebody deliberately turned off
33
+ * hides anything.
34
+ */
35
+
36
+ /** The app each switch governs. `value` is stored; `label` is only shown. */
37
+ export const ENTRYPASS_APPS: readonly {
38
+ value: string;
39
+ label: string;
40
+ group: "Management" | "Service Providers";
41
+ }[] = Object.freeze([
42
+ { value: "ma", label: "MA App", group: "Management" },
43
+ { value: "mechanical_electrical_services", label: "M&E", group: "Service Providers" },
44
+ { value: "cleaning_services", label: "Hygiene", group: "Service Providers" },
45
+ { value: "pool_maintenance_services", label: "Pool Maintenance", group: "Service Providers" },
46
+ { value: "pest_control_services", label: "Pest Control", group: "Service Providers" },
47
+ { value: "landscaping_services", label: "Landscape", group: "Service Providers" },
48
+ ]);
49
+
50
+ export type EntrypassApps = Partial<Record<string, boolean>>;
51
+
52
+ /**
53
+ * Does this app offer the entry pass at this site?
54
+ *
55
+ * Fails open on every uncertainty, so a site that has never been configured —
56
+ * which is all of them until somebody opens the tab — behaves exactly as it
57
+ * does today.
58
+ */
59
+ export function isEntrypassAppEnabled(
60
+ accessApps: EntrypassApps | null | undefined,
61
+ app: string,
62
+ ): boolean {
63
+ if (!accessApps || typeof accessApps !== "object" || Array.isArray(accessApps)) {
64
+ return true;
65
+ }
66
+ return (accessApps as Record<string, unknown>)[app] !== false;
67
+ }
68
+
69
+ /** Every switch written out explicitly, so a save can never turn one off by omission. */
70
+ export function entrypassAppsPayload(
71
+ current: EntrypassApps | null | undefined,
72
+ ): Record<string, boolean> {
73
+ return Object.fromEntries(
74
+ ENTRYPASS_APPS.map(({ value }) => [value, isEntrypassAppEnabled(current, value)]),
75
+ );
76
+ }