@7365admin1/layer-common 4.2.20 → 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.
@@ -742,11 +742,35 @@
742
742
  class="visitor-preview__row"
743
743
  >
744
744
  <div class="visitor-preview__label">{{ label }}</div>
745
- <div
746
- v-tooltip:top="selectedVisitorObject[key]"
747
- class="visitor-preview__value"
748
- >
749
- {{ maskNRIC(selectedVisitorObject[key]) }}
745
+ <div>
746
+ <!-- Was a hover tooltip on the value: the full NRIC only
747
+ reachable by hovering, which says nothing is there to
748
+ reach and cannot be reached at all on a touch screen.
749
+ The eye alone, at the 14px the Incident Report screens
750
+ draw it, is a 14px target - the floor is 24px. So the
751
+ NUMBER is the control and the eye is its affordance:
752
+ the whole masked value is pressable, which makes the
753
+ target the width of the digits rather than of a glyph,
754
+ and being a real `button` it also takes a tab stop,
755
+ which a `v-icon` with a click handler never did. -->
756
+ <button
757
+ type="button"
758
+ class="visitor-preview__reveal"
759
+ :aria-label="showVisitorNric ? 'Hide NRIC' : 'Show NRIC'"
760
+ :aria-pressed="showVisitorNric"
761
+ @click="showVisitorNric = !showVisitorNric"
762
+ >
763
+ <span class="visitor-preview__value">
764
+ {{
765
+ showVisitorNric
766
+ ? selectedVisitorObject[key]
767
+ : maskNRIC(selectedVisitorObject[key])
768
+ }}
769
+ </span>
770
+ <v-icon size="16" class="visitor-preview__eye">
771
+ {{ showVisitorNric ? "mdi-eye-off-outline" : "mdi-eye-outline" }}
772
+ </v-icon>
773
+ </button>
750
774
  </div>
751
775
  </div>
752
776
 
@@ -796,6 +820,84 @@
796
820
  </div>
797
821
  </div>
798
822
 
823
+ <!--
824
+ THE CONTRACTOR'S PARTY.
825
+
826
+ The list row has always said `( +2 members)` beside the name
827
+ and then had nowhere to send you for the names themselves. The
828
+ block spans both columns rather than sitting in the 116px
829
+ value track: a member is a record, not a value, and several of
830
+ them in a 250px column is unreadable.
831
+
832
+ Read off `selectedVisitorDataObject` (the raw row) and not
833
+ `selectedVisitorObject`, which filters itself down to
834
+ `typeFieldMap` plus five fixed keys - `members` is on neither
835
+ list, and widening that computed would change what four other
836
+ dialogs on this screen see.
837
+ -->
838
+ <div
839
+ v-else-if="key === 'members' && selectedVisitorMembers.length"
840
+ class="visitor-preview__row visitor-preview__row--block"
841
+ >
842
+ <div class="visitor-preview__label">
843
+ {{ label }} ({{ selectedVisitorMembers.length }})
844
+ </div>
845
+ <div class="visitor-preview__members">
846
+ <div
847
+ v-for="(member, index) in selectedVisitorMembers"
848
+ :key="member?.nric || member?.name || index"
849
+ class="visitor-preview__member"
850
+ >
851
+ <div class="visitor-preview__value">
852
+ {{ member?.name || "N/A" }}
853
+ </div>
854
+ <template v-for="field in memberDetailFields" :key="field.key">
855
+ <div
856
+ v-if="member?.[field.key]"
857
+ class="visitor-preview__member-line"
858
+ >
859
+ <span class="visitor-preview__member-key">
860
+ {{ field.label }}
861
+ </span>
862
+ <!-- A member's NRIC is the same class of data as the
863
+ visitor's, so it gets the same control. Each
864
+ member reveals separately - one toggle for the
865
+ whole card would show three people's NRICs to
866
+ read one. -->
867
+ <button
868
+ v-if="field.key === 'nric'"
869
+ type="button"
870
+ class="visitor-preview__reveal"
871
+ :aria-label="
872
+ isMemberNricShown(index)
873
+ ? `Hide NRIC for ${member?.name || 'this member'}`
874
+ : `Show NRIC for ${member?.name || 'this member'}`
875
+ "
876
+ :aria-pressed="isMemberNricShown(index)"
877
+ @click="toggleMemberNric(index)"
878
+ >
879
+ <span>
880
+ {{
881
+ isMemberNricShown(index)
882
+ ? member.nric
883
+ : maskNRIC(member.nric)
884
+ }}
885
+ </span>
886
+ <v-icon size="16" class="visitor-preview__eye">
887
+ {{
888
+ isMemberNricShown(index)
889
+ ? "mdi-eye-off-outline"
890
+ : "mdi-eye-outline"
891
+ }}
892
+ </v-icon>
893
+ </button>
894
+ <span v-else>{{ member[field.key] }}</span>
895
+ </div>
896
+ </template>
897
+ </div>
898
+ </div>
899
+ </div>
900
+
799
901
  <div
