@7365admin1/module-hygiene 4.30.1 → 4.30.2
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 +10 -0
- package/dist/index.js +34 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/require-photo-on-completion.test.mjs +63 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @7365admin1/module-hygiene
|
|
2
2
|
|
|
3
|
+
## 4.30.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6f02fc2: Decide which approve finishes a checklist set from approve/reject, the same rule
|
|
8
|
+
the units list uses, instead of the unit `status` field. Units at rest carry
|
|
9
|
+
"open" or "closed", so the old check never saw a set as finished: a set holding a
|
|
10
|
+
rejected unit could not be completed, and the finishing tick was not recognised.
|
|
11
|
+
No change to when a photo is required, and no schema or data change.
|
|
12
|
+
|
|
3
13
|
## 4.30.1
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -3288,6 +3288,39 @@ var import_core10 = require("@7365admin1/core");
|
|
|
3288
3288
|
// src/repositories/hygiene-area-checklist.repository.ts
|
|
3289
3289
|
var import_mongodb9 = require("mongodb");
|
|
3290
3290
|
var import_node_server_utils17 = require("@7365admin1/node-server-utils");
|
|
3291
|
+
|
|
3292
|
+
// src/utils/completion-photo.util.ts
|
|
3293
|
+
var COMPLETION_PHOTO_MESSAGE = "A photo is required to complete this task. Take or upload at least one photo before marking it complete.";
|
|
3294
|
+
function readCompletion(units, unitId) {
|
|
3295
|
+
if (units.length === 0)
|
|
3296
|
+
return { completesSet: false, hasEvidence: false };
|
|
3297
|
+
const others = units.filter((unit) => String(unit.unit) !== String(unitId));
|
|
3298
|
+
return {
|
|
3299
|
+
completesSet: others.every(
|
|
3300
|
+
(unit) => unit.approve === true || unit.reject === true
|
|
3301
|
+
),
|
|
3302
|
+
hasEvidence: others.some(
|
|
3303
|
+
(unit) => Array.isArray(unit.attachment) && unit.attachment.length > 0
|
|
3304
|
+
)
|
|
3305
|
+
};
|
|
3306
|
+
}
|
|
3307
|
+
function requiresCompletionPhoto({
|
|
3308
|
+
decision,
|
|
3309
|
+
attachment,
|
|
3310
|
+
completesSet,
|
|
3311
|
+
hasEvidence
|
|
3312
|
+
}) {
|
|
3313
|
+
if (decision !== "approve")
|
|
3314
|
+
return false;
|
|
3315
|
+
if (!completesSet)
|
|
3316
|
+
return false;
|
|
3317
|
+
if (hasEvidence)
|
|
3318
|
+
return false;
|
|
3319
|
+
const carriesEvidence = Array.isArray(attachment) && attachment.some((id) => typeof id === "string" && id.trim().length > 0);
|
|
3320
|
+
return !carriesEvidence;
|
|
3321
|
+
}
|
|
3322
|
+
|
|
3323
|
+
// src/repositories/hygiene-area-checklist.repository.ts
|
|
3291
3324
|
function useAreaChecklistRepo() {
|
|
3292
3325
|
const db = import_node_server_utils17.useAtlas.getDb();
|
|
3293
3326
|
if (!db) {
|
|
@@ -4132,18 +4165,7 @@ function useAreaChecklistRepo() {
|
|
|
4132
4165
|
const group = (doc?.checklist ?? []).find(
|
|
4133
4166
|
(entry) => entry.set === set
|
|
4134
4167
|
);
|
|
4135
|
-
|
|
4136
|
-
if (units.length === 0)
|
|
4137
|
-
return { completesSet: false, hasEvidence: false };
|
|
4138
|
-
const others = units.filter(
|
|
4139
|
-
(unit) => String(unit.unit) !== String(unitId)
|
|
4140
|
-
);
|
|
4141
|
-
return {
|
|
4142
|
-
completesSet: others.every((unit) => unit.status === "completed"),
|
|
4143
|
-
hasEvidence: others.some(
|
|
4144
|
-
(unit) => Array.isArray(unit.attachment) && unit.attachment.length > 0
|
|
4145
|
-
)
|
|
4146
|
-
};
|
|
4168
|
+
return readCompletion(group?.units ?? [], unitId);
|
|
4147
4169
|
}
|
|
4148
4170
|
async function updateAreaChecklist(_id, value, session) {
|
|
4149
4171
|
try {
|
|
@@ -4681,24 +4703,6 @@ var import_joi9 = __toESM(require("joi"));
|
|
|
4681
4703
|
var import_node_server_utils20 = require("@7365admin1/node-server-utils");
|
|
4682
4704
|
var import_core11 = require("@7365admin1/core");
|
|
4683
4705
|
|
|
4684
|
-
// src/utils/completion-photo.util.ts
|
|
4685
|
-
var COMPLETION_PHOTO_MESSAGE = "A photo is required to complete this task. Take or upload at least one photo before marking it complete.";
|
|
4686
|
-
function requiresCompletionPhoto({
|
|
4687
|
-
decision,
|
|
4688
|
-
attachment,
|
|
4689
|
-
completesSet,
|
|
4690
|
-
hasEvidence
|
|
4691
|
-
}) {
|
|
4692
|
-
if (decision !== "approve")
|
|
4693
|
-
return false;
|
|
4694
|
-
if (!completesSet)
|
|
4695
|
-
return false;
|
|
4696
|
-
if (hasEvidence)
|
|
4697
|
-
return false;
|
|
4698
|
-
const carriesEvidence = Array.isArray(attachment) && attachment.some((id) => typeof id === "string" && id.trim().length > 0);
|
|
4699
|
-
return !carriesEvidence;
|
|
4700
|
-
}
|
|
4701
|
-
|
|
4702
4706
|
// src/services/hygiene-checklist-pdf.service.ts
|
|
4703
4707
|
var import_puppeteer = require("puppeteer");
|
|
4704
4708
|
var import_node_server_utils19 = require("@7365admin1/node-server-utils");
|