@7365admin1/layer-common 4.170.2 → 4.171.0
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.
- package/CHANGELOG.md +17 -4
- package/components/ScheduleAreaMain.vue +96 -0
- package/package.json +1 -1
- package/utils/schedule-task.ts +46 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @iservice365/layer-common
|
|
2
2
|
|
|
3
|
+
## 4.171.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 56755b3: Daily Checklist: add areas set up after the day's list was made (DV-0998, DV-1003)
|
|
8
|
+
|
|
9
|
+
A day's list is made at midnight, so an area set up during the day only started
|
|
10
|
+
on tomorrow's list, and "Create today's list now" showed only for an empty day.
|
|
11
|
+
The day view now names those areas in a notice with "Add to today's list"
|
|
12
|
+
(creating the list again adds only what is missing). Without the right to
|
|
13
|
+
create lists the notice says to ask someone who can. Areas with no units or no
|
|
14
|
+
visits are left out, as the list would skip them.
|
|
15
|
+
|
|
3
16
|
## 4.170.2
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -3879,11 +3892,11 @@ Monthly report: a month that had patrols opens the list of that month's patrol r
|
|
|
3879
3892
|
`utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
|
|
3880
3893
|
own rule from two endpoints the console already calls, unprojected:
|
|
3881
3894
|
|
|
3882
|
-
|
|
3883
|
-
|
|
3895
|
+
GET /api/members/user/:user/app/admin the Seven365 staff membership
|
|
3896
|
+
GET /api/roles/id/:role that membership's role document
|
|
3884
3897
|
|
|
3885
|
-
|
|
3886
|
-
|
|
3898
|
+
owner = member.type === "admin" && role.type === "admin" && role.default === true
|
|
3899
|
+
staff = member.type === "admin" && role.type === "admin"
|
|
3887
3900
|
|
|
3888
3901
|
`role.default` is the marker because it is the only property of a platform
|
|
3889
3902
|
staff role no API caller can set - `role.controller.ts` validates create and
|
|
@@ -8,6 +8,32 @@
|
|
|
8
8
|
:schedule-route="scheduleRoute"
|
|
9
9
|
text="These are the areas on this day's checklist. Click an area to see each unit, tick it as done, or send it back to be redone. Visits today counts the area's normal visits plus any extra checks added today."
|
|
10
10
|
/>
|
|
11
|
+
<!--
|
|
12
|
+
DV-0998 / DV-1003: an area set up during the day is not on that day's
|
|
13
|
+
list (lists are made at midnight). Say which, and offer to add it:
|
|
14
|
+
creating the list again adds only what is missing.
|
|
15
|
+
-->
|
|
16
|
+
<v-alert
|
|
17
|
+
v-if="showMissingNotice"
|
|
18
|
+
type="info"
|
|
19
|
+
variant="tonal"
|
|
20
|
+
density="comfortable"
|
|
21
|
+
class="mb-3"
|
|
22
|
+
:title="missingNotice.title"
|
|
23
|
+
:text="missingNotice.body"
|
|
24
|
+
>
|
|
25
|
+
<template v-if="canGenerateChecklist" #append>
|
|
26
|
+
<v-btn
|
|
27
|
+
class="text-none screen-btn-primary"
|
|
28
|
+
variant="flat"
|
|
29
|
+
aria-label="Add to today's list"
|
|
30
|
+
:loading="addingAreas"
|
|
31
|
+
@click="addMissingAreas"
|
|
32
|
+
>
|
|
33
|
+
Add to today's list
|
|
34
|
+
</v-btn>
|
|
35
|
+
</template>
|
|
36
|
+
</v-alert>
|
|
11
37
|
<TableMain
|
|
12
38
|
:title="dayTitle"
|
|
13
39
|
:headers="headers"
|
|
@@ -144,11 +170,15 @@
|
|
|
144
170
|
<script setup lang="ts">
|
|
145
171
|
import useCleaningSchedules from "../composables/useCleaningSchedules";
|
|
146
172
|
import {
|
|
173
|
+
areaNamesText,
|
|
174
|
+
areasMissingFromDay,
|
|
147
175
|
dailyChecklistTitle,
|
|
148
176
|
dailyStatusLabel,
|
|
149
177
|
dayLabel,
|
|
150
178
|
isClosedDay,
|
|
179
|
+
missingAreasNotice,
|
|
151
180
|
} from "../utils/schedule-task";
|
|
181
|
+
import useAreas from "../composables/useAreas";
|
|
152
182
|
import useUtils from "../composables/useUtils";
|
|
153
183
|
|
|
154
184
|
const props = defineProps({
|
|
@@ -271,6 +301,69 @@ const showCreateList = computed(
|
|
|
271
301
|
items.value.length === 0,
|
|
272
302
|
);
|
|
273
303
|
|
|
304
|
+
// Areas set up after this day's list was made (DV-0998 / DV-1003). The whole
|
|
305
|
+
// day and every area of the service, not the filtered page on screen.
|
|
306
|
+
const { getAreas } = useAreas();
|
|
307
|
+
const missingAreas = ref<string[]>([]);
|
|
308
|
+
const addingAreas = ref(false);
|
|
309
|
+
|
|
310
|
+
async function checkMissingAreas() {
|
|
311
|
+
if (!props.site || !props.scheduleAreaId || !props.serviceType) return;
|
|
312
|
+
try {
|
|
313
|
+
const [areas, day] = await Promise.all([
|
|
314
|
+
getAreas({ site: props.site, serviceType: props.serviceType, limit: 200 }),
|
|
315
|
+
getScheduleAreas({
|
|
316
|
+
scheduleAreaId: props.scheduleAreaId,
|
|
317
|
+
page: 1,
|
|
318
|
+
limit: 200,
|
|
319
|
+
serviceType: props.serviceType,
|
|
320
|
+
}),
|
|
321
|
+
]);
|
|
322
|
+
missingAreas.value = areasMissingFromDay(areas?.items, day?.items);
|
|
323
|
+
} catch {
|
|
324
|
+
// a failed check is not evidence of a missing area: say nothing
|
|
325
|
+
missingAreas.value = [];
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const showMissingNotice = computed(
|
|
330
|
+
() =>
|
|
331
|
+
missingAreas.value.length > 0 &&
|
|
332
|
+
!isScheduleClosed.value &&
|
|
333
|
+
!showCreateList.value &&
|
|
334
|
+
!loading.value,
|
|
335
|
+
);
|
|
336
|
+
const missingNotice = computed(() =>
|
|
337
|
+
missingAreasNotice(missingAreas.value, canGenerateChecklist.value),
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
async function addMissingAreas() {
|
|
341
|
+
const before = [...missingAreas.value];
|
|
342
|
+
try {
|
|
343
|
+
addingAreas.value = true;
|
|
344
|
+
await generateChecklist(props.site, props.scheduleAreaId);
|
|
345
|
+
await Promise.all([getScheduleAreasRefresh(), checkMissingAreas()]);
|
|
346
|
+
const added = before.filter((name) => !missingAreas.value.includes(name));
|
|
347
|
+
showMessage(
|
|
348
|
+
added.length
|
|
349
|
+
? `${areaNamesText(added)} added to today's list.`
|
|
350
|
+
: "Today's list already has every area that can be added.",
|
|
351
|
+
added.length ? "success" : "info",
|
|
352
|
+
);
|
|
353
|
+
} catch (error: any) {
|
|
354
|
+
showMessage(
|
|
355
|
+
`Could not add ${areaNamesText(before)} to today's list. ${
|
|
356
|
+
error?.data?.message || "Check your connection and try again."
|
|
357
|
+
}`,
|
|
358
|
+
"error",
|
|
359
|
+
);
|
|
360
|
+
} finally {
|
|
361
|
+
addingAreas.value = false;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
watch(() => [props.site, props.scheduleAreaId, props.serviceType], checkMissingAreas);
|
|
366
|
+
|
|
274
367
|
function showMessage(msg: string, color: string = "error") {
|
|
275
368
|
message.value = msg;
|
|
276
369
|
messageColor.value = color;
|
|
@@ -306,6 +399,7 @@ async function _generateChecklist() {
|
|
|
306
399
|
if (typeof getScheduleAreasRefresh === "function") {
|
|
307
400
|
getScheduleAreasRefresh();
|
|
308
401
|
}
|
|
402
|
+
checkMissingAreas();
|
|
309
403
|
} catch (error: any) {
|
|
310
404
|
showMessage(error?.data?.message || error?.message || "Could not create today's list.", "error");
|
|
311
405
|
} finally {
|
|
@@ -314,6 +408,7 @@ async function _generateChecklist() {
|
|
|
314
408
|
}
|
|
315
409
|
|
|
316
410
|
onMounted(() => {
|
|
411
|
+
checkMissingAreas();
|
|
317
412
|
try {
|
|
318
413
|
const { $socket } = useNuxtApp() as any;
|
|
319
414
|
if ($socket) {
|
|
@@ -326,6 +421,7 @@ onMounted(() => {
|
|
|
326
421
|
if (typeof getScheduleAreasRefresh === "function") {
|
|
327
422
|
getScheduleAreasRefresh();
|
|
328
423
|
}
|
|
424
|
+
checkMissingAreas();
|
|
329
425
|
}
|
|
330
426
|
);
|
|
331
427
|
}
|
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.
|
|
5
|
+
"version": "4.171.0",
|
|
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.",
|
package/utils/schedule-task.ts
CHANGED
|
@@ -450,3 +450,49 @@ export function checklistPdfName(day: string | Date | null | undefined, now: Dat
|
|
|
450
450
|
const p = (n: number) => String(n).padStart(2, "0");
|
|
451
451
|
return `CHECKLIST_DOWNLOADED_${p(now.getDate())}_${p(now.getMonth() + 1)}_${now.getFullYear()} ${p(now.getHours())}_${p(now.getMinutes())}.pdf`;
|
|
452
452
|
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* AREAS SET UP AFTER THE DAY'S LIST WAS MADE (DV-0998 / DV-1003).
|
|
456
|
+
*
|
|
457
|
+
* A day's list is made at midnight from the areas set up then, so an area added
|
|
458
|
+
* during the day only starts on tomorrow's list. Creating the list again adds
|
|
459
|
+
* the missing areas and leaves the ones already on it alone (module-hygiene
|
|
460
|
+
* `createAreaChecklist`). These are the areas it would add: set up with at least
|
|
461
|
+
* one visit and, when the server says how many, at least one unit (an area
|
|
462
|
+
* without units is skipped, and `ScheduleGuide` already says so). Matched by
|
|
463
|
+
* name, the only area field the day list returns.
|
|
464
|
+
*/
|
|
465
|
+
export function areasMissingFromDay(
|
|
466
|
+
siteAreas: { name?: string | null; set?: unknown; unitCount?: unknown }[] | null | undefined,
|
|
467
|
+
dayRows: { name?: string | null }[] | null | undefined,
|
|
468
|
+
): string[] {
|
|
469
|
+
const key = (s: unknown) => String(s ?? "").trim().toLowerCase();
|
|
470
|
+
const onDay = new Set((dayRows ?? []).map((r) => key(r?.name)));
|
|
471
|
+
const missing: string[] = [];
|
|
472
|
+
for (const a of siteAreas ?? []) {
|
|
473
|
+
const name = String(a?.name ?? "").trim();
|
|
474
|
+
if (!name || onDay.has(key(name))) continue;
|
|
475
|
+
if (!(Number(a?.set) >= 1)) continue;
|
|
476
|
+
if (typeof a?.unitCount === "number" && a.unitCount === 0) continue;
|
|
477
|
+
if (!missing.some((m) => key(m) === key(name))) missing.push(name);
|
|
478
|
+
}
|
|
479
|
+
return missing;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/** "Hallway", "Hallway and Lobby B", "Hallway, Lobby B and 2 more". */
|
|
483
|
+
export function areaNamesText(names: string[]): string {
|
|
484
|
+
if (names.length <= 1) return names[0] ?? "";
|
|
485
|
+
if (names.length === 2) return `${names[0]} and ${names[1]}`;
|
|
486
|
+
if (names.length === 3) return `${names[0]}, ${names[1]} and ${names[2]}`;
|
|
487
|
+
return `${names[0]}, ${names[1]} and ${names.length - 2} more`;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/** The notice above the day's list, in the words the mockup agreed (6 Nov 2026). */
|
|
491
|
+
export function missingAreasNotice(names: string[], canAdd: boolean): { title: string; body: string } {
|
|
492
|
+
const one = names.length === 1;
|
|
493
|
+
const title = `${areaNamesText(names)} ${one ? "was" : "were"} set up after today's list was made.`;
|
|
494
|
+
const body = canAdd
|
|
495
|
+
? `Add ${one ? "it" : "them"} to today's list so ${one ? "it" : "they"} can be checked today. Otherwise ${one ? "it starts" : "they start"} on tomorrow's list.`
|
|
496
|
+
: `${one ? "It starts" : "They start"} on tomorrow's list. To check ${one ? "it" : "them"} today, ask someone who can create daily checklists to add ${one ? "it" : "them"}.`;
|
|
497
|
+
return { title, body };
|
|
498
|
+
}
|