@7365admin1/layer-common 4.97.1-staging.517 → 4.97.1-staging.519

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.
Files changed (28) hide show
  1. package/CHANGELOG.md +4 -4
  2. package/assets/css/screens.css +11 -0
  3. package/components/Nfc/NFCPatrolReportMain.vue +61 -72
  4. package/components/Nfc/NFCPatrolRouteMain.vue +21 -31
  5. package/components/Nfc/NFCRouteScheduleTimes.vue +83 -0
  6. package/components/Nfc/PatrolReport/DailyReportTab.vue +24 -3
  7. package/components/Nfc/PatrolReport/MonthlyReportTab.vue +32 -3
  8. package/components/Nfc/PatrolReport/MonthlyReportTable.vue +29 -1
  9. package/components/Nfc/PatrolReport/PatrolActivityTable.vue +24 -2
  10. package/components/Nfc/PatrolReport/PatrolMonthDialog.vue +195 -0
  11. package/components/Nfc/PatrolReport/PatrolReportTab.vue +11 -2
  12. package/components/Nfc/PatrolReport/PatrolRouteDetailsDialog.vue +214 -0
  13. package/components/Nfc/PatrolReport/ReportLocationHeader.vue +4 -1
  14. package/components/Nfc/PatrolReport/SkipPhotoDetails.vue +137 -0
  15. package/components/Nfc/PatrolReport/SkipPhotoThumb.vue +132 -0
  16. package/components/Nfc/PatrolReport/SummaryReportTable.vue +42 -1
  17. package/composables/useCommonPermission.ts +10 -0
  18. package/composables/useNFCPatrolDailyReport.ts +4 -18
  19. package/composables/useNFCPatrolMonthlyReport.ts +34 -5
  20. package/composables/useReportPdf.ts +220 -0
  21. package/composables/useSecurityPermission.ts +38 -0
  22. package/composables/useSettingsPermission.ts +16 -1
  23. package/constants/permissions.ts +3 -0
  24. package/package.json +1 -1
  25. package/types/nfc-patrol-report.ts +14 -0
  26. package/utils/nfc-patrol-report.ts +239 -1
  27. package/utils/nfc-patrol-schedule.ts +73 -0
  28. package/utils/report-export.ts +120 -0
