@7365admin1/layer-common 4.2.21-staging.281 → 4.2.21-staging.282

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.
@@ -896,6 +896,138 @@
896
896
  text-transform: none;
897
897
  }
898
898
 
899
+ /* ------------------------------------------------------------------ */
900
+ /* The ANPR plate toast (`components/VisitorSocketPopUp.vue`). */
901
+ /* */
902
+ /* The generic toast above is a coloured slab with a sentence on it, */
903
+ /* which is the wrong shape for this one: it carries a PAYLOAD - the */
904
+ /* plate the camera read - and the operator reads the number, not the */
905
+ /* sentence. So it is the design's own CARD instead: `--card` on a */
906
+ /* `--border` rule at `--r-card`, the menu shadow, and the plate set */
907
+ /* two steps above the label. */
908
+ /* */
909
+ /* No colour is written down here. The tint is `--info` over */
910
+ /* `--info-bg`, the same pair `.tone-info` paints a chip with, so the */
911
+ /* toast follows the theme instead of Vuetify's flat `color="info"` */
912
+ /* fill - which is what the owner was shown and what this replaces. */
913
+ /* ------------------------------------------------------------------ */
914
+ .anpr-toast .v-snackbar__wrapper {
915
+ background: var(--card);
916
+ color: var(--text);
917
+ border: 1px solid var(--border);
918
+ border-radius: var(--r-card);
919
+ box-shadow: var(--shadow-menu);
920
+ /* One width for every read, so the toast does not resize between plates.
921
+ Vuetify's own 344px minimum is left behind deliberately: a plate set at
922
+ 21px needs the room, and a long read wraps inside this box. Vuetify's own
923
+ 344px minimum is zeroed first, or a narrow phone gets a toast wider than
924
+ the screen. */
925
+ min-width: 0;
926
+ width: min(92vw, 400px);
927
+ }
928
+
929
+ .anpr-toast .v-snackbar__content {
930
+ width: 100%;
931
+ padding: 14px 14px 16px 16px;
932
+ }
933
+
934
+ .anpr-toast__row {
935
+ display: flex;
936
+ align-items: flex-start;
937
+ gap: 12px;
938
+ }
939
+
940
+ /* The leading glyph says WHAT was detected - a vehicle, not "information".
941
+ `mdi-car` resolves to `directions_car` through `utils/materialSymbols.ts`. */
942
+ .anpr-toast__icon {
943
+ flex: 0 0 auto;
944
+ display: inline-flex;
945
+ align-items: center;
946
+ justify-content: center;
947
+ width: 34px;
948
+ height: 34px;
949
+ border-radius: var(--r-pill);
950
+ background: var(--info-bg);
951
+ color: var(--info);
952
+ }
953
+
954
+ .anpr-toast__text {
955
+ flex: 1 1 auto;
956
+ /* Without this a long read stretches the flex item instead of wrapping. */
957
+ min-width: 0;
958
+ display: flex;
959
+ flex-direction: column;
960
+ gap: 2px;
961
+ }
962
+
963
+ /* The label is the SMALL half. `--fs-btn` is the size the generic toast
964
+ already uses, so nothing here is set smaller than the product's own toast
965
+ text - the plate is what got bigger. */
966
+ /* `--text2`, not `--muted`. `utils/theme.ts` measures `--muted` at 3.24:1 on a
967
+ card - below AA - and this is real text, not a graphical mark. */
968
+ .anpr-toast__label {
969
+ font-size: var(--fs-btn);
970
+ font-weight: var(--fw-btn);
971
+ line-height: 1.3;
972
+ color: var(--text2);
973
+ }
974
+
975
+ /* The payload. Tabular figures so `0`/`8` and `1`/`7` cannot be mistaken for
976
+ one another at a barrier, and `anywhere` so a malformed read wraps inside
977
+ the card rather than widening it. */
978
+ .anpr-toast__plate {
979
+ font-size: 21px;
980
+ font-weight: var(--fw-h1);
981
+ letter-spacing: 0.05em;
982
+ line-height: 1.25;
983
+ color: var(--text);
984
+ font-variant-numeric: tabular-nums;
985
+ overflow-wrap: anywhere;
986
+ }
987
+
988
+ /* 44px, the touch minimum - the bare 24px Vuetify cross this replaces was
989
+ under half that. Pulled out by its own padding so the glyph still sits on
990
+ the card's optical edge. */
991
+ .anpr-toast__close {
992
+ flex: 0 0 auto;
993
+ display: inline-flex;
994
+ align-items: center;
995
+ justify-content: center;
996
+ width: 44px;
997
+ height: 44px;
998
+ margin: -10px -10px 0 0;
999
+ padding: 0;
1000
+ border: 0;
1001
+ border-radius: var(--r-inner-sm);
1002
+ background: transparent;
1003
+ color: var(--muted);
1004
+ cursor: pointer;
1005
+ }
1006
+
1007
+ .anpr-toast__close:hover {
1008
+ background: var(--hover);
1009
+ color: var(--text);
1010
+ }
1011
+
1012
+ .anpr-toast__close:focus-visible {
1013
+ outline: 2px solid var(--accent);
1014
+ outline-offset: 2px;
1015
+ }
1016
+
1017
+ /* Indented to the text column, so the button reads as belonging to the plate
1018
+ above it rather than to the card's edge. */
1019
+ .anpr-toast__actions {
1020
+ display: flex;
1021
+ margin: 12px 0 0 46px;
1022
+ }
1023
+
1024
+ /* `AppButton`'s ghost is 40px everywhere else in the product; in a toast the
1025
+ operator is often on a tablet at a gate, so it is raised to the touch
1026
+ minimum here rather than changed for every screen. */
1027
+ .anpr-toast__actions .app-btn {
1028
+ min-height: 44px;
1029
+ }
1030
+
899
1031
  /* ------------------------------------------------------------------ */