800
902
  v-else-if="selectedVisitorObject[key]"
801
903
  class="visitor-preview__row"
@@ -1898,6 +2000,71 @@ const isSelectedVisitorPendingApproval = computed(
1898
2000
  () => selectedVisitorStatus.value === "pending"
1899
2001
  );
1900
2002
 
2003
+ /**
2004
+ * The members a contractor brought with them. Not gated on the Guests tab: the
2005
+ * list row's own `( +N members)` count is not either, and a contractor with a
2006
+ * party has one wherever the screen shows it.
2007
+ *
2008
+ * Blank entries are dropped rather than drawn as an empty card - the payload
2009
+ * carries `""` for every detail nobody filled in, so a member with no name and
2010
+ * no details would otherwise render as a bare inset box.
2011
+ */
2012
+ const selectedVisitorMembers = computed<Record<string, any>[]>(() => {
2013
+ const members = selectedVisitorDataObject.value?.members;
2014
+ if (!Array.isArray(members)) return [];
2015
+
2016
+ return members.filter(
2017
+ (member: Record<string, any>) =>
2018
+ member?.name || member?.nric || member?.contact || member?.plateNumber
2019
+ );
2020
+ });
2021
+
2022
+ /**
2023
+ * WHICH NRICs ARE UNCOVERED RIGHT NOW.
2024
+ *
2025
+ * Per member and not per card, so revealing one person's number does not
2026
+ * uncover the rest of the party's. Both are cleared when the dialog closes -
2027
+ * a preview must not open on the next visitor with the last one's NRIC
2028
+ * already showing, and it is the same `selectedVisitorId` that would carry it
2029
+ * across if the same row were reopened.
2030
+ */
2031
+ const showVisitorNric = ref(false);
2032
+ const shownMemberNrics = ref<number[]>([]);
2033
+
2034
+ function isMemberNricShown(index: number) {
2035
+ return shownMemberNrics.value.includes(index);
2036
+ }
2037
+
2038
+ function toggleMemberNric(index: number) {
2039
+ shownMemberNrics.value = isMemberNricShown(index)
2040
+ ? shownMemberNrics.value.filter((x) => x !== index)
2041
+ : [...shownMemberNrics.value, index];
2042
+ }
2043
+
2044
+ watch(
2045
+ () => dialog.viewVisitor,
2046
+ (open) => {
2047
+ if (open) return;
2048
+ showVisitorNric.value = false;
2049
+ shownMemberNrics.value = [];
2050
+ }
2051
+ );
2052
+
2053
+ /**
2054
+ * What a member row prints under the name, in order. `plateNumber` is in here
2055
+ * because the API returns it on `members[]` even though neither
2056
+ * `TMemberInfo` (this package) nor `TContractorMembers` (API-core's visitor
2057
+ * model, name and nric only) declares it - the two types have drifted from the
2058
+ * document and from each other. Reading the key defensively costs nothing and
2059
+ * shows the vehicle a member actually arrived in; the types are somebody's to
2060
+ * reconcile separately.
2061
+ */
2062
+ const memberDetailFields = [
2063
+ { key: "nric", label: "NRIC" },
2064
+ { key: "contact", label: "Contact" },
2065
+ { key: "plateNumber", label: "Vehicle" },
2066
+ ] as const;
2067
+
1901
2068
  const formatType = (item: any) =>
1902
2069
  (item.deliveryType ? item.deliveryType + "-" : "") + item.type;
1903
2070
 
