@7365admin1/layer-common 4.97.1-staging.542 → 4.97.1-staging.544

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.
@@ -34,6 +34,33 @@
34
34
  <p v-if="!choices.length" class="text-body-2">This organisation has no sites yet.</p>
35
35
 
36
36
  <div v-else>
37
+ <!--
38
+ WHO GOES OUT TO THE SITES. One switch for the whole person, not one
39
+ per row: an officer is an officer everywhere they are sent, and the
40
+ server writes the same value onto every site ticked below.
41
+
42
+ It grants NOTHING. What a member may do is still their role, which
43
+ is why this sits apart from the Role column rather than inside it.
44
+ -->
45
+ <v-switch
46
+ v-model="securityOps"
47
+ color="primary"
48
+ density="compact"
49
+ hide-details
50
+ inset
51
+ class="mb-2"
52
+ data-test="site-access-security-ops"
53
+ >
54
+ <template #label>
55
+ <div>
56
+ <div class="text-body-2">This person is part of Security Ops</div>
57
+ <div class="text-caption text-medium-emphasis">
58
+ They visit the sites ticked below and fill in the checklists.
59
+ </div>
60
+ </div>
61
+ </template>
62
+ </v-switch>
63
+
37
64
  <div class="d-flex align-center ga-2 mb-2">
38
65
  <v-select
39
66
  v-model="sameRole"
@@ -53,6 +80,7 @@
53
80
 
54
81
  <div v-for="(c, i) in choices" :key="c.site" class="d-flex align-center ga-2 py-1" data-test="site-access-row">
55
82
  <v-checkbox v-model="choices[i].on" density="compact" hide-details :label="c.name" style="min-width: 220px" />
83
+ <v-chip v-if="securityOps && choices[i].on" size="x-small" color="primary" variant="tonal">Security Ops</v-chip>
56
84
  <v-select
57
85
  v-if="c.roles.length"
58
86
  v-model="choices[i].role"
@@ -72,6 +100,10 @@
72
100
  </p>
73
101
  </div>
74
102
 
103
+ <p v-if="choices.length" class="text-caption mt-2" data-test="site-access-security-ops-note">
104
+ {{ securityOpsNote }}
105
+ </p>
106
+
75
107
  <p v-if="missing.length" class="text-error text-caption mt-2">Choose a role for: {{ missing.join(", ") }}</p>
76
108
  <p v-if="saveError" class="text-error mt-2">{{ saveError }}</p>
77
109
  </template>
@@ -87,7 +119,7 @@
87
119
 
88
120
  <script setup lang="ts">
89
121
  // Relative import: this layer's `utils/` is not auto-imported into consumers.
90
- import { applySameRole, initialChoices, roleItems, sharedRoleItems, toPayload, type SiteChoice } from "../utils/site-access";
122
+ import { applySameRole, initialChoices, initialSecurityOps, roleItems, sharedRoleItems, toPayload, type SiteChoice } from "../utils/site-access";
91
123
 