900
1032
  /* The "Back" link that sits above a page title. */
901
1033
  /* `SpecificAttr.vue` (17 caller files) and `Container/Standard.vue`. */
@@ -284,8 +284,12 @@
284
284
  pointer-events: none;
285
285
  }
286
286
 
287
+ /* `button` is on the list because the design's own controls - `AppButton` and
288
+ the plate toast's close - are plain `<button>` elements, not `v-btn`. Left
289
+ off, a redesigned toast draws a button that cannot be clicked. */
287
290
  .v-snackbar .v-snackbar__wrapper .v-btn,
288
291
  .v-snackbar .v-snackbar__wrapper a,
292
+ .v-snackbar .v-snackbar__wrapper button,
289
293
  .v-snackbar .v-snackbar__wrapper [role="button"] {
290
294
  pointer-events: auto;
291
295
  }
@@ -482,6 +482,55 @@
482
482
  </draggable>
483
483
  </section>
484
484
 
485
+ <!-- RESIDENT CHECKLISTS -->
486
+ <v-col cols="12" class="mt-4 border-t">
487
+ <v-row align="center" no-gutters class="pt-5">
488
+ <v-col cols="9" class="d-flex align-center text-body-2">
489
+ <v-row no-gutters>
490
+ <v-col cols="12" class="header-style">
491
+ Resident Checklists
492
+ </v-col>
493
+ <v-col cols="12" class="text-body-2 text-medium-emphasis">
494
+ Allow residents to view and complete assigned checklists. Each
495
+ checklist requires a photo upload before submission.
496
+ </v-col>
497
+ </v-row>
498
+ </v-col>
499
+ <v-col cols="3" class="d-flex align-center justify-end">
500
+ <v-switch
501
+ v-model="facility.isResidentChecklistEnabled"
502
+ class="d-flex align-center"
503
+ color="accent"
504
+ hide-details
505
+ @update:model-value="onToggleResidentChecklist"
506
+ />
507
+ </v-col>
508
+ </v-row>
509
+
510
+ <!-- SECURITY CHECKLISTS -->
511
+ <v-row align="center" no-gutters class="border-t pt-5 mt-5">
512
+ <v-col cols="9" class="d-flex align-center text-body-2">
513
+ <v-row no-gutters>
514
+ <v-col cols="12" class="header-style">
515
+ Security Checklists
516
+ </v-col>
517
+ <v-col cols="12" class="text-body-2 text-medium-emphasis">
518
+ Allow Security to view and complete assigned checklists
519
+ </v-col>
520
+ </v-row>
521
+ </v-col>
522
+ <v-col cols="3" class="d-flex align-center justify-end">
523
+ <v-switch
524
+ v-model="facility.isSecurityChecklistEnabled"
525
+ class="d-flex align-center"
526
+ color="accent"
527
+ hide-details
528
+ @update:model-value="onToggleSecurityChecklist"
529
+ />
530
+ </v-col>
531
+ </v-row>
532
+ </v-col>
533
+
485
534
  <v-col cols="12" class="mt-10">
486
535
  <p class="header-style font-weight-bold mb-5 mt-md-0 ml-md-4">
487
536
  Other Settings
@@ -1020,6 +1069,20 @@ watchEffect(() => {
1020
1069
  }
1021
1070
  });
1022
1071
 
