@7365admin1/module-hygiene 4.5.0 → 4.7.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 +12 -0
- package/dist/index.d.ts +8 -4
- package/dist/index.js +53 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -2556,6 +2556,8 @@ function MAreaChecklist(value) {
|
|
|
2556
2556
|
units: checklistItem.units.map((unit) => ({
|
|
2557
2557
|
unit: new ObjectId8(unit.unit),
|
|
2558
2558
|
name: unit.name,
|
|
2559
|
+
approve: false,
|
|
2560
|
+
reject: false,
|
|
2559
2561
|
status: "ready",
|
|
2560
2562
|
remarks: "",
|
|
2561
2563
|
completedBy: "",
|
|
@@ -3098,8 +3100,12 @@ function useAreaChecklistRepo() {
|
|
|
3098
3100
|
$project: {
|
|
3099
3101
|
_id: 0,
|
|
3100
3102
|
set: "$checklist.set",
|
|
3103
|
+
remarks: "$checklist.remarks",
|
|
3104
|
+
attachment: "$checklist.attachment",
|
|
3101
3105
|
unit: "$checklist.units.unit",
|
|
3102
3106
|
name: "$checklist.units.name",
|
|
3107
|
+
approve: "$checklist.units.approve",
|
|
3108
|
+
reject: "$checklist.units.reject",
|
|
3103
3109
|
status: {
|
|
3104
3110
|
$switch: {
|
|
3105
3111
|
branches: [
|
|
@@ -3114,18 +3120,21 @@ function useAreaChecklistRepo() {
|
|
|
3114
3120
|
],
|
|
3115
3121
|
default: "$checklist.units.status"
|
|
3116
3122
|
}
|
|
3117
|
-
}
|
|
3118
|
-
remarks: "$checklist.units.remarks"
|
|
3123
|
+
}
|
|
3119
3124
|
}
|
|
3120
3125
|
},
|
|
3121
3126
|
{ $sort: { set: 1, name: 1 } },
|
|
3122
3127
|
{
|
|
3123
3128
|
$group: {
|
|
3124
3129
|
_id: "$set",
|
|
3130
|
+
remarks: { $first: "$remarks" },
|
|
3131
|
+
attachment: { $first: "$attachment" },
|
|
3125
3132
|
units: {
|
|
3126
3133
|
$push: {
|
|
3127
3134
|
unit: "$unit",
|
|
3128
3135
|
name: "$name",
|
|
3136
|
+
approve: "$approve",
|
|
3137
|
+
reject: "$reject",
|
|
3129
3138
|
status: "$status",
|
|
3130
3139
|
remarks: "$remarks"
|
|
3131
3140
|
}
|
|
@@ -3136,6 +3145,8 @@ function useAreaChecklistRepo() {
|
|
|
3136
3145
|
$project: {
|
|
3137
3146
|
_id: 0,
|
|
3138
3147
|
set: "$_id",
|
|
3148
|
+
remarks: "$remarks",
|
|
3149
|
+
attachment: "$attachment",
|
|
3139
3150
|
units: 1
|
|
3140
3151
|
}
|
|
3141
3152
|
},
|
|
@@ -3210,7 +3221,7 @@ function useAreaChecklistRepo() {
|
|
|
3210
3221
|
throw error;
|
|
3211
3222
|
}
|
|
3212
3223
|
}
|
|
3213
|
-
async function
|
|
3224
|
+
async function updateAreaChecklistUnits(_id, set, unitId, value, session) {
|
|
3214
3225
|
try {
|
|
3215
3226
|
_id = new ObjectId9(_id);
|
|
3216
3227
|
} catch (error) {
|
|
@@ -3225,12 +3236,26 @@ function useAreaChecklistRepo() {
|
|
|
3225
3236
|
const now = /* @__PURE__ */ new Date();
|
|
3226
3237
|
const updateValue = {
|
|
3227
3238
|
"checklist.$[checklist].units.$[unit].timestamp": now,
|
|
3228
|
-
"checklist.$[checklist].units.$[unit].status": "completed",
|
|
3229
3239
|
updatedAt: now
|
|
3230
3240
|
};
|
|
3241
|
+
if (value.approve === true) {
|
|
3242
|
+
updateValue["checklist.$[checklist].units.$[unit].approve"] = true;
|
|
3243
|
+
updateValue["checklist.$[checklist].units.$[unit].reject"] = false;
|
|
3244
|
+
updateValue["checklist.$[checklist].units.$[unit].status"] = "completed";
|
|
3245
|
+
} else if (value.reject === true) {
|
|
3246
|
+
updateValue["checklist.$[checklist].units.$[unit].approve"] = false;
|
|
3247
|
+
updateValue["checklist.$[checklist].units.$[unit].reject"] = true;
|
|
3248
|
+
updateValue["checklist.$[checklist].units.$[unit].status"] = "ready";
|
|
3249
|
+
}
|
|
3231
3250
|
if (value.remarks) {
|
|
3232
3251
|
updateValue["checklist.$[checklist].units.$[unit].remarks"] = value.remarks;
|
|
3233
3252
|
}
|
|
3253
|
+
if (value.attachment) {
|
|
3254
|
+
updateValue["checklist.$[checklist].attachment"] = value.attachment;
|
|
3255
|
+
if (value.remarks) {
|
|
3256
|
+
updateValue["checklist.$[checklist].remarks"] = value.remarks;
|
|
3257
|
+
}
|
|
3258
|
+
}
|
|
3234
3259
|
if (value.completedBy) {
|
|
3235
3260
|
updateValue["checklist.$[checklist].units.$[unit].completedBy"] = new ObjectId9(value.completedBy);
|
|
3236
3261
|
}
|
|
@@ -3358,7 +3383,7 @@ function useAreaChecklistRepo() {
|
|
|
3358
3383
|
getAreaChecklistByAreaAndSchedule,
|
|
3359
3384
|
updateAreaChecklist,
|
|
3360
3385
|
updateAreaChecklistStatus,
|
|
3361
|
-
|
|
3386
|
+
updateAreaChecklistUnits,
|
|
3362
3387
|
getMaxSetNumberForArea
|
|
3363
3388
|
};
|
|
3364
3389
|
}
|
|
@@ -3371,7 +3396,7 @@ function useAreaChecklistService() {
|
|
|
3371
3396
|
getAllAreaChecklist,
|
|
3372
3397
|
getAreaChecklistUnits,
|
|
3373
3398
|
getAreaChecklistById,
|
|
3374
|
-
|
|
3399
|
+
updateAreaChecklistUnits: _updateAreaChecklistUnits,
|
|
3375
3400
|
updateAreaChecklistStatus,
|
|
3376
3401
|
getMaxSetNumberForArea
|
|
3377
3402
|
} = useAreaChecklistRepo();
|
|
@@ -3442,11 +3467,11 @@ function useAreaChecklistService() {
|
|
|
3442
3467
|
session?.endSession();
|
|
3443
3468
|
}
|
|
3444
3469
|
}
|
|
3445
|
-
async function
|
|
3470
|
+
async function updateAreaChecklistUnits(_id, set, unitId, value) {
|
|
3446
3471
|
const session = useAtlas7.getClient()?.startSession();
|
|
3447
3472
|
try {
|
|
3448
3473
|
session?.startTransaction();
|
|
3449
|
-
await
|
|
3474
|
+
await _updateAreaChecklistUnits(_id, set, unitId, value, session);
|
|
3450
3475
|
const allUnitsResult = await getAreaChecklistUnits(
|
|
3451
3476
|
{
|
|
3452
3477
|
page: 1,
|
|
@@ -3526,7 +3551,7 @@ function useAreaChecklistService() {
|
|
|
3526
3551
|
session?.endSession();
|
|
3527
3552
|
}
|
|
3528
3553
|
}
|
|
3529
|
-
return { createAreaChecklist,
|
|
3554
|
+
return { createAreaChecklist, updateAreaChecklistUnits };
|
|
3530
3555
|
}
|
|
3531
3556
|
|
|
3532
3557
|
// src/controllers/hygiene-area-checklist.controller.ts
|
|
@@ -3541,7 +3566,7 @@ function useAreaChecklistController() {
|
|
|
3541
3566
|
} = useAreaChecklistRepo();
|
|
3542
3567
|
const {
|
|
3543
3568
|
createAreaChecklist: _createAreaChecklist,
|
|
3544
|
-
|
|
3569
|
+
updateAreaChecklistUnits: _updateAreaChecklistUnits
|
|
3545
3570
|
} = useAreaChecklistService();
|
|
3546
3571
|
async function createAreaChecklist(req, res, next) {
|
|
3547
3572
|
const cookies = req.headers.cookie ? req.headers.cookie.split(";").map((cookie) => cookie.trim().split("=")).reduce(
|
|
@@ -3708,22 +3733,36 @@ function useAreaChecklistController() {
|
|
|
3708
3733
|
return;
|
|
3709
3734
|
}
|
|
3710
3735
|
}
|
|
3711
|
-
async function
|
|
3736
|
+
async function updateAreaChecklistUnits(req, res, next) {
|
|
3712
3737
|
const cookies = req.headers.cookie ? req.headers.cookie.split(";").map((cookie) => cookie.trim().split("=")).reduce(
|
|
3713
3738
|
(acc, [key, value]) => ({ ...acc, [key]: value }),
|
|
3714
3739
|
{}
|
|
3715
3740
|
) : {};
|
|
3716
3741
|
const completedBy = cookies["user"] || "";
|
|
3742
|
+
const decisionMap = {
|
|
3743
|
+
approve: { approve: true, reject: false },
|
|
3744
|
+
reject: { approve: false, reject: true }
|
|
3745
|
+
};
|
|
3746
|
+
const decision = req.params.decision;
|
|
3747
|
+
const decisionValues = decisionMap[decision] || {
|
|
3748
|
+
approve: void 0,
|
|
3749
|
+
reject: void 0
|
|
3750
|
+
};
|
|
3717
3751
|
const payload = {
|
|
3718
3752
|
...req.params,
|
|
3719
3753
|
...req.body,
|
|
3754
|
+
...decisionValues,
|
|
3720
3755
|
completedBy
|
|
3721
3756
|
};
|
|
3722
3757
|
const validation = Joi9.object({
|
|
3723
3758
|
id: Joi9.string().hex().required(),
|
|
3724
3759
|
set: Joi9.number().integer().min(1).required(),
|
|
3725
3760
|
unit: Joi9.string().hex().required(),
|
|
3761
|
+
decision: Joi9.string().valid("approve", "reject").required(),
|
|
3762
|
+
approve: Joi9.boolean().optional(),
|
|
3763
|
+
reject: Joi9.boolean().optional(),
|
|
3726
3764
|
remarks: Joi9.string().optional().allow("", null),
|
|
3765
|
+
attachment: Joi9.array().items(Joi9.string()).optional(),
|
|
3727
3766
|
completedBy: Joi9.string().hex().required()
|
|
3728
3767
|
});
|
|
3729
3768
|
const { error } = validation.validate(payload);
|
|
@@ -3733,13 +3772,8 @@ function useAreaChecklistController() {
|
|
|
3733
3772
|
return;
|
|
3734
3773
|
}
|
|
3735
3774
|
try {
|
|
3736
|
-
const { id, set, unit, ...value } = payload;
|
|
3737
|
-
await
|
|
3738
|
-
id,
|
|
3739
|
-
parseInt(set),
|
|
3740
|
-
unit,
|
|
3741
|
-
value
|
|
3742
|
-
);
|
|
3775
|
+
const { id, set, unit, decision: decision2, ...value } = payload;
|
|
3776
|
+
await _updateAreaChecklistUnits(id, parseInt(set), unit, value);
|
|
3743
3777
|
res.json({ message: "Area checklist updated successfully." });
|
|
3744
3778
|
return;
|
|
3745
3779
|
} catch (error2) {
|
|
@@ -3754,7 +3788,7 @@ function useAreaChecklistController() {
|
|
|
3754
3788
|
getAreaChecklistHistory,
|
|
3755
3789
|
getAreaChecklistHistoryDetails,
|
|
3756
3790
|
getAreaChecklistUnits,
|
|
3757
|
-
|
|
3791
|
+
updateAreaChecklistUnits
|
|
3758
3792
|
};
|
|
3759
3793
|
}
|
|
3760
3794
|
|