92
124
  const props = defineProps({
93
125
  org: { type: String, required: true },
@@ -106,6 +138,7 @@ const choices = ref<SiteChoice[]>([]);
106
138
  const orgWide = ref<Array<{ roleName?: string }>>([]);
107
139
  const removeOrgAccess = ref(false);
108
140
  const sameRole = ref<string | null>(null);
141
+ const securityOps = ref(false);
109
142
 
110
143
  const sharedItems = computed(() => sharedRoleItems(choices.value));
111
144
  const anyOn = computed(() => choices.value.some((c) => c.on));
@@ -119,6 +152,15 @@ function createOrgRole() {
119
152
  }
120
153
  const missing = computed(() => toPayload(choices.value).missing);
121
154
 
155
+ /** Say back what the switch and the ticks add up to, in the order they read. */
156
+ const securityOpsNote = computed(() => {
157
+ if (!securityOps.value) return "Not part of Security Ops.";
158
+ const names = choices.value.filter((c) => c.on).map((c) => c.name);
159
+ if (!names.length) return "Part of Security Ops, but no site is ticked yet.";
160
+ if (names.length === 1) return `Part of Security Ops at ${names[0]}.`;
161
+ return `Part of Security Ops at ${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}.`;
162
+ });
163
+
122
164
  function applySame() {
123
165
  if (sameRole.value) choices.value = applySameRole(choices.value, sameRole.value);
124
166
  }
@@ -130,6 +172,7 @@ async function load() {
130
172
  const res = await getSiteAccess(props.org, props.user);
131
173
  choices.value = initialChoices(res?.sites ?? []);
132
174
  orgWide.value = res?.orgWide ?? [];
175
+ securityOps.value = initialSecurityOps(res?.sites ?? []);
133
176
  } catch (e: any) {
134
177
  loadError.value = e?.data?.message || "Site access could not be loaded. Only the organisation's owner or an admin can change it.";
135
178
  }
@@ -141,7 +184,13 @@ async function save() {
141
184
  saveError.value = "";
142
185
  try {
143
186
  const { sites } = toPayload(choices.value);
144
- await saveSiteAccess({ org: props.org, user: props.user, sites, removeOrgAccess: removeOrgAccess.value });
187
+ await saveSiteAccess({
188
+ org: props.org,
189
+ user: props.user,
190
+ sites,
191
+ securityOps: securityOps.value,
192
+ removeOrgAccess: removeOrgAccess.value,
193
+ });
145
194
  emit("saved", sites.length ? `Site access saved: ${sites.length} site(s).` : "Site access saved: no sites.");
146
195
  } catch (e: any) {
147
196
  saveError.value = e?.data?.message || "Site access could not be saved.";
@@ -201,6 +201,12 @@ export default function useMember() {
201
201
  org: string;
202
202
  user: string;
203
203
  sites: Array<{ site: string; role: string }>;
204
+ /**
205
+ * Is this person one of the Security Ops officers who visits sites? One
206
+ * value for the whole person, written onto every site they end up with.
207
+ * Omit it and the server leaves the mark exactly as it is.
208
+ */
209
+ securityOps?: boolean;
204
210
  removeOrgAccess?: boolean;
205
211
  }) {
206
212
  return useNuxtApp().$api<Record<string, any>>("/api/members/site-access", {
@@ -342,6 +342,18 @@ export const PERMISSIONS = {
342
342
  // Owner answer Q10, 2026-09-11. Mirrors `start-virtual-patrol-route`.
343
343
  "start-nfc-patrol",
344
344
  ],
345
+ // Security Ops. Both strings are enforced by the server (API-core
346
+ // `SITE_VISIT_PERMISSIONS`) and read by the security mobile app's own
347
+ // catalogue, so the spelling is maintained by hand in three places and this
348
+ // is the one that makes a typo visible.
349
+ //
350
+ // `see-all-site-visits` also decides who is told about an action: a head of
351
+ // security holds it together with `site-settings:manage-geofence`. A wildcard
352
+ // deliberately does NOT qualify for that, because a wildcard says somebody
353
+ // administers this site, not that they run security at it - measured
354
+ // 2026-10-13, every wildcard holder at a live site was an org owner, a test
355
+ // account or a service provider's administrator.
356
+ "security-ops": ["start-site-visit", "see-all-site-visits"],
345
357
  // Owner answer Q9, 2026-09-11: seeing the CCTV wall. Distinct from
346
358
  // `site-settings:manage-cctv-camera`, which is camera setup.
347
359
  "cctv-mgmt": ["see-all-cctv", "view-recordings"],
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.542",
5
+ "version": "4.97.1-staging.544",
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.",
@@ -56,8 +56,50 @@ export const INVENTORY_PRESETS: TPermissionPreset[] = [
56
56
  },
57
57
  ];
58
58
 
59
- /** Presets per module key; only inventory has them today. */
60
- export const PERMISSION_PRESETS: Record<string, TPermissionPreset[]> = { inventory: INVENTORY_PRESETS };
59
+ /**
60
+ * Security Ops in plain words: the two jobs the module actually has.
61
+ *
62
+ * WHY A PRESET AND NOT A NEW PERMISSION. Neither of these is a new right: both
63
+ * sets are made of strings that already exist. The preset only spares somebody
64
+ * hunting a permission tree, and that matters here because the alternative
65
+ * people reach for is a wildcard role, which is how a service provider's
66
+ * administrator ends up supervising a security site.
67
+ *
68
+ * GEOFENCING IS NOT IN EITHER SET, and cannot be: `applyPermissionPreset` is
69
+ * scoped to one resource, and `manage-geofence` belongs to `site-settings`.
70
+ * That matters because the owner's definition of a head of security
71
+ * (2026-10-13) is this permission AND geofencing, and the server reads exactly
72
+ * that pair to decide who is told when an action is raised or sent for
73
+ * verification. So the preset's description has to send the administrator to
74
+ * tick the other box, rather than quietly leaving the job half done.
75
+ *
76
+ * `start-site-visit` is deliberately NOT in the head of security set: it is the
77
+ * right to go and do a visit, and somebody who never walks a site should not
78
+ * have to hold it to be told what is happening on one. Holding it as well does
79
+ * not disqualify them.
80
+ */
81
+ export const SECURITY_OPS_PRESETS: TPermissionPreset[] = [
82
+ {
83
+ key: "officer",
84
+ label: "Security Ops officer",
85
+ description:
86
+ "Goes to the site, works through the visit checklists and checks out. Sees their own work.",
87
+ actions: ["start-site-visit"],
88
+ },
89
+ {
90
+ key: "head",
91
+ label: "Head of security",
92
+ description:
93
+ "Sees every officer's visits and actions. Also tick Manage geofencing under Site settings: that pair is what decides who is told when an action is raised or sent for verification.",
94
+ actions: ["see-all-site-visits"],
95
+ },
96
+ ];
97
+
98
+ /** Presets per module key. */
99
+ export const PERMISSION_PRESETS: Record<string, TPermissionPreset[]> = {
100
+ inventory: INVENTORY_PRESETS,
101
+ "security-ops": SECURITY_OPS_PRESETS,
102
+ };
61
103
 
62
104
  /**
63
105
  * The permission list with `resource`'s grants replaced by `preset`'s actions --
@@ -204,6 +204,16 @@ const SITE_PAGES: Record<string, TSitePage[]> = {
204
204
  robotAlert: [{ apps: ["security", "property-management", "hygiene"], page: () => "robot-management/alerts" }],
205
205
  // hygiene has its Service Providers page too since 2026-09-28
206
206
  serviceProviderInviteAnswer: [{ apps: SERVICE_APPS, page: () => "service-providers" }],
207
+ /**
208
+ * Security Ops: an action was raised, sent for verification, signed off,
209
+ * reopened, or went overdue. Lands on the Ops Review page, which is where the
210
+ * register is read.
211
+ *
212
+ * WITHOUT THIS ENTRY THE ROW IS A DEAD END. `notificationTarget` answers null
213
+ * for a kind it has no page for, so every overdue escalation ever written has
214
+ * opened nothing at all. Adding it repairs those too, not only the new alerts.
215
+ */
216
+ "security-ops": [{ apps: ["security"], page: () => "security-ops" }],
207
217
  };
208
218
  SITE_PAGES.myVisitors = SITE_PAGES.visitors;
209
219
 
@@ -8,7 +8,7 @@ export type SiteAccessRole = { _id: string; name: string; type?: string; scope?:
8
8
  export type SiteAccessRow = {
9
9
  site: string;
10
10
  name: string;
11
- membership: { role: string; roleName?: string } | null;
11
+ membership: { role: string; roleName?: string; securityOps?: boolean } | null;
12
12
  roles: SiteAccessRole[];
13
13
  };
14
14
  export type SiteChoice = { site: string; name: string; on: boolean; role: string; roles: SiteAccessRole[]; replacedRole?: string };
@@ -31,6 +31,18 @@ export function initialChoices(rows: SiteAccessRow[]): SiteChoice[] {
31
31
  });
32
32
  }
33
33
 
34
+ /**
35
+ * Is this person already marked as Security Ops?
36
+ *
37
+ * ONE ANSWER FOR THE WHOLE PERSON, because that is the question the switch
38
+ * asks: an officer is an officer everywhere they are sent. Any marked site
39
+ * means yes, so a person whose rows disagree (only reachable by an older client
40
+ * or a hand edit) reads as marked, and saving settles every row to one value.
41
+ */
42
+ export function initialSecurityOps(rows: SiteAccessRow[]): boolean {
43
+ return (rows ?? []).some((r) => Boolean(r.membership?.securityOps));
44
+ }
45
+
34
46
  /** One site's Role list: "Organisation roles" first, then "<Site> roles". */
35
47
  export function roleItems(choice: Pick<SiteChoice, "name" | "roles">): RoleItem[] {
36
48
  const org = choice.roles.filter(isOrgRole);