package/CHANGELOG.md CHANGED
@@ -2082,11 +2082,11 @@
2082
2082
  `utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
2083
2083
  own rule from two endpoints the console already calls, unprojected:
2084
2084
 
2085
- GET /api/members/user/:user/app/admin the Seven365 staff membership
2086
- GET /api/roles/id/:role that membership's role document
2085
+ GET /api/members/user/:user/app/admin the Seven365 staff membership
2086
+ GET /api/roles/id/:role that membership's role document
2087
2087
 
2088
- owner = member.type === "admin" && role.type === "admin" && role.default === true
2089
- staff = member.type === "admin" && role.type === "admin"
2088
+ owner = member.type === "admin" && role.type === "admin" && role.default === true
2089
+ staff = member.type === "admin" && role.type === "admin"
2090
2090
 
2091
2091
  `role.default` is the marker because it is the only property of a platform
2092
2092
  staff role no API caller can set - `role.controller.ts` validates create and
@@ -1246,3 +1246,14 @@
1246
1246
  letter-spacing: 0;
1247
1247
  color: var(--muted);
1248
1248
  }
1249
+
1250
+ /**
1251
+ * Report PDF only. A report's PDF is drawn from a copy of its `.report-export`
1252
+ * area (`useReportPdf`), which shows `data-pdf-only` and drops `data-pdf-hide`.
1253
+ * On screen the first never shows - e.g. the skip photos under each skipped
1254
+ * checkpoint, which the tables already carry as thumbnails. Scoped to a
1255
+ * report's export area, so the attribute means nothing anywhere else.
1256
+ */
1257
+ .report-export [data-pdf-only] {
1258
+ display: none !important;
1259
+ }
@@ -86,15 +86,20 @@
86
86
  </template>
87
87
 
88
88
  <script setup lang="ts">
89
- import html2canvas from "html2canvas";
90
- import jsPDF from "jspdf";
91
-
92
89
  import type {
93
90
  NFCPatrolReportFilters,
94
91
  NFCPatrolReportTab,
95
92
  } from "../../types/nfc-patrol-report";
96
93
 
97
94
  import { useNFCPatrolReportFilters } from "../../composables/useNFCPatrolReportFilters";
95
+ import useReportPdf, { type ReportPdfMeta } from "../../composables/useReportPdf";
96
+ import {
97
+ buildReportCsv,
98
+ formatGeneratedAt,
99
+ formatReportDate,
100
+ reportFileName,
101
+ type CsvSection,
102
+ } from "../../utils/report-export";
98
103
 
99
104
  import PatrolReportTab from "./PatrolReport/PatrolReportTab.vue";
100
105
  import DailyReportTab from "./PatrolReport/DailyReportTab.vue";
@@ -134,7 +139,42 @@ function updateFilters(value: NFCPatrolReportFilters) {
134
139
  filters.date = value.date;
135
140
  }
136
141
 
137
- async function exportReport(type: "pdf" | "csv") {
142
+ const { exportReportPdf } = useReportPdf();
143
+
144
+ /** An export's heading and file name: which report, where, and for what. */
145
+ function reportMeta(report: HTMLElement, extension: "pdf" | "csv"): ReportPdfMeta {
146
+ const tab = reportTabs.find(({ value }) => value === activeTab.value);
147
+ const route = options.value.routes.find(({ value }) => value === filters.route)?.title;
148
+ const text = (selector: string) => report.querySelector(selector)?.textContent?.trim() || undefined;
149
+
150
+ // The yearly table always covers the current year (useNFCPatrolMonthlyReport).
151
+ const period =
152
+ activeTab.value === "monthly"
153
+ ? { label: "Year", value: String(new Date().getFullYear()) }
154
+ : { label: "Date", value: formatReportDate(filters.date) };
155
+ const details = [{ label: "Route", value: route ?? "-" }, period];
156
+ if (activeTab.value === "patrol" && filters.timeRange) {
157
+ details.push({ label: "Time", value: filters.timeRange });
158
+ }
159
+
160
+ return {
161
+ title: tab?.label ?? "Patrol Report",
162
+ site: text(".location-header__name"),
163
+ address: text(".location-header__address"),
164
+ details,
165
+ fileName: reportFileName(
166
+ [
167
+ tab?.label,
168
+ route,
169
+ activeTab.value === "monthly" ? period.value : filters.date,
170
+ activeTab.value === "patrol" ? filters.timeRange.split(" - ")[0]?.replace(":", "") : undefined,
171
+ ],
172
+ extension,
173
+ ),
174
+ };
175
+ }
176
+
177
+ async function exportReport(type: "pdf" | "csv", sections: CsvSection[] = []) {
138
178
  const report = document.querySelector(
139
179
  ".report-export",
140
180
  ) as HTMLElement | null;
@@ -142,82 +182,31 @@ async function exportReport(type: "pdf" | "csv") {
142
182
  if (!report) return;
143
183
 
144
184
  if (type === "pdf") {
145
- const canvas = await html2canvas(report, {
146
- scale: 2,
147
- useCORS: true,
148
- backgroundColor: "#fff",
149
- });
150
-
151
- const pdf = new jsPDF("p", "mm", "a4");
152
-
153
- const pdfWidth = pdf.internal.pageSize.getWidth();
154
- const pdfHeight = pdf.internal.pageSize.getHeight();
155
-
156
- const imgWidth = pdfWidth;
157
- const imgHeight = (canvas.height * imgWidth) / canvas.width;
158
-
159
- const imgData = canvas.toDataURL("image/png");
160
-
161
- let heightLeft = imgHeight;
162
- let position = 0;
163
-
164
- pdf.addImage(imgData, "PNG", 0, position, imgWidth, imgHeight);
165
-
166
- heightLeft -= pdfHeight;
167
-
168
- while (heightLeft > 0) {
169
- position -= pdfHeight;
170
-
171
- pdf.addPage();
172
- pdf.addImage(imgData, "PNG", 0, position, imgWidth, imgHeight);
173
-
174
- heightLeft -= pdfHeight;
175
- }
176
-
177
- pdf.save(`${activeTab.value}-report.pdf`);
185
+ await exportReportPdf(report, reportMeta(report, "pdf"));
178
186
  return;
179
187
  }
180
188
 
181
- const table = report.querySelector("table");
182
-
183
- if (!table) return;
184
-
185
- const csv = Array.from(table.querySelectorAll("tr"))
186
- .map((row) =>
187
- Array.from(row.querySelectorAll("th,td"))
188
- .map((cell) => escapeCsvCell(getCsvCellValue(cell)))
189
- .join(","),
190
- )
191
- .join("\n");
192
-
193
- const blob = new Blob([csv], {
194
- type: "text/csv;charset=utf-8;",
189
+ // Built from the report's data by its tab, not read off the screen: every
190
+ // table, with each skip's remarks and photo link on its checkpoint's row.
191
+ if (!sections.length) return;
192
+
193
+ const meta = reportMeta(report, "csv");
194
+ const csv = buildReportCsv({
195
+ title: meta.title,
196
+ details: [
197
+ { label: "Site", value: meta.site },
198
+ { label: "Address", value: meta.address },
199
+ ...meta.details,
200
+ { label: "Generated", value: formatGeneratedAt() },
201
+ ],
202
+ sections,
195
203
  });
196
204
 
197
205
  const link = document.createElement("a");
198
-
199
- link.href = URL.createObjectURL(blob);
200
- link.download = `${activeTab.value}-report.csv`;
206
+ link.href = URL.createObjectURL(new Blob([csv], { type: "text/csv;charset=utf-8;" }));
207
+ link.download = meta.fileName;
201
208
  link.click();
202
209
 
203
210
  URL.revokeObjectURL(link.href);
204
211
  }
205
-
206
- function getCsvCellValue(cell: Element) {
207
- const image = cell.querySelector("img");
208
-
209
- if (image) {
210
- const imageUrl = image.currentSrc || image.src;
211
-
212
- if (imageUrl) {
213
- return imageUrl;
214
- }
215
- }
216
-
217
- return cell.textContent?.trim() ?? "";
218
- }
219
-
220
- function escapeCsvCell(value: string) {
221
- return `"${value.replace(/"/g, '""')}"`;
222
- }
223
212
  </script>