@@ -1911,6 +2078,7 @@ const formattedFields = {
1911
2078
  level: "Level",
1912
2079
  unit: "Unit",
1913
2080
  purpose: "Purpose",
2081
+ members: "Members",
1914
2082
  checkIn: "Check In",
1915
2083
  snapshotEntryImage: "Entry Image",
1916
2084
  checkOut: "Check Out",
@@ -2889,6 +3057,100 @@ watchEffect(async () => {
2889
3057
  word-break: break-word;
2890
3058
  }
2891
3059
 
3060
+ /* A row whose value is a set of records rather than a value - it drops the
3061
+ two-column grid and runs the full width of the card body. */
3062
+ .visitor-preview__row--block {
3063
+ display: block;
3064
+ }
3065
+
3066
+ .visitor-preview__members {
3067
+ display: flex;
3068
+ flex-direction: column;
3069
+ gap: 8px;
3070
+ margin-top: 8px;
3071
+ }
3072
+
3073
+ /*
3074
+ * An added member reads as an inset on the card it sits in - `--hover` on
3075
+ * `--border` at the inner radius. Those are `Card/MemberInfoSummary`'s three
3076
+ * decisions, unchanged, so a member looks the same in the preview as it does
3077
+ * in the form that created it. Only the TYPE differs: that card still prints
3078
+ * `<strong>Label:</strong> value`, which is the pattern this dialog just moved
3079
+ * off, so the lines below are set on the scale rather than inherited.
3080
+ */
3081
+ .visitor-preview__member {
3082
+ padding: 9px 12px;
3083
+ border: 1px solid var(--border);
3084
+ border-radius: var(--r-inner);
3085
+ background: var(--hover);
3086
+ }
3087
+
3088
+ .visitor-preview__member-line {
3089
+ display: flex;
3090
+ gap: 8px;
3091
+ margin-top: 3px;
3092
+ font-size: var(--fs-breadcrumb);
3093
+ color: var(--text2);
3094
+ word-break: break-word;
3095
+ }
3096
+
3097
+ .visitor-preview__member-key {
3098
+ flex: 0 0 52px;
3099
+ color: var(--muted);
3100
+ }
3101
+
3102
+ /*
3103
+ * THE NRIC REVEAL.
3104
+ *
3105
+ * The pressable thing is the masked number, not the glyph beside it: an eye on
3106
+ * its own is a 14-16px target where 24px is the floor, and on a 12.5px member
3107
+ * line an `AppButton variant="icon"` - the layer's 32px icon square - would
3108
+ * make the NRIC line half again the height of the Contact line under it.
3109
+ * Pressing the digits gives a target the width of the value at no cost to the
3110
+ * rhythm, and reads the right way round: the number is what changes.
3111
+ *
3112
+ * It inherits its type rather than setting any, so the visitor's NRIC stays on
3113
+ * `--fs-cell` and a member's on the `--fs-breadcrumb` of the line it sits in.
3114
+ * The negative margin pays back the padding, so a revealed value starts on the
3115
+ * same left edge as every other value in the card.
3116
+ */
3117
+ .visitor-preview__reveal {
3118
+ display: inline-flex;
3119
+ align-items: center;
3120
+ gap: 6px;
3121
+ margin: -3px -7px;
3122
+ padding: 3px 7px;
3123
+ border: none;
3124
+ border-radius: var(--r-inner-sm);
3125
+ background: transparent;
3126
+ font: inherit;
3127
+ color: inherit;
3128
+ text-align: left;
3129
+ cursor: pointer;
3130
+ transition: background var(--motion) ease;
3131
+ }
3132
+
3133
+ .visitor-preview__reveal:hover {
3134
+ background: var(--hover);
3135
+ }
3136
+
3137
+ .visitor-preview__reveal:focus-visible {
3138
+ outline: 2px solid var(--accent);
3139
+ outline-offset: 1px;
3140
+ }
3141
+
3142
+ /* The design's interactive ink - not Vuetify's fixed blue, which is one colour
3143
+ on both themes. `affectedEntities` gives its NRIC eye the same value. */
3144
+ .visitor-preview__eye {
3145
+ color: var(--accent-text);
3146
+ }
3147
+
3148
+ @media (prefers-reduced-motion: reduce) {
3149
+ .visitor-preview__reveal {
3150
+ transition: none;
3151
+ }
3152
+ }
3153
+
2892
3154
  /* The width the type filter carried as `max-width="200"` on the v-select. */
2893
3155
  .visitor-type-filter {
2894
3156
  max-width: 200px;
@@ -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,