@7365admin1/layer-common 4.97.1-staging.518 → 4.97.1-staging.520

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.
@@ -103,10 +103,75 @@
103
103
  />
104
104
  </v-col>
105
105
 
106
+ <!-- Event with RSVP (owner 2026-10-07, 1PAM: "Mooncake Festival - time, RSVP, RSVP closes"). -->
107
+ <v-col cols="12" class="mt-2">
108
+ <v-checkbox
109
+ v-model="eventForm.enabled"
110
+ hide-details
111
+ label="This announcement is an event people can attend"
112
+ data-test="bulletin-event-toggle"
113
+ />
114
+ <p class="text-caption text-medium-emphasis ml-10 mb-2">
115
+ For example a festival, a briefing or a gathering. The date, time and place are shown on the
116
+ announcement in the residents' and service providers' apps.
117
+ </p>
118
+ </v-col>
119
+ <template v-if="eventForm.enabled">
120
+ <v-col cols="12" md="6" class="pr-md-2">
121
+ <InputLabel title="Event starts" required />
122
+ <InputDateTimePicker v-model:utc="eventForm.startAt" :rules="[eventStartRule]" />
123
+ </v-col>
124
+ <v-col cols="12" md="6" class="pl-md-2">
125
+ <InputLabel title="Event ends (optional)" />
126
+ <InputDateTimePicker v-model:utc="eventForm.endAt" :rules="[eventEndRule]" />
127
+ </v-col>
128
+ <v-col cols="12">
129
+ <InputLabel title="Venue (optional)" />
130
+ <v-text-field v-model.trim="eventForm.venue" density="compact" placeholder="e.g. Function Room, Block 2" maxlength="200" />
131
+ </v-col>
132
+ <v-col cols="12">
133
+ <v-checkbox
134
+ v-model="eventForm.rsvp"
135
+ hide-details
136
+ label="Ask residents to RSVP (Going / Not going)"
137
+ data-test="bulletin-rsvp-toggle"
138
+ />
139
+ <p class="text-caption text-medium-emphasis ml-10 mb-2">
140
+ Residents answer in the Service365 app and say how many people are coming. You see every answer, with
141
+ the unit, when you open this announcement.
142
+ </p>
143
+ <p v-if="eventForm.rsvp && !bulletinForm.recipients.includes('resident')" class="text-caption text-warning ml-10 mb-2">
144
+ Add "Resident" to the recipients so residents can see and answer it.
145
+ </p>
146
+ </v-col>
147
+ <template v-if="eventForm.rsvp">
148
+ <v-col cols="12" md="6" class="pr-md-2">
149
+ <InputLabel title="RSVP closes (optional)" />
150
+ <InputDateTimePicker v-model:utc="eventForm.rsvpClosesAt" :rules="[rsvpCloseRule]" />
151
+ <p class="text-caption text-medium-emphasis">Leave empty to take answers until the event starts.</p>
152
+ </v-col>
153
+ <v-col cols="12" md="6" class="pl-md-2">
154
+ <InputLabel title="Places available (optional)" />
155
+ <v-text-field
156
+ v-model.number="eventForm.capacity"
157
+ type="number"
158
+ min="1"
159
+ density="compact"
160
+ :rules="[capacityRule]"
161
+ hint="Total people across all units. Leave empty for no limit."
162
+ persistent-hint
163
+ />
164
+ </v-col>
165
+ </template>
166
+ </template>
167
+
106
168
  <v-col cols="12">
107
169
  <v-col cols="12" class="font-weight-bold text-h6"
108
170
  >Attachments</v-col
109
171
  >
172
+ <v-col cols="12" class="text-caption text-medium-emphasis py-0">
173
+ Photos, videos and documents, up to 25 MB each.
174
+ </v-col>
110
175
  <v-col cols="12">
111
176
  <!-- Was `color="primary-button"` on an OUTLINED button, i.e. a