@@ -54,11 +54,10 @@
54
54
  </div>
55
55
  </template>
56
56
 
57
+ <!-- Earliest first, one unbreakable pill per window; past three the
58
+ rest fold into "+N more" so a busy route keeps a normal row. -->
57
59
  <template #item.schedules="{ value }">
58
- <span v-if="Array.isArray(value) && value.length > 0">
59
- {{ value.map((s: any) => `${s.start}-${s.end}`).join(", ") }}
60
- </span>
61
- <span v-else>--</span>
60
+ <NFCRouteScheduleTimes :windows="value || []" :limit="3" />
62
61
  </template>
63
62
 
64
63
  <template #item.repeatDays="{ value }">
@@ -152,10 +151,14 @@
152
151
  class="mb-2"
153
152
  v-if="selectedRoute.schedules && selectedRoute.schedules.length"
154
153
  >
155
- Security Check Schedule:
156
- <span class="font-weight-bold">
157
- {{ selectedRoute.schedules.map(s => `${s.start}-${s.end}`).join(", ") }}
158
- </span>
154
+ <div class="mb-2">
155
+ Security Check Schedule
156
+ <span class="route-preview__count">
157
+ · {{ selectedRoute.schedules.length }}
158
+ {{ selectedRoute.schedules.length === 1 ? "check" : "checks" }} a day
159
+ </span>
160
+ </div>
161
+ <NFCRouteScheduleTimes :windows="selectedRoute.schedules" />
159
162
  </v-col>
160
163
 
161
164
  <v-col
@@ -291,6 +294,8 @@
291
294
 
292
295
  <script setup lang="ts">
293
296
  import useNFCPatrolRoute from "../../composables/useNFCPatrolRoute";
297
+ import { formatRouteDays, routeWindows } from "../../utils/nfc-patrol-schedule";
298
+ import NFCRouteScheduleTimes from "./NFCRouteScheduleTimes.vue";
294
299
 
295
300
  const props = defineProps({
296
301
  site: {
@@ -343,21 +348,6 @@ const searchInput = ref("");
343
348
  const { getAll: getAllRoutes, getById: getRouteById, deleteById: deleteRouteById } =
344
349
  useNFCPatrolRoute();
345
350
 
346
- function calculateEndTime(startTime: string, toleranceMinutes: number): string {
347
- if (!startTime) return '';
348
-
349
- const [hours, minutes] = startTime.split(':').map(Number);
350
- if (isNaN(hours) || isNaN(minutes)) return startTime;
351
-
352
- const totalMinutes = hours * 60 + minutes + toleranceMinutes;
353
- const wrappedMinutes = ((totalMinutes % 1440) + 1440) % 1440;
354
-
355
- const endHours = String(Math.floor(wrappedMinutes / 60)).padStart(2, '0');
356
- const endMins = String(wrappedMinutes % 60).padStart(2, '0');
357
-
358
- return `${endHours}:${endMins}`;
359
- }
360
-
361
351
  // Use a reactive trigger for manual refresh
362
352
  const refreshTrigger = ref(0);
363
353
 
@@ -389,14 +379,9 @@ watchEffect(() => {
389
379
  // Display fields for the table
390
380
  routeName: item.name,
391
381
  numberOfCheckpoints: item.checkPointNumber,
392
- schedules: item.startTimes?.map((time: string) => ({
393
- start: time,
394
- end: calculateEndTime(time, item.tolerance || 0)
395
- })) || [],
396
- repeatDays: item.days?.map((d: number) => {
397
- const dayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
398
- return dayNames[d];
399
- }).join(', ') || '--',
382
+ // Each start time's window, earliest first; days Monday first, runs as ranges.
383
+ schedules: routeWindows(item.startTimes, item.tolerance),
384
+ repeatDays: formatRouteDays(item.days) || '--',
400
385
  checkpoints: item.checkPoints?.map((cp: any) => ({
401
386
  nfcTagId: cp.nfcTag_id,
402
387
  })) || []
@@ -529,6 +514,11 @@ async function submitDelete() {
529
514
  }
530
515
  }
531
516
  </script>
517
+ <style scoped>
518
+ .route-preview__count {
519
+ color: var(--text2);
520
+ }
521
+ </style>
532
522
  <!--
533
523
  The screen's own table CSS is gone with the `v-data-table` it styled: it
534
524
  hardcoded an `rgb(250,250,250)` header fill and black-alpha borders, which
@@ -0,0 +1,83 @@
1
+ <!--
2
+ A route's check windows as pills, earliest first: "09:01 – 14:40", never
3
+ broken across lines, with a "+1" on a window that ends the next day.
4
+
5
+ It replaces one comma-joined string in the order the times were typed,
6
+ which wrapped mid-time ("10:01-" / "18:40") and grew a table row as tall as
7
+ its list. Given `limit`, the first windows show and the rest fold into a
8
+ "+5 more" pill whose tooltip lists them.
9
+ -->
10
+ <template>
11
+ <div v-if="windows.length" class="route-times">
12
+ <span
13
+ v-for="(entry, index) in shown"
14
+ :key="`${entry.start}-${index}`"
15
+ class="route-times__pill"
16
+ :title="routeWindowLabel(entry)"
17
+ >
18
+ {{ entry.end ? `${entry.start} – ${entry.end}` : entry.start }}<span
19
+ v-if="entry.nextDay"
20
+ class="route-times__next"
21
+ aria-label="next day"
22
+ >+1</span>
23
+ </span>
24
+ <span
25
+ v-if="hidden.length"
26
+ class="route-times__pill route-times__pill--more"
27
+ :title="hidden.map(routeWindowLabel).join('\n')"
28
+ >
29
+ +{{ hidden.length }} more
30
+ </span>
31
+ </div>
32
+ <span v-else>--</span>
33
+ </template>
34
+
35
+ <script setup lang="ts">
36
+ import { routeWindowLabel, type RouteWindow } from "../../utils/nfc-patrol-schedule";
37
+
38
+ const props = defineProps<{
39
+ windows: RouteWindow[];
40
+ /** How many to show before folding the rest into "+N more"; all when not given. */
41
+ limit?: number;
42
+ }>();
43
+
44
+ const shown = computed(() => (props.limit ? props.windows.slice(0, props.limit) : props.windows));
45
+ const hidden = computed(() => (props.limit ? props.windows.slice(props.limit) : []));
46
+ </script>
47
+
48
+ <style scoped>
49
+ .route-times {
50
+ display: flex;
51
+ flex-wrap: wrap;
52
+ gap: 6px;
53
+ padding: 2px 0;
54
+ }
55
+
56
+ .route-times__pill {
57
+ display: inline-flex;
58
+ align-items: baseline;
59
+ gap: 3px;
60
+ padding: 3px 10px;
61
+ border: 1px solid var(--border);
62
+ border-radius: var(--r-pill);
63
+ background: var(--thead);
64
+ font-family: var(--font-sans);
65
+ font-size: var(--fs-chip-lg);
66
+ font-weight: 600;
67
+ color: var(--text);
68
+ font-variant-numeric: tabular-nums;
69
+ white-space: nowrap;
70
+ }
71
+
72
+ .route-times__next {
73
+ font-size: 10px;
74
+ font-weight: 700;
75
+ color: var(--warn);
76
+ }
77
+
78
+ .route-times__pill--more {
79
+ background: transparent;
80
+ color: var(--text2);
81
+ cursor: help;
82
+ }
83
+ </style>
@@ -5,7 +5,7 @@
5
5
  :options="options"
6
6
  :show-time-filter="false"
7
7
  @update:model-value="$emit('update:filters', $event)"
8
- @export="(type) => $emit('export', type)"
8
+ @export="(type) => $emit('export', type, csvSections())"
9
9
  />
10
10
  <div class="report-export">
11
11
  <v-divider :thickness="1" class="border-opacity-100" />
@@ -13,7 +13,7 @@
13
13
  <template v-if="report">
14
14
  <ReportLocationHeader :location="report.location" />
15
15
  <v-divider :thickness="1" class="border-opacity-100 mb-6" />
16
- <SummaryReportTable :title="report.title" :rows="report.rows" />
16
+ <SummaryReportTable :title="report.title" :rows="report.rows" @select="openDetails" />
17
17
  </template>
18
18
 
19
19
 
@@ -31,6 +31,8 @@
31
31
  />
32
32
 
33
33
  <ReportEmptyState v-else-if="!loading" />
34
+
35
+ <PatrolRouteDetailsDialog v-model="detailsOpen" :row="selectedRow" />
34
36
  </div>
35
37
  </div>
36
38
  </template>
@@ -39,8 +41,12 @@
39
41
  import type {
40
42
  NFCPatrolReportFilterOptions,
41
43
  NFCPatrolReportFilters,
44
+ NFCPatrolReportSummaryRow,
42
45
  } from "../../../types/nfc-patrol-report";
43
46
  import { useNFCPatrolDailyReport } from "../../../composables/useNFCPatrolDailyReport";
47
+ import { dailyReportCsv } from "../../../utils/nfc-patrol-report";
48
+ import type { CsvSection } from "../../../utils/report-export";
49
+ import PatrolRouteDetailsDialog from "./PatrolRouteDetailsDialog.vue";
44
50
  import ReportEmptyState from "./ReportEmptyState.vue";
45
51
  import ReportFilters from "./ReportFilters.vue";
46
52
  import ReportLocationHeader from "./ReportLocationHeader.vue";
@@ -55,7 +61,8 @@ const props = defineProps<{
55
61
 
56
62
  defineEmits<{
57
63
  "update:filters": [value: NFCPatrolReportFilters];
58
- export: [type: "pdf" | "csv"];
64
+ /** `csv` is the report's tables, built from its data rather than read off the screen. */
65
+ export: [type: "pdf" | "csv", csv: CsvSection[]];
59
66
  }>();
60
67
 
61
68
  const { report, loading, notFound, failed, fetchReport } = useNFCPatrolDailyReport(
@@ -63,6 +70,20 @@ const { report, loading, notFound, failed, fetchReport } = useNFCPatrolDailyRepo
63
70
  props.site,
64
71
  );
65
72
 
73
+ const { getFileUrl } = useFile();
74
+
75
+ function csvSections() {
76
+ return report.value ? dailyReportCsv(report.value, getFileUrl) : [];
77
+ }
78
+
79
+ const detailsOpen = ref(false);
80
+ const selectedRow = ref<NFCPatrolReportSummaryRow | null>(null);
81
+
82
+ function openDetails(row: NFCPatrolReportSummaryRow) {
83
+ selectedRow.value = row;
84
+ detailsOpen.value = true;
85
+ }
86
+
66
87
  watch(
67
88
  () => [props.filters.route, props.filters.date, props.active],
68
89
  () => {
@@ -6,7 +6,7 @@
6
6
  :show-time-filter="false"
7
7
  :show-date-filter="false"
8
8
  @update:model-value="$emit('update:filters', $event)"
9
- @export="(type) => $emit('export', type)"
9
+ @export="(type) => $emit('export', type, csvSections())"
10
10
  />
11
11
  <div class="report-export">
12
12
  <v-divider :thickness="1" class="border-opacity-100" />
@@ -18,6 +18,7 @@
18
18
  <MonthlyReportTable
19
19
  :title="report.title"
20
20
  :rows="report.rows"
21
+ @select="openMonth"
21
22
  />
22
23
  </template>
23
24
 
@@ -33,6 +34,13 @@
33
34
  title="No Monthly Report"
34
35
  message="No patrol log found for this route"
35
36
  />
37
+
38
+ <PatrolMonthDialog
39
+ v-model="monthOpen"
40
+ :title="monthTitle"
41
+ :route-name="monthRows[0]?.detail?.routeSummary.routeName ?? ''"
42
+ :rows="monthRows"
43
+ />
36
44
  </div>
37
45
  </div>
38
46
  </template>
@@ -41,9 +49,13 @@
41
49
  import type {
42
50
  NFCPatrolReportFilterOptions,
43
51
  NFCPatrolReportFilters,
52
+ NFCPatrolReportSummaryRow,
44
53
  } from "../../../types/nfc-patrol-report";
45
54
 
46
55
  import { useNFCPatrolMonthlyReport } from "../../../composables/useNFCPatrolMonthlyReport";
56
+ import { monthlyReportCsv } from "../../../utils/nfc-patrol-report";
57
+ import PatrolMonthDialog from "./PatrolMonthDialog.vue";
58
+ import type { CsvSection } from "../../../utils/report-export";
47
59
 
48
60
  import ReportEmptyState from "./ReportEmptyState.vue";
49
61
  import ReportFilters from "./ReportFilters.vue";
@@ -59,12 +71,29 @@ const props = defineProps<{
59
71
 
60
72
  defineEmits<{
61
73
  "update:filters": [value: NFCPatrolReportFilters];
62
- export: [type: "pdf" | "csv"];
74
+ /** `csv` is the report's tables, built from its data rather than read off the screen. */
75
+ export: [type: "pdf" | "csv", csv: CsvSection[]];
63
76
  }>();
64
77
 
65
- const { report, loading, notFound, failed, fetchReport } =
78
+ const { report, loading, notFound, failed, fetchReport, monthRuns } =
66
79
  useNFCPatrolMonthlyReport(props.filters, props.site);
67
80
 
81
+ // A month's row opens the list of that month's patrols.
82
+ const monthOpen = ref(false);
83
+ const monthTitle = ref("");
84
+ const monthRows = shallowRef<NFCPatrolReportSummaryRow[]>([]);
85
+
86
+ function openMonth(monthIndex: number) {
87
+ // The yearly report always covers the current year (useNFCPatrolMonthlyReport).
88
+ monthTitle.value = `${report.value?.rows[monthIndex]?.month ?? ""} ${new Date().getFullYear()}`;
89
+ monthRows.value = monthRuns(monthIndex);
90
+ monthOpen.value = true;
91
+ }
92
+
93
+ function csvSections() {
94
+ return report.value ? monthlyReportCsv(report.value) : [];
95
+ }
96
+
68
97
  watch(
69
98
  () => [props.filters.route, props.active],
70
99
  () => {
@@ -1,3 +1,8 @@
1
+ <!--
2
+ The year, month by month. A month that had patrols opens its list of patrol
3
+ runs (`PatrolMonthDialog`), and each run there opens its checkpoints and
4
+ skip photos.
5
+ -->
1
6
  <template>
2
7
  <div class="mt-6">
3
8
  <div class="screen-card-title mb-4">
@@ -17,8 +22,13 @@
17
22
 
18
23
  <tbody>
19
24
  <tr
20
- v-for="row in rows"
25
+ v-for="(row, index) in rows"
21
26
  :key="row.month"
27
+ :class="{ 'monthly-table__row--link': row.runs }"
28
+ :tabindex="row.runs ? 0 : undefined"
29
+ :title="row.runs ? `View the patrols of ${row.month}` : undefined"
30
+ @click="row.runs && emit('select', index)"
31
+ @keydown.enter="row.runs && emit('select', index)"
22
32
  >
23
33
  <td>{{ row.month }}</td>
24
34
 
@@ -52,6 +62,11 @@ defineProps<{
52
62
  title: string;
53
63
  rows: NFCPatrolMonthlyReportRow[];
54
64
  }>();
65
+
66
+ const emit = defineEmits<{
67
+ /** The month (0-11) whose patrols to list. */
68
+ select: [monthIndex: number];
69
+ }>();
55
70
  </script>
56
71
 
57
72
  <style scoped>
@@ -68,4 +83,17 @@ thead th {
68
83
  tbody td {
69
84
  height: 56px;
70
85
  }
86
+
87
+ .monthly-table__row--link {
88
+ cursor: pointer;
89
+ }
90
+
91
+ .monthly-table__row--link:hover > td {
92
+ background: var(--hover);
93
+ }
94
+
95
+ .monthly-table__row--link:focus-visible {
96
+ outline: 2px solid var(--accent);
97
+ outline-offset: -2px;
98
+ }
71
99
  </style>
@@ -10,6 +10,11 @@
10
10
  tokens by way of `utils/theme.ts`, and `utils/status.ts` does not name
11
11
  "Skipped", so routing this through `StatusChip` would turn a red skipped
12
12
  checkpoint neutral. That is a design decision, not a conversion.
13
+
14
+ A skipped checkpoint's photo shows in its own column (`SkipPhotoThumb`); the
15
+ thumbnail opens the photo, the rest of the row still opens the remarks. The
16
+ PDF drops that column and draws the photo with its remarks in a row of its
17
+ own right under the checkpoint (`SkipPhotoDetails`), kept on the same page.
13
18
  -->
14
19
  <template>
15
20
  <div class="table-card table-card__shrink">
@@ -26,13 +31,14 @@
26
31
  <th>Signature</th>
27
32
  <th>Start - End Time</th>
28
33
  <th>Status</th>
34
+ <th data-pdf-hide>Skip Photo</th>
29
35
  </tr>
30
36
  </thead>
31
37
  <tbody>
38
+ <template v-for="(activity, index) in activities" :key="`${activity.id}-${index}`">
32
39
  <tr
33
- v-for="activity in activities"
34
- :key="activity.id"
35
40
  :class="{ 'cursor-pointer': activity.status === 'Skipped' }"
41
+ :data-pdf-keep-with-next="activity.status === 'Skipped' || undefined"
36
42
  @click="handleActivityClick(activity)"
37
43
  >
38
44
  <td>{{ activity.checkpoint }}</td>
@@ -44,6 +50,7 @@
44
50
  :alt="`${activity.guardName || worker.one} signature`"
45
51
  class="guard-signature"
46
52
  contain
53
+ eager
47
54
  />
48
55
  <span v-else>-</span>
49
56
  </td>
@@ -62,7 +69,16 @@
62
69
  </v-icon>
63
70
  </v-chip>
64
71
  </td>
72
+ <td data-pdf-hide>
73
+ <SkipPhotoThumb :activity="activity" />
74
+ </td>
75
+ </tr>
76
+ <tr v-if="activity.status === 'Skipped'" data-pdf-only>
77
+ <td colspan="5" class="activity-table__skip">
78
+ <SkipPhotoDetails :activities="[activity]" inline />
79
+ </td>
65
80
  </tr>
81
+ </template>
66
82
  </tbody>
67
83
  </v-table>
68
84
  </div>
@@ -75,6 +91,8 @@ import type {
75
91
  NFCPatrolActivity,
76
92
  NFCPatrolActivityStatus,
77
93
  } from "../../../types/nfc-patrol-report";
94
+ import SkipPhotoDetails from "./SkipPhotoDetails.vue";
95
+ import SkipPhotoThumb from "./SkipPhotoThumb.vue";
78
96
 
79
97
  const worker = useWorkerTerm();
80
98
  defineProps<{
@@ -104,6 +122,10 @@ function handleActivityClick(activity: NFCPatrolActivity) {
104
122
  border-bottom: 1px solid var(--border);
105
123
  }
106
124
 
125
+ .activity-table__skip {
126
+ padding-top: 0 !important;
127
+ }
128
+
107
129
  .cursor-pointer {
108
130
  cursor: pointer;
109
131
  }