1072
+ /**
1073
+ * One checklist, one owner, and always one. A facility is completed either by
1074
+ * its residents or by Security, so the two switches are each other's inverse:
1075
+ * turning either off turns the other on. There is no state where a facility
1076
+ * has no checklist owner.
1077
+ */
1078
+ function onToggleResidentChecklist(enabled: boolean | null) {
1079
+ facility.value.isSecurityChecklistEnabled = !enabled;
1080
+ }
1081
+
1082
+ function onToggleSecurityChecklist(enabled: boolean | null) {
1083
+ facility.value.isResidentChecklistEnabled = !enabled;
1084
+ }
1085
+
1023
1086
  function onToggleBookingUnitLimit(val: any) {
1024
1087
  if (val) {
1025
1088
  isBookingUnitLimitEnabled.value = true;
@@ -276,7 +276,21 @@ const { data: roleData, refresh: refreshRoles } = await useLazyAsyncData(
276
276
  )
277
277
 
278
278
  watchEffect(() => {
279
- if (roleData.value) roles.value = roleData.value.items
279
+ /*
280
+ * The App field above offers the seven service types and never the Seven365
281
+ * staff type (`APP_LIST`), so every invitation this screen can send is a
282
+ * non-staff one -- and `core invite-role-scope.util roleInvitable` refuses a
283
+ * `type: "admin"` role on any of those, without exception. The request that
284
+ * fills this list goes out as `org: "", type: ""`, which is the ORG-LESS set:
285
+ * on staging that is 12 roles, 2 of them `type: "admin"`. So 2 of the 12
286
+ * options could only ever be picked and then refused.
287
+ *
288
+ * Display only. The server's decision is unchanged, and nothing this form can
289
+ * successfully send is removed -- the 10 `type: "organization"` templates,
290
+ * including "Org Owner" (117 live members, 321 invitations), all stay.
291
+ */
292
+ if (roleData.value)
293
+ roles.value = roleData.value.items.filter((r: any) => r?.type !== 'admin')
280
294
  })
281
295
 
282
296
  watch(
@@ -109,28 +109,24 @@
109
109
  </AppButton>
110
110
 
111
111
  <!-- one channel per row: a switch must never sit beside the
112
- NEXT channel's label, which is what a three-up grid does -->
112
+ NEXT channel's label, which is what a three-up grid does.
113
+ Only channels this category can really deliver on are
114
+ drawn — a switch that will not move is not a setting. -->
113
115
  <v-row no-gutters>
114
116
  <v-col
115
- v-for="(channel, index) in category.channels"
117
+ v-for="(channel, index) in switchableIn(category)"
116
118
  :key="channel.key"
117
119
  cols="12"
118
- :class="index < category.channels.length - 1 ? 'border-b-thin' : ''"
120
+ :class="index < switchableIn(category).length - 1 ? 'border-b-thin' : ''"
119
121
  >
120
- <div
121
- class="d-flex align-center justify-space-between py-2"
122
- :class="{ 'channel-unavailable': !channel.supported }"
123
- >
122
+ <div class="d-flex align-center justify-space-between py-2">
124
123
  <div class="pr-4">
125
124
  <div class="channel-label">{{ channel.label }}</div>
126
- <div v-if="!channel.supported" class="channel-note mt-1">
127
- {{ channel.note }}
128
- </div>
129
125
  </div>
130
126
 
131
127
  <v-switch
132
128
  :model-value="channel.enabled"
133
- :disabled="!channel.supported || saving"
129
+ :disabled="saving"
134
130
  color="primary"
135
131
  hide-details
136
132
  density="compact"
@@ -206,11 +202,17 @@ const allOn = computed(
206
202
  categories.value.every((category) => categoryAllOn(category)),
207
203
  );
208
204
 
209
- /** what is on, in words — so a collapsed panel still says what it is doing */
205
+ /**
206
+ * What is on, in words — so a collapsed panel still says what it is doing.
207
+ *
208
+ * The channels are NAMED rather than summarised as "on everywhere". Not every
209
+ * category can reach a person every way, so "everywhere" was a claim about
210
+ * three channels for a category that only ever had two — the screen said the
211
+ * email nobody sends was on.
212
+ */
210
213
  function summaryFor(category: TNotificationCategorySetting) {
211
214
  const on = switchableIn(category).filter((c) => c.enabled);
212
215
  if (!on.length) return "Off";
213
- if (on.length === switchableIn(category).length) return "On everywhere";
214
216
  return `On: ${on.map((c) => c.label).join(", ")}`;
215
217
  }
216
218
 
@@ -357,17 +359,4 @@ onMounted(load);
357
359
  font-size: var(--fs-breadcrumb);
358
360
  color: var(--text2);
359
361
  }
360
-
361
- /* Unavailable channels are shown and explained, never hidden.
362
- *
363
- * They are NOT faded. The disabled switch already says the control cannot be
364
- * moved, and the sentence beside it is the only place a person is told why —
365
- * dimming that sentence is dimming the explanation. A blanket opacity here
366
- * measured 2.3:1 against the card, which is unreadable; the row is now marked
367
- * by a rule down its edge instead, and every word stays at full strength. */
368
- .channel-unavailable {
369
- border-left: 2px solid rgb(var(--v-border-color));
370
- padding-left: 12px;
371
- opacity: 1;
372
- }
373
362
  </style>
@@ -36,19 +36,6 @@
36
36
  </v-row>
37
37
  </v-col>
38
38
 
39
- <v-col cols="12" class="mt-3">
40
- <div class="role-create__legend">
41
- <span class="d-flex align-center ga-2">
42
- <v-icon class="role-create__dot--both" size="14">mdi-circle</v-icon>
43
- Web and Mobile
44
- </span>
45
- <span class="d-flex align-center ga-2">
46
- <v-icon class="role-create__dot--web" size="14">mdi-circle</v-icon>
47
- Web only
48
- </span>
49
- </div>
50
- </v-col>
51
-
52
39
  <v-col cols="12" class="mt-2">
53
40
  <AppButton
54
41
  variant="ghost"
@@ -73,7 +60,7 @@
73
60
  <StatusChip
74
61
  class="mr-3"
75
62
  :dot="false"
76
- :tone="isWebOnly(String(resourceKey)) ? 'info' : 'warn'"
63
+ tone="info"
77
64
  :label="String(selectedActionCount(String(resourceKey)))"
78
65
  />
79
66
  </template>
@@ -181,10 +168,6 @@ const props = defineProps({
181
168
  type: Boolean,
182
169
  default: true,
183
170
  },
184
- webOnlyResources: {
185
- type: Array as PropType<string[]>,
186
- default: () => [],
187
- },
188
171
  cancelText: {
189
172
  type: String,
190
173
  default: "Cancel",
@@ -213,12 +196,7 @@ const resourceLabels: Record<string, string> = {
213
196
  };
214
197
 
215
198
  function formatResourceLabel(key: string): string {
216
- const label = resourceLabels[key] ?? key.replace(/-/g, " ");
217
- return props.webOnlyResources.includes(key) ? `${label} (Web Only)` : label;
218
- }
219
-
220
- function isWebOnly(resource: string) {
221
- return props.webOnlyResources.includes(resource);
199
+ return resourceLabels[key] ?? key.replace(/-/g, " ");
222
200
  }
223
201
 
224
202
  function isCategoryEnabled(resource: string) {
@@ -313,7 +291,6 @@ async function submit() {
313
291
  type: props.type,
314
292
  org: props.org,
315
293
  site: props.siteId,
316
- platform: "website",
317
294
  });
318
295
  emit("success");
319
296
  } catch (error: any) {
@@ -381,25 +358,6 @@ const isAllSelected = computed(() => {
381
358
  max-height: calc(100vh - 160px);
382
359
  }
383
360
 
384
- .role-create__legend {
385
- display: flex;
386
- align-items: center;
387
- gap: 16px;
388
- font-size: var(--fs-breadcrumb);
389
- color: var(--text2);
390
- }
391
-
392
- /* Were `amber-darken-2` / `blue-darken-2` - fixed Vuetify hues that do not
393
- follow the theme, and the same two the count chip used. Design tones now,
394
- and the dot and the chip read the same `isWebOnly`, so they cannot drift. */
395
- .role-create__dot--both {
396
- color: var(--warn);
397
- }
398
-
399
- .role-create__dot--web {
400
- color: var(--info);
401
- }
402
-
403
361
  /* Was a `variant="outlined"` v-card inside the card - a card on a card. It is
404
362
  the list frame, so it takes the design's border and radius and no second
405
363
  surface. */
@@ -7,16 +7,6 @@
7
7
  <v-form v-model="validForm" :disabled="disable">
8
8
  <v-row no-gutters>
9
9
  <v-col cols="12" class="mt-4">
10
- <div class="role-perm__legend">
11
- <span class="d-flex align-center ga-2">
12
- <v-icon class="role-perm__dot--both" size="14">mdi-circle</v-icon>
13
- Web and Mobile
14
- </span>
15
- <span class="d-flex align-center ga-2">
16
- <v-icon class="role-perm__dot--web" size="14">mdi-circle</v-icon>
17
- Web only
18
- </span>
19
- </div>
20
10
  <AppButton
21
11
  v-if="edit"
22
12
  variant="ghost"
@@ -36,7 +26,7 @@
36
26
  <StatusChip
37
27
  class="mr-3"
38
28
  :dot="false"
39
- :tone="isWebOnly(String(resourceKey)) ? 'info' : 'warn'"
29
+ tone="info"
40
30
  :label="String(selectedActionCount(String(resourceKey)))"
41
31
  />
42
32
  </template>
@@ -157,10 +147,6 @@ const props = defineProps({
157
147
  type: Object,
158
148
  default: () => ({}),
159
149
  },
160
- webOnlyResources: {
161
- type: Array as PropType<string[]>,
162
- default: () => [],
163
- },
164
150
  // "Update role". This dialog had no permission prop at all, so it showed Edit
165
151
  // to everyone -- including on the seeded platform-owner role -- and the
166
152
  // `canUpdateRole` the apps have been passing to `RolePermissionMain` in good
@@ -182,12 +168,20 @@ const resourceLabels: Record<string, string> = {
182
168
  };
183
169
 
184
170
  function formatResourceLabel(key: string) {
185
- const label = resourceLabels[key] ?? key.replace(/-/g, " ");
186
- return props.webOnlyResources.includes(key) ? `${label} (Web Only)` : label;
171
+ return resourceLabels[key] ?? key.replace(/-/g, " ");
187
172
  }
188
173
 
189
- function isWebOnly(resource: string) {
190
- return props.webOnlyResources.includes(resource);
174
+ /**
175
+ * Is this box ticked?
176
+ *
177
+ * The same grant is stored under more than one spelling. An exact `includes()`
178
+ * showed a role holding `work-orders:see-all-work-orders` as NOT having
179
+ * `workOrder:see-all-work-orders`, so the dialog reported a grant the role
180
+ * really holds as absent -- and unticking a box then cleared nothing. Ticks are
181
+ * alias-aware, and so is the untick below.
182
+ */
183
+ function isActionSelected(resource: string, action: string) {
184
+ return holdsPermission(definedModel.value, `${resource}:${action}`);
191
185
  }
192
186
 
193
187
  /**
@@ -340,27 +334,6 @@ async function submit() {
340
334
  max-height: calc(100vh - 160px);
341
335
  }
342
336
 
343
- .role-perm__legend {
344
- display: flex;
345
- align-items: center;
346
- gap: 16px;
347
- margin-bottom: 12px;
348
- font-size: var(--fs-breadcrumb);
349
- color: var(--text2);
350
- }
351
-
352
- /* The two legend dots carried `amber-darken-2` and `blue-darken-2` - fixed
353
- Vuetify hues that do not follow the theme, and the same two hues the count
354
- chip beside each row used. Both are the design's tones now, and the chip and
355
- the dot stay in step because they read the same `isWebOnly`. */
356
- .role-perm__dot--both {
357
- color: var(--warn);
358
- }
359
-
360
- .role-perm__dot--web {
361
- color: var(--info);
362
- }
363
-
364
337
  /* Was a `variant="outlined"` v-card, i.e. a card inside a card. It is the list
365
338
  frame, so it takes the design's card border and radius without laying a
366
339
  second surface over the first. */
@@ -52,6 +52,20 @@
52
52
  @click:row="tableRowClickHandler"
53
53
  style="max-height: calc(100vh - (180px))"
54
54
  >
55
+ <!--
56
+ SCOPE. Only rendered when a page puts `scope` in its `headers`,
57
+ which is the console's Roles and Permissions screen and nothing
58
+ else. Two kinds share that list and they are governed differently,
59
+ so the row has to say which it is.
60
+ -->
61
+ <template #item.scope="{ item }">
62
+ <StatusChip
63
+ :dot="false"
64
+ :tone="item.type === 'admin' ? 'info' : 'neutral'"
65
+ :label="scopeLabel(item)"
66
+ />
67
+ </template>
68
+
55
69
  <template #item.permissions="{ value }">
56
70
  <span class="text-caption font-weight-bold text-capitalize">
57
71
  permissions
@@ -86,7 +100,6 @@
86
100
  :org="props.orgId"
87
101
  :site-id="props.siteId"
88
102
  :site-state="siteFieldShown"
89
- :web-only-resources="props.webOnlyResources"
90
103
  @success="success()"
91
104
  :type="props.type"
92
105
  @success:create-more="getRoles()"
@@ -104,7 +117,6 @@
104
117
  :name="name"
105
118
  :id="roleId"
106
119
  :can-update-role="props.canUpdateRole"
107
- :web-only-resources="props.webOnlyResources"
108
120
  />
109
121
  </v-dialog>
110
122
 
@@ -221,15 +233,34 @@ const props = defineProps({
221
233
  required: true,
222
234
  default: "app",
223
235
  },
236
+ /*
237
+ * The `type` the LIST is filtered by, when it differs from the `type` a
238
+ * newly created role is given.
239
+ *
240
+ * They were the same value, and on the Seven365 console that was the defect:
241
+ * the screen passed `type="admin"`, so it listed the 2 platform-staff roles
242
+ * and nothing else -- while the console's own "Invite Client" picker asks
243
+ * `GET /api/roles` with no `type` and is offered all 12 ORG-LESS roles
244
+ * (10 `type: "organization"` templates + those same 2). A super admin could
245
+ * therefore hand out ten roles the Roles and Permissions screen could not
246
+ * show, edit or delete.
247
+ *
248
+ * The server has always allowed it: an org-less role of ANY type goes to
249
+ * `requireConsolePermission("roles-and-permissions")`
250
+ * (`core role.controller requireRoleOrg`), so this only stops the UI hiding
251
+ * what the console may already manage. `null` keeps every other page exactly
252
+ * as it was; `""` means "do not filter by type", which for an org-less
253
+ * caller IS the administrative scope.
254
+ */
255
+ listType: {
256
+ type: String,
257
+ default: null,
258
+ },
224
259
  permissions: {
225
260
  type: Object,
226
261
  required: true,
227
262
  default: () => ({}),
228
263
  },
229
- webOnlyResources: {
230
- type: Array as PropType<string[]>,
231
- default: () => [],
232
- },
233
264
  headers: {
234
265
  type: Array as PropType<Array<Record<string, any>>>,
235
266
  default: () => [
@@ -296,7 +327,7 @@ const {
296
327
  _getRoles({
297
328
  page: page.value,
298
329
  search: headerSearch.value,
299
- type: props.type,
330
+ type: props.listType ?? props.type,
300
331
  org: props.orgId,
301
332
  site: props.siteId,
302
333
  }),
@@ -338,6 +369,19 @@ const emptyText = computed(() => {
338
369
  return "No roles have been created yet.";
339
370
  });
340
371
 
372
+ /**
373
+ * What KIND of role a row is, in the words the console needs.
374
+ *
375
+ * A role with no `org` is not a client's -- it is either the Seven365 console's
376
+ * own staff role (`type: "admin"`) or an org-less TEMPLATE that any invitation
377
+ * may hand out. Both are managed here; only the second one leaves this system.
378
+ */
379
+ function scopeLabel(item: Record<string, any>) {
380
+ if (item?.type === "admin") return "Platform staff";
381
+ if (props.orgId) return "Organisation";
382
+ return "Client template";
383
+ }
384
+
341
385
  function tableRowClickHandler(_: any, data: any) {
342
386
  // "See role details". Ungated until now, which is why granting or withholding
343
387
  // it changed nothing.
@@ -31,38 +31,54 @@
31
31
  </ul>
32
32
  </section> -->
33
33
 
34
+ <!--
35
+ THE PLATE TOAST.
36
+
37
+ The estate's own toast surface (`.app-toast`, `assets/css/screens.css`)
38
+ rather than Vuetify's flat `color="info"` slab, and the plate is set
39
+ apart from the label because the plate IS the payload - a guard reads the
40
+ number, not the sentence around it. Nothing here changes when the toast
41
+ fires, what it links to, or how long it stays; only how it is drawn.
42
+ -->
34
43
  <v-snackbar
35
44
  v-if="!isUnregisteredVisitorRoute && enableUnregisteredSnackbar && canViewVisitor"
36
45
  v-model="snackBarMessage.modal"
37
- :color="snackBarMessage.color"
38
- :timeout="snackBarMessage.timeout"
46
+ :timeout="-1"
39
47
  location="bottom center"
40
- class="rounded-xl"
48
+ class="app-toast anpr-toast"
41
49
  multi-line
42
50
  :z-index="100000000"
43
51
  >
44
- <div class="d-flex flex-column align-start ga-2">
45
- <div class="d-flex align-center ga-2">
46
- <span class="text-1-4rem mr-2">{{ snackBarMessage.text }}</span>
52
+ <div class="anpr-toast__row">
53
+ <span class="anpr-toast__icon" aria-hidden="true">
54
+ <v-icon icon="mdi-car" :size="20" />
55
+ </span>
56
+
57
+ <!--
58
+ One live region for both halves, so a screen reader announces
59
+ "New plate detected SLD7537A" as a single message. `polite`: a plate
60
+ read must not interrupt whatever the operator is being told.
61
+ -->
62
+ <div class="anpr-toast__text" role="status" aria-live="polite">
63
+ <span class="anpr-toast__label">{{ plateCopy.label }}</span>
64
+ <span class="anpr-toast__plate">{{ plateCopy.plate }}</span>
47
65
  </div>
48
- <v-btn
49
- rounded="md"
50
- variant="text"
51
- color="white"
52
- class="text-truncate text-decoration-underline px-0"
53
- @click="goToUnregistered"
66
+
67
+ <button
68
+ type="button"
69
+ class="anpr-toast__close"
70
+ aria-label="Dismiss plate notification"
71
+ @click="handleCloseSnackbar"
54
72
  >
55
- Go to Unregistered
56
- </v-btn>
73
+ <v-icon icon="mdi-close" :size="18" />
74
+ </button>
57
75
  </div>
58
76
 
59
- <template #actions>
60
- <v-btn
61
- icon="mdi-close"
62
- variant="text"
63
- @click="handleCloseSnackbar"
64
- />
65
- </template>
77
+ <div class="anpr-toast__actions">
78
+ <AppButton variant="ghost" @click="goToUnregistered">
79
+ Go to Unregistered
80
+ </AppButton>
81
+ </div>
66
82
  </v-snackbar>
67
83
 
68
84
  <!--
@@ -137,11 +153,15 @@ const visitorList = ref<TVisitorSocketData[]>([]);
137
153
  const lastPlateNumber = ref("");
138
154
 
139
155
  const snackBarMessage = reactive({
140
- timeout: 3000,
141
- text: "",
142
- color: "",
156
+ /** The camera's raw read. `plateToast` decides what is drawn for it. */
157
+ plateNumber: "",
143
158
  modal: false,
144
- isUnregistered: false,
159
+ });
160
+
161
+ const plateCopy = computed(() => plateToast(snackBarMessage.plateNumber));
162
+
163
+ const plateToastWindow = createPlateToastWindow(() => {
164
+ snackBarMessage.modal = false;
145
165
  });
146
166
 
147
167
  const permanentMessageDialog = reactive({
@@ -226,20 +246,23 @@ const handleCloseSnackbar = () => {
226
246
 
227
247
  };
228
248
 
229
- const showTransientMessage = (
230
- text: string,
231
- color: string,
232
- isUnregistered = false
233
- ) => {
249
+ /*
250
+ * Several reads in quick succession REPLACE each other in this one toast -
251
+ * they have never stacked, and they still do not. At a busy gate a queue of
252
+ * toasts would put the operator several plates behind the barrier; the newest
253
+ * read is the one that matters, and the ones before it are on the Unregistered
254
+ * tab the toast links to.
255
+ */
256
+ const showPlate = (plateNumber: string) => {
234
257
  if (!enableUnregisteredSnackbar.value) {
235
258
  return;
236
259
  }
237
260
 
238
- snackBarMessage.text = text;
239
- snackBarMessage.color = color;
261
+ snackBarMessage.plateNumber = plateNumber;
240
262
  snackBarMessage.modal = true;
241
- snackBarMessage.timeout = 20000;
242
- snackBarMessage.isUnregistered = isUnregistered;
263
+ // Restart the 20s window from zero. A replacement plate gets a full window
264
+ // of its own; without this it inherited whatever was left of the one before.
265
+ plateToastWindow.restart();
243
266
  };
244
267
 
245
268
  const connectSocket = () => {
@@ -270,11 +293,7 @@ const connectSocket = () => {
270
293
  newVisitor.value = data;
271
294
 
272
295
  if (isCheckIn) {
273
- showTransientMessage(
274
- `New plate detected: ${plateNumber}`,
275
- "info",
276
- true
277
- );
296
+ showPlate(plateNumber);
278
297
  lastPlateNumber.value = plateNumber;
279
298
  return;
280
299
  }
@@ -359,7 +378,33 @@ watch(enableUnregisteredSnackbar, (enabled) => {
359
378
  }
360
379
  });
361
380
 
381
+ /*
382
+ * Escape closes it. The close button is a real `<button>` and is reachable by
383
+ * tab, so the toast was already dismissible from the keyboard; Escape is what
384
+ * anyone actually reaches for, and it is bound only while the toast is up.
385
+ */
386
+ const onEscape = (event: KeyboardEvent) => {
387
+ if (event.key === "Escape") handleCloseSnackbar();
388
+ };
389
+
390
+ watch(
391
+ () => snackBarMessage.modal,
392
+ (open) => {
393
+ // Every route to a closed toast - the close button, Escape, the
394
+ // unregistered tab, the site setting - lands here, so the outstanding
395
+ // window is dropped in one place rather than at each of them.
396
+ if (!open) plateToastWindow.cancel();
397
+ if (typeof document === "undefined") return;
398
+ if (open) document.addEventListener("keydown", onEscape);
399
+ else document.removeEventListener("keydown", onEscape);
400
+ }
401
+ );
402
+
362
403
  onUnmounted(() => {
404
+ plateToastWindow.cancel();
405
+ if (typeof document !== "undefined") {
406
+ document.removeEventListener("keydown", onEscape);
407
+ }
363
408
  disconnectSocket();
364
409
  });
365
410
 
@@ -76,6 +76,8 @@ export default function usetFacility() {
76
76
  hourInterval?: number;
77
77
  isBookingFeeEnabled: boolean;
78
78
  isGuestEnabled: boolean;
79
+ isResidentChecklistEnabled: boolean;
80
+ isSecurityChecklistEnabled: boolean;
79
81
  bookingAmount: number | null;
80
82
  peakBookingFeeAmount?: number | null;
81
83
  bookingFeeGuestAmount?: number | null;
@@ -173,6 +175,8 @@ export default function usetFacility() {
173
175
  hourInterval = 1,
174
176
  isBookingFeeEnabled = false,
175
177
  isGuestEnabled = false,
178
+ isResidentChecklistEnabled = false,
179
+ isSecurityChecklistEnabled = false,
176
180
  bookingAmount = 0,
177
181
  peakBookingFeeAmount = 0,
178
182
  bookingFeeGuestAmount = 0,
@@ -236,6 +240,13 @@ export default function usetFacility() {
236
240
  this.hourInterval = hourInterval;
237
241
  this.isBookingFeeEnabled = isBookingFeeEnabled;
238
242
  this.isGuestEnabled = isGuestEnabled;
243
+ // Exactly one owner, always. `isResidentChecklistEnabled` is the flag
244
+ // the apps gate on, so it decides, and security is its complement —
245
+ // stored rather than computed so each app can read its own flag without
246
+ // knowing the rule. A facility predating both fields lands on security,
247
+ // which is how every one of them already behaved.
248
+ this.isResidentChecklistEnabled = isResidentChecklistEnabled === true;
249
+ this.isSecurityChecklistEnabled = !this.isResidentChecklistEnabled;
239
250
  this.bookingAmount = bookingAmount;
240
251
  this.peakBookingFeeAmount = peakBookingFeeAmount;
241
252
  this.bookingFeeGuestAmount = bookingFeeGuestAmount;
@@ -14,10 +14,13 @@
14
14
  export type TNotificationChannelSetting = {
15
15
  key: string;
16
16
  label: string;
17
- /** false = this category cannot reach them this way; drawn, dimmed, explained */
17
+ /**
18
+ * Whether this category can reach them this way at all. The server now sends
19
+ * only the channels that can, so this is true for everything it sends; the
20
+ * screen still filters on it so an older server, which sent all three and
21
+ * marked the dead one false, draws the same two switches.
22
+ */
18
23
  supported: boolean;
19
- /** the plain-English reason, present only when unsupported */
20
- note?: string;
21
24
  enabled: boolean;
22
25
  };
23
26
 
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The 20-second window a plate toast stays up for.
3
+ *
4
+ * Vuetify does NOT restart a snackbar's countdown when an already-open
5
+ * snackbar is re-shown with the same timeout. `VSnackbar` starts its timer
6
+ * from two watchers only -
7
+ *
8
+ * watch(isActive, startTimeout)
9
+ * watch(() => props.timeout, startTimeout)
10
+ *
11
+ * - and a Vue watcher does not fire when the value it watches is assigned the
12
+ * value it already holds. Re-showing the toast with `modal = true` and
13
+ * `timeout = 20000` while both were already `true` and `20000` therefore left
14
+ * the FIRST plate's timer running: a replacement read arriving at 19s
15
+ * inherited the 1s that was left of the plate before it, and was gone before
16
+ * the guard could read it.
17
+ *
18
+ * So the window is owned here instead of by Vuetify. The snackbar runs with
19
+ * `timeout: -1` (Vuetify's "never close on your own") and every plate clears
20
+ * the outstanding timer and starts a fresh one. This is the same shape the
21
+ * React Native app already uses (`visitor-socket-monitor.tsx`), which is why
22
+ * the defect never appeared there.
23
+ */
24
+ export const PLATE_TOAST_MS = 20000;
25
+
26
+ export type TPlateToastWindow = {
27
+ /** Start the window, or restart it from zero if one is already running. */
28
+ restart: () => void;
29
+ /** Drop the outstanding window - the toast was closed by something else. */
30
+ cancel: () => void;
31
+ };
32
+
33
+ export const createPlateToastWindow = (
34
+ close: () => void,
35
+ ms: number = PLATE_TOAST_MS,
36
+ ): TPlateToastWindow => {
37
+ let handle: ReturnType<typeof setTimeout> | null = null;
38
+
39
+ const cancel = () => {
40
+ if (handle !== null) {
41
+ clearTimeout(handle);
42
+ handle = null;
43
+ }
44
+ };
45
+
46
+ return {
47
+ restart: () => {
48
+ cancel();
49
+ handle = setTimeout(() => {
50
+ handle = null;
51
+ close();
52
+ }, ms);
53
+ },
54
+ cancel,
55
+ };
56
+ };
@@ -31,6 +31,60 @@ export default function useRole() {
31
31
  });
32
32
  }
33
33
 
34
+ /**
35
+ * The roles an INVITATION into `org` may actually hand out.
36
+ *
37
+ * The invite endpoints refuse a role the invitation is not entitled to
38
+ * (`core console-authz.util requireRoleInvitable` -> `invite-role-scope.util
39
+ * roleInvitable`), and that decision is a UNION that `GET /api/roles` cannot
40
+ * express in one call:
41
+ *
42
+ * - an ORG-LESS role is a template and is accepted for any organisation.
43
+ * Measured on staging: 341 of the 942 role-carrying invitations name one,
44
+ * so a picker that asks only for `org: <id>` locks every one of them out.
45
+ * - a role whose `org` IS the invited organisation.
46
+ * - never a `type: "admin"` role -- that is the Seven365 console's own staff
47
+ * type, and the server refuses it on any non-staff invitation.
48
+ *
49
+ * So: two reads, merged. `type: "organization"` on the org-less read is what
50
+ * excludes the staff roles there (the 12 org-less roles are 10 "organization"
51
+ * + 2 "admin"); the explicit filter covers the 1 org-SCOPED "admin" role,
52
+ * which the org read would otherwise return.
53
+ *
54
+ * `site` narrows the tenant half only, and only in the UI -- the server
55
+ * deliberately does not check a role's site, because a site is not a tenant
56
+ * boundary. A site-scoped screen still gets the organisation's site-less
57
+ * roles, because `getRoles` matches those too.
58
+ */
59
+ async function getInvitableRoles(
60
+ { search = "", org = "", site = "", limit = 50 } = {} as {
61
+ search?: string;
62
+ org?: string;
63
+ site?: string;
64
+ limit?: number;
65
+ }
66
+ ) {
67
+ const [tenant, templates] = await Promise.all([
68
+ org
69
+ ? getRoles({ search, org, site, limit })
70
+ : Promise.resolve({ items: [] } as Record<string, any>),
71
+ getRoles({ search, type: "organization", limit }),
72
+ ]);
73
+
74
+ const seen = new Set<string>();
75
+ const items = [...(tenant?.items ?? []), ...(templates?.items ?? [])].filter(
76
+ (role: Record<string, any>) => {
77
+ if (role?.type === "admin") return false;
78
+ const id = String(role?._id ?? "");
79
+ if (!id || seen.has(id)) return false;
80
+ seen.add(id);
81
+ return true;
82
+ }
83
+ );
84
+
85
+ return { items };
86
+ }
87
+
34
88
  function getRoleById(id: string) {
35
89
  return useNuxtApp().$api<TRole>(`/api/roles/id/${id}`, {
36
90
  method: "GET",
@@ -120,6 +174,7 @@ export default function useRole() {
120
174
  role,
121
175
  createRole,
122
176
  getRoles,
177
+ getInvitableRoles,
123
178
  getRoleById,
124
179
  updateRoleById,
125
180
  updateRoleFieldById,
@@ -33,6 +33,37 @@ export const cameraAlertMessage = (messages: string[]): string => {
33
33
  );
34
34
  };
35
35
 
36
+ /**
37
+ * The two halves of the plate toast.
38
+ *
39
+ * The camera's read is the payload, so it is returned SEPARATELY from the
40
+ * label rather than concatenated into one sentence - the toast sets it at its
41
+ * own size and weight, and a run-on `"New plate detected: SLD7537A"` cannot be
42
+ * typeset that way.
43
+ *
44
+ * `plate` is never empty: the socket only raises this toast when a plate was
45
+ * read, but a build that ever calls it without one gets a word rather than a
46
+ * dangling label. A read is a handful of characters - anything past
47
+ * `MAX_PLATE_CHARS` is a malformed payload, not a number plate, and is cut so
48
+ * it cannot stretch the toast off the screen.
49
+ */
50
+ export const MAX_PLATE_CHARS = 24;
51
+
52
+ export const plateToast = (
53
+ plateNumber?: string | null,
54
+ ): { label: string; plate: string } => {
55
+ const plate = (plateNumber ?? "").trim();
56
+
57
+ return {
58
+ label: "New plate detected",
59
+ plate: plate
60
+ ? plate.length > MAX_PLATE_CHARS
61
+ ? `${plate.slice(0, MAX_PLATE_CHARS)}…`
62
+ : plate
63
+ : "Unknown",
64
+ };
65
+ };
66
+
36
67
  export const useVisitorSocket = () => {
37
68
  const socketUnregisteredVisitorTrigger = useState(
38
69
  "socketUnregisteredVisitorTrigger",
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.2.21-staging.281",
5
+ "version": "4.2.21-staging.282",
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.",
@@ -36,7 +36,7 @@
36
36
  "build": "nuxt build .playground",
37
37
  "generate": "nuxt generate .playground",
38
38
  "preview": "nuxt preview .playground",
39
- "test": "esbuild composables/useVisitorSocket.ts --format=esm --outfile=test/.build/useVisitorSocket.mjs --log-level=error && node --experimental-strip-types --test \"test/*.test.mjs\" && yarn test:units",
39
+ "test": "esbuild composables/useVisitorSocket.ts --format=esm --outfile=test/.build/useVisitorSocket.mjs --log-level=error && esbuild composables/usePlateToastWindow.ts --format=esm --outfile=test/.build/usePlateToastWindow.mjs --log-level=error && node --experimental-strip-types --test \"test/*.test.mjs\" && yarn test:units",
40
40
  "test:units": "node --experimental-strip-types --test \"utils/*.test.ts\"",
41
41
  "release": "yarn run build && changeset publish"
42
42
  },
@@ -73,6 +73,10 @@ declare type TFacility = {
73
73
  hourInterval?: number;
74
74
  isBookingFeeEnabled: boolean;
75
75
  isGuestEnabled: boolean;
76
+ /** Residents may complete this facility's checklist themselves. */
77
+ isResidentChecklistEnabled?: boolean;
78
+ /** Security may complete it. Mutually exclusive with the above. */
79
+ isSecurityChecklistEnabled?: boolean;
76
80
  bookingAmount: number | null;
77
81
  peakBookingFeeAmount?: number | null;
78
82
  bookingFeeGuestAmount?: number | null;