112
177
  FILL token used as ink - the exact case `utils/theme.ts`
@@ -228,6 +293,42 @@ const bulletinForm = reactive<TCreateAnnouncementPayload>({
228
293
 
229
294
  const emit = defineEmits(["close", "done"]);
230
295
 
296
+ const eventForm = reactive({
297
+ enabled: false,
298
+ startAt: "",
299
+ endAt: "",
300
+ venue: "",
301
+ rsvp: false,
302
+ rsvpClosesAt: "",
303
+ capacity: null as number | null,
304
+ });
305
+
306
+ function eventStartRule(v: string) {
307
+ return !eventForm.enabled || !!v || "Please choose when the event starts";
308
+ }
309
+ function eventEndRule(v: string) {
310
+ return !v || !eventForm.startAt || new Date(v) > new Date(eventForm.startAt) || "The event must end after it starts";
311
+ }
312
+ function rsvpCloseRule(v: string) {
313
+ return !v || !eventForm.startAt || new Date(v) <= new Date(eventForm.startAt) || "RSVP must close before the event starts";
314
+ }
315
+ function capacityRule(v: any) {
316
+ return v === null || v === "" || v === undefined || (Number.isInteger(Number(v)) && Number(v) >= 1) || "Enter a whole number of 1 or more";
317
+ }
318
+
319
+ /** What is sent: no event = `null`, so turning the event off on edit clears it. */
320
+ function eventPayload() {
321
+ if (!eventForm.enabled) return null;
322
+ return {
323
+ startAt: eventForm.startAt,
324
+ endAt: eventForm.endAt || null,
325
+ venue: eventForm.venue || "",
326
+ rsvp: eventForm.rsvp,
327
+ rsvpClosesAt: eventForm.rsvp ? eventForm.rsvpClosesAt || null : null,
328
+ capacity: eventForm.rsvp && eventForm.capacity ? Number(eventForm.capacity) : null,
329
+ };
330
+ }
331
+
231
332
  const validForm = ref(false);
232
333
  const formRef = ref<HTMLFormElement>();
233
334
  const formKey = ref(0);
@@ -289,6 +390,16 @@ watch(
289
390
  bulletinForm.endDate = newData?.endDate;
290
391
  bulletinForm.file = newData?.file;
291
392
  bulletinForm.recipients = newData?.recipients;
393
+ const ev = newData?.event;
394
+ Object.assign(eventForm, {
395
+ enabled: !!ev?.startAt,
396
+ startAt: ev?.startAt ?? "",
397
+ endAt: ev?.endAt ?? "",
398
+ venue: ev?.venue ?? "",
399
+ rsvp: !!ev?.rsvp,
400
+ rsvpClosesAt: ev?.rsvpClosesAt ?? "",
401
+ capacity: ev?.capacity ?? null,
402
+ });
292
403
 
293
404
  // mapped rawFileArray
294
405
 
@@ -393,6 +504,7 @@ async function onSubmit() {
393
504
  const { site, ...rest } = bulletinForm;
394
505
  payload = rest;
395
506
  }
507
+ (payload as any).event = eventPayload();
396
508
 
397
509
  try {
398
510
  loading.processing = true;
@@ -33,6 +33,8 @@
33
33
  </v-col>
34
34
  </template>
35
35
 
36
+ <BulletinEventRsvp :announcement="prop.activeAnnouncement" :can-see-answers="canUpdate" />
37
+
36
38
  <v-col
37
39
  cols="12"
38
40
  v-if="prop.activeAnnouncement?.file?.length > 0"
@@ -0,0 +1,126 @@
1
+ <template>
2
+ <!--
3
+ The event part of an announcement (owner 2026-10-07, 1PAM "Mooncake
4
+ Festival"): when, where, and - for the estate team - who is coming.
5
+ Residents answer in the Service365 app; this only reads the answers.
6
+ -->
7
+ <v-col v-if="event?.startAt" cols="12" class="mb-5" data-test="bulletin-event">
8
+ <v-row no-gutters>
9
+ <v-col class="font-weight-bold">Event:</v-col>
10
+ <v-col cols="9" class="px-10">
11
+ <div>{{ when }}</div>
12
+ <div v-if="event.venue" class="text-medium-emphasis">{{ event.venue }}</div>
13
+
14
+ <template v-if="event.rsvp">
15
+ <div class="text-caption text-medium-emphasis mt-1">
16
+ RSVP {{ closed ? "closed" : "open" }} {{ closed ? "on" : "until" }} {{ fmt(event.rsvpClosesAt || event.startAt) }}{{
17
+ event.capacity ? ` · ${event.capacity} places` : " · no limit on places"
18
+ }}
19
+ </div>
20
+
21
+ <template v-if="canSeeAnswers">
22
+ <v-alert v-if="error" type="error" variant="tonal" density="compact" class="mt-3">{{ error }}</v-alert>
23
+ <div v-else-if="loading" class="text-caption mt-3">Loading answers...</div>
24
+ <template v-else-if="summary">
25
+ <div class="d-flex flex-wrap ga-2 mt-3" data-test="bulletin-rsvp-summary">
26
+ <v-chip size="small" color="success" variant="tonal">
27
+ Going: {{ summary.goingPeople }} {{ summary.goingPeople === 1 ? "person" : "people" }} ({{ summary.goingHouseholds }}
28
+ {{ summary.goingHouseholds === 1 ? "unit" : "units" }})
29
+ </v-chip>
30
+ <v-chip size="small" variant="tonal">Not going: {{ summary.notGoing }}</v-chip>
31
+ <v-chip v-if="summary.capacity" size="small" variant="tonal">
32
+ Places left: {{ Math.max(summary.capacity - summary.goingPeople, 0) }}
33
+ </v-chip>
34
+ <v-btn
35
+ v-if="items.length"
36
+ size="small"
37
+ variant="outlined"
38
+ class="text-none screen-btn-ghost"
39
+ prepend-icon="mdi-download"
40
+ data-test="bulletin-rsvp-export"
41
+ @click="exportCsv"
42
+ >
43
+ Download list (CSV)
44
+ </v-btn>
45
+ </div>
46
+ <p v-if="!items.length" class="text-caption text-medium-emphasis mt-2">
47
+ No answers yet. Residents answer in the Service365 app.
48
+ </p>
49
+ <v-table v-else density="compact" class="mt-2 border rounded">
50
+ <thead>
51
+ <tr><th>Unit</th><th>Name</th><th>Answer</th><th>People</th><th>Answered</th></tr>
52
+ </thead>
53
+ <tbody>
54
+ <tr v-for="r in items" :key="r._id">
55
+ <td>{{ r.unit || "-" }}</td>
56
+ <td>{{ r.name || r.email || "-" }}</td>
57
+ <td>{{ r.response === "going" ? "Going" : "Not going" }}</td>
58
+ <td>{{ r.response === "going" ? r.attendees : "-" }}</td>
59
+ <td>{{ fmt(r.updatedAt) }}</td>
60
+ </tr>
61
+ </tbody>
62
+ </v-table>
63
+ </template>
64
+ </template>
65
+ </template>
66
+ </v-col>
67
+ </v-row>
68
+ </v-col>
69
+ </template>
70
+
71
+ <script setup lang="ts">
72
+ const props = defineProps({
73
+ announcement: { type: Object as PropType<Record<string, any> | null>, default: null },
74
+ /** The estate team (bulletin edit right) sees who answered. */
75
+ canSeeAnswers: { type: Boolean, default: false },
76
+ });
77
+
78
+ const event = computed(() => props.announcement?.event ?? null);
79
+ const items = ref<Record<string, any>[]>([]);
80
+ const summary = ref<Record<string, any> | null>(null);
81
+ const loading = ref(false);
82
+ const error = ref("");
83
+
84
+ const fmt = (v: any) =>
85
+ v ? new Date(v).toLocaleString(undefined, { day: "numeric", month: "short", year: "numeric", hour: "numeric", minute: "2-digit" }) : "";
86
+ const when = computed(() => {
87
+ const e = event.value;
88
+ if (!e?.startAt) return "";
89
+ return e.endAt ? `${fmt(e.startAt)} - ${fmt(e.endAt)}` : fmt(e.startAt);
90
+ });
91
+ const closed = computed(() => {
92
+ const at = event.value?.rsvpClosesAt || event.value?.startAt;
93
+ return !!at && new Date(at) < new Date();
94
+ });
95
+
96
+ async function load() {
97
+ items.value = [];
98
+ summary.value = null;
99
+ error.value = "";
100
+ if (!event.value?.rsvp || !props.canSeeAnswers || !props.announcement?._id) return;
101
+ loading.value = true;
102
+ try {
103
+ const res: any = await useNuxtApp().$api(`/api/bulletin-boards/id/${props.announcement._id}/rsvps`);
104
+ items.value = res?.items ?? [];
105
+ summary.value = res?.summary ?? null;
106
+ } catch (e: any) {
107
+ error.value = e?.data?.message || "The answers could not be loaded. Please try again.";
108
+ } finally {
109
+ loading.value = false;
110
+ }
111
+ }
112
+ watch(() => [props.announcement?._id, props.canSeeAnswers], load, { immediate: true });
113
+
114
+ function exportCsv() {
115
+ const q = (v: any) => `"${String(v ?? "").replace(/"/g, '""')}"`;
116
+ const rows = [["Unit", "Name", "Email", "Answer", "People", "Answered"]].concat(
117
+ items.value.map((r) => [r.unit, r.name, r.email, r.response === "going" ? "Going" : "Not going", r.response === "going" ? r.attendees : 0, fmt(r.updatedAt)]),
118
+ );
119
+ const blob = new Blob([rows.map((r) => r.map(q).join(",")).join("\n")], { type: "text/csv" });
120
+ const a = document.createElement("a");
121
+ a.href = URL.createObjectURL(blob);
122
+ a.download = `rsvp-${String(props.announcement?.title || "event").replace(/[^A-Za-z0-9]+/g, "-")}.csv`;
123
+ a.click();
124
+ setTimeout(() => URL.revokeObjectURL(a.href), 5000);
125
+ }
126
+ </script>
@@ -63,6 +63,10 @@
63
63
  </v-col>
64
64
  <v-col cols="12" lg="6" class="mt-2 pl-lg-2">
65
65
  <InputLabel title="Site Documents" class="d-block mb-1" />
66
+ <p class="text-caption text-medium-emphasis mb-2">
67
+ Every resident of this site can open these in the Service365 app (About this site) - for example
68
+ by-laws, house rules or the site plan. Documents for one unit only go on that unit instead.
69
+ </p>
66
70
  <InputFileV2 v-model="siteDocuments" :multiple="true" accept="*/*" title="Upload documents"
67
71
  :height="104" />
68
72
  </v-col>
@@ -6,7 +6,10 @@
6
6
  heading. Same handler, same permission gate.
7
7
  -->
8
8
  <v-col cols="12">
9
- <PageHeader title="Vehicle Mgmt">
9
+ <PageHeader
10
+ title="Vehicle Mgmt"
11
+ subtitle="The register of residents' and visitors' vehicles. Works with or without number-plate (LPR) cameras - cameras only add automatic plate matching at the gate."
12
+ >
10
13
  <template #actions>
11
14
  <AppButton v-if="qrStickersOn" icon="mdi-qrcode" variant="ghost" @click="openStickerDialog()">
12
15
  Print QR stickers
@@ -280,6 +280,16 @@ export function useCommonPermissions() {
280
280
  check: true,
281
281
  description: "Allows the user to manage work order settings.",
282
282
  },
283
+ // Security Ops site visits. The boundary is one half; the guardhouse
284
+ // code an Ops Executive scans to open a visit is the other, and it is the
285
+ // proof the whole module rests on - so this is the right that decides who
286
+ // may re-register it. In the COMMON catalogue because site settings are
287
+ // shared across verticals, not only security.
288
+ "manage-geofence": {
289
+ check: true,
290
+ description:
291
+ "Allows the user to set a site's boundary and register the guardhouse check-in code used for Security Ops site visits.",
292
+ },
283
293
  "manage-billing-and-soa-configuration": {
284
294
  check: true,
285
295
  description:
@@ -735,6 +735,38 @@ export default function useSecurityPermission() {
735
735
  description: "Allows the user to delete routes.",
736
736
  },
737
737
  },
738
+ /**
739
+ * NEW. Security Ops - the site visit and its checklists.
740
+ *
741
+ * NO ROLE HOLDS THESE YET. The module is new, so every one of these strings
742
+ * has a count of zero today. API-core's `siteVisit` gate is therefore
743
+ * COUNTED, not enforcing (`SITE_VISIT_PERMISSION_MODE`, default `log`): it
744
+ * records who WOULD be refused and refuses nobody, the same way the NFC
745
+ * patrol and incident report gates shipped. Provision roles against that
746
+ * count before anyone sets it to `enforce`.
747
+ *
748
+ * THREE PLACES, BY HAND. These spellings have to match API-core
749
+ * (`SITE_VISIT_PERMISSIONS` in `site-authz.util.ts`) and the RN app
750
+ * (`permission.catalog.ts`), which does NOT import this file - it keeps a
751
+ * literal copy and compares strings exactly. `roles-picker-covers-mobile-gates`
752
+ * in web-app-security is the test that holds the three together.
753
+ *
754
+ * The geofence right is NOT here: it is a site setting, so it lives in
755
+ * `useCommonPermission.ts` as `site-settings:manage-geofence` beside the
756
+ * other panels.
757
+ */
758
+ "security-ops": {
759
+ "start-site-visit": {
760
+ check: true,
761
+ description:
762
+ "Allows the user to check in at a site, fill in the visit checklists and check out.",
763
+ },
764
+ "see-all-site-visits": {
765
+ check: true,
766
+ description:
767
+ "Allows the user to view site visits across the sites they can reach, including other executives' visits.",
768
+ },
769
+ },
738
770
  // NEW. Seeing the CCTV wall, as distinct from setting cameras up
739
771
  // (`site-settings:manage-cctv-camera`).
740
772
  "cctv-mgmt": {
@@ -768,6 +800,12 @@ export default function useSecurityPermission() {
768
800
  "manage-nfc-management": siteSettingsPermissions["manage-nfc-management"],
769
801
  "manage-nfc-patrol-settings":
770
802
  siteSettingsPermissions["manage-nfc-patrol-settings"],
803
+ // Security Ops geofencing. This block CHERRY-PICKS from
804
+ // `siteSettingsPermissions` rather than spreading it, so a new entry in
805
+ // the common catalogue does not reach the security role editor on its own
806
+ // - without this line no administrator on a security site could grant the
807
+ // right, and the Geofencing panel would be invisible to everyone.
808
+ "manage-geofence": siteSettingsPermissions["manage-geofence"],
771
809
  "manage-red-dot-settings": {
772
810
  check: true,
773
811
  description:
@@ -129,6 +129,20 @@ export function useSettingsPermission() {
129
129
  "update-vehicle": { check: true, description: "Allows the user to update vehicle details." },
130
130
  },
131
131
  };
132
+ /**
133
+ * The Geofencing panel - Security Ops site visits.
134
+ *
135
+ * MUST ALSO BE IN `canManageSiteSettings` BELOW. That computed is an OR of
136
+ * every panel gate and it is what decides whether the Settings page renders at
137
+ * all, so a role holding ONLY this right would otherwise be given a page it
138
+ * cannot open. Adding a panel is always two lines, never one.
139
+ */
140
+ const canManageGeofence = computed(() => {
141
+ if (!userAppRole.value) return false;
142
+ if (userAppRole.value.permissions.includes("*")) return true;
143
+ return hasPermission(userAppRole.value, permissions, "site-settings", "manage-geofence");
144
+ });
145
+
132
146
  const canManageVehicleQr = computed(() => {
133
147
  if (!userAppRole.value) return false;
134
148
  if (userAppRole.value.permissions.includes("*")) return true;
@@ -136,7 +150,7 @@ export function useSettingsPermission() {
136
150
  });
137
151
 
138
152
  const canManageSiteSettings = computed(() => {
139
- return canManageSiteInformation.value || canManageANPRCamera.value || canManageCCTVCamera.value || canManageDeliveryCompanies.value || canManageResidentVisitors.value || canManageWorkOrderSettings.value || canManageBillingAndSOAConfiguration.value || canManageNFCManagement.value || canManageNFCPatrolSettings.value || canManageEntryPass.value || canManageRedDotSettings.value
153
+ return canManageSiteInformation.value || canManageANPRCamera.value || canManageCCTVCamera.value || canManageDeliveryCompanies.value || canManageResidentVisitors.value || canManageWorkOrderSettings.value || canManageBillingAndSOAConfiguration.value || canManageNFCManagement.value || canManageNFCPatrolSettings.value || canManageEntryPass.value || canManageRedDotSettings.value || canManageGeofence.value
140
154
  })
141
155
 
142
156
  return {
@@ -151,6 +165,7 @@ export function useSettingsPermission() {
151
165
  canManageNFCPatrolSettings,
152
166
  canManageEntryPass,
153
167
  canManageRedDotSettings,
168
+ canManageGeofence,
154
169
  canManageVehicleQr,
155
170
  canManageSiteSettings
156
171
 
@@ -150,6 +150,9 @@ export const PERMISSIONS = {
150
150
  "manage-nfc-patrol-settings",
151
151
  "manage-entry-pass",
152
152
  "manage-red-dot-settings",
153
+ // Security Ops: the site boundary and the guardhouse check-in code. The
154
+ // server reads this one too - API-core `GEOFENCE_MANAGE_PERMISSIONS`.
155
+ "manage-geofence",
153
156
  ],
154
157
 
155
158
  // ---- module apps (cleaning, landscape, M&E, pest, pool) ----
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.518",
5
+ "version": "4.97.1-staging.520",
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.",
@@ -12,6 +12,16 @@ declare interface TAnnouncement {
12
12
  startDate: string;
13
13
  endDate: string;
14
14
  status: TAnnouncementStatus
15
+ event?: TAnnouncementEvent | null;
16
+ }
17
+
18
+ declare interface TAnnouncementEvent {
19
+ startAt: string;
20
+ endAt?: string | null;
21
+ venue?: string;
22
+ rsvp?: boolean;
23
+ rsvpClosesAt?: string | null;
24
+ capacity?: number | null;
15
25
  }
16
26
 
17
27
  declare interface TAnnouncementFile {
@@ -24,6 +34,6 @@ declare type TAnnouncementRecipients = "resident" | "security_agency" | "cleanin
24
34
 
25
35
 
26
36
 
27
- declare type TCreateAnnouncementPayload = Pick<TAnnouncement, "recipients" | "file" | "site" | "noExpiration" | "startDate" | "endDate" | "content" | "title">
37
+ declare type TCreateAnnouncementPayload = Pick<TAnnouncement, "recipients" | "file" | "site" | "noExpiration" | "startDate" | "endDate" | "content" | "title"> & { event?: TAnnouncementEvent | null }
28
38
 
29
39
  declare type TAnnouncementStatus = "active" | "expired"