tango-app-api-trax 3.8.21 → 3.8.22-nike
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/package.json +2 -2
- package/src/controllers/download.controller.js +19 -19
- package/src/controllers/gallery.controller.js +91 -27
- package/src/controllers/handlebar-helper.js +1 -0
- package/src/controllers/internalTrax.controller.js +808 -87
- package/src/controllers/mobileTrax.controller.js +262 -211
- package/src/controllers/teaxFlag.controller.js +5 -5
- package/src/controllers/trax.controller.js +6 -2
- package/src/hbs/recurringFlag.hbs +18 -16
- package/src/hbs/template.hbs +34 -23
- package/src/hbs/visit-checklist.hbs +84 -40
- package/src/hbs/weeklyWrap.hbs +218 -0
- package/src/routes/internalTraxApi.router.js +2 -0
- package/src/services/recurringFlagTracker.service.js +33 -33
- package/src/utils/visitChecklistPdf.utils.js +6 -5
|
@@ -118,7 +118,7 @@ export async function startChecklist( req, res ) {
|
|
|
118
118
|
$and: [
|
|
119
119
|
{ _id: new ObjectId( requestData.processedcheckListId ) },
|
|
120
120
|
{ userId: req.user._id },
|
|
121
|
-
{ date_string: requestData.date },
|
|
121
|
+
{ $or: [ { date_string: requestData.date }, { redoStatus: true } ] },
|
|
122
122
|
],
|
|
123
123
|
},
|
|
124
124
|
} );
|
|
@@ -137,7 +137,9 @@ export async function startChecklist( req, res ) {
|
|
|
137
137
|
let updateQuery = {};
|
|
138
138
|
updateQuery._id = new ObjectId( requestData.processedcheckListId );
|
|
139
139
|
updateQuery.userId = req.user._id;
|
|
140
|
-
|
|
140
|
+
if ( getBeforeChecklist?.[0]?.date_string == dayjs().format( 'YYYY-MM-DD' ) ) {
|
|
141
|
+
updateQuery.date_string = requestData.date;
|
|
142
|
+
}
|
|
141
143
|
|
|
142
144
|
if ( PCLQusestion && PCLQusestion?.questionAnswers && PCLQusestion?.questionAnswers.length > 0 ) {
|
|
143
145
|
await PCLQusestion.questionAnswers.forEach( ( section ) => {
|
|
@@ -234,15 +236,15 @@ export async function startChecklist( req, res ) {
|
|
|
234
236
|
},
|
|
235
237
|
} );
|
|
236
238
|
let getupdatedchecklist = await processedchecklist.aggregate( findQuery );
|
|
237
|
-
let bucket = JSON.parse( process.env.BUCKET );
|
|
239
|
+
// let bucket = JSON.parse( process.env.BUCKET );
|
|
238
240
|
getupdatedchecklist[0].questionAnswers.forEach( ( section ) => {
|
|
239
241
|
section.questions.forEach( async ( question ) => {
|
|
240
242
|
if ( question.questionReferenceImage && question.questionReferenceImage!='' ) {
|
|
241
|
-
question.questionReferenceImage =
|
|
243
|
+
question.questionReferenceImage = `${cdnurl.TraxAnswerCDN}${question.questionReferenceImage}`;
|
|
242
244
|
}
|
|
243
245
|
question.answers.forEach( async ( answer ) => {
|
|
244
246
|
if ( answer.referenceImage != '' ) {
|
|
245
|
-
answer.referenceImage =
|
|
247
|
+
answer.referenceImage = `${cdnurl.TraxAnswerCDN}${answer.referenceImage}`;
|
|
246
248
|
}
|
|
247
249
|
} );
|
|
248
250
|
} );
|
|
@@ -317,7 +319,7 @@ export async function startChecklist( req, res ) {
|
|
|
317
319
|
return res.sendError( 'something went wrong please try again', 500 );
|
|
318
320
|
}
|
|
319
321
|
} catch ( e ) {
|
|
320
|
-
|
|
322
|
+
console.log( 'e =>', e );
|
|
321
323
|
logger.error( { function: 'startChecklist', error: e, body: req.body } );
|
|
322
324
|
return res.sendError( e, 500 );
|
|
323
325
|
}
|
|
@@ -467,19 +469,16 @@ export async function startTask( req, res ) {
|
|
|
467
469
|
} );
|
|
468
470
|
const getUpdatedTask = await processedTask.aggregate( findQuery );
|
|
469
471
|
|
|
470
|
-
|
|
472
|
+
let cdnurl = JSON.parse( process.env.CDNURL );
|
|
471
473
|
if ( !( task.checkListFrom && task.checkListFrom == 'api' ) ) {
|
|
472
|
-
const bucket = JSON.parse( process.env.BUCKET );
|
|
474
|
+
// const bucket = JSON.parse( process.env.BUCKET );
|
|
473
475
|
await Promise.all(
|
|
474
476
|
getUpdatedTask[0].questionAnswers.map( ( section ) =>
|
|
475
477
|
section.questions.map( async ( question ) => {
|
|
476
478
|
if ( question.questionReferenceImage.length > 0 ) {
|
|
477
479
|
question.questionReferenceImage = await Promise.all(
|
|
478
480
|
question.questionReferenceImage.map( async ( image ) => {
|
|
479
|
-
return
|
|
480
|
-
Bucket: bucket.sop,
|
|
481
|
-
file_path: decodeURIComponent( image ),
|
|
482
|
-
} );
|
|
481
|
+
return `${cdnurl.TraxAnswerCDN}${image}`;
|
|
483
482
|
} ),
|
|
484
483
|
);
|
|
485
484
|
}
|
|
@@ -489,10 +488,7 @@ export async function startTask( req, res ) {
|
|
|
489
488
|
if ( answer.referenceImage.length > 0 ) {
|
|
490
489
|
answer.referenceImage = await Promise.all(
|
|
491
490
|
answer.referenceImage.map( async ( image ) => {
|
|
492
|
-
return
|
|
493
|
-
Bucket: bucket.sop,
|
|
494
|
-
file_path: decodeURIComponent( image ),
|
|
495
|
-
} );
|
|
491
|
+
return `${cdnurl.TraxAnswerCDN}${image}`;
|
|
496
492
|
} ),
|
|
497
493
|
);
|
|
498
494
|
}
|
|
@@ -667,12 +663,12 @@ export async function sopMobilechecklistQuestionValidatorv1( req, res, next ) {
|
|
|
667
663
|
let sectionQuestion = requestSection.filter( ( secQuestion ) => secQuestion.qname == question.oldQname || secQuestion.qname == question.qname );
|
|
668
664
|
if ( sectionQuestion.length ) {
|
|
669
665
|
if ( requestData.submittype == 'submit' ) {
|
|
670
|
-
if ( ( [ 'multipleImage', 'multiplechoicemultiple' ].includes( question.answerType ) || ( question.answerType =='dropdown' && question.allowMultiple ) ) ) {
|
|
666
|
+
if ( ( [ 'multipleImage', 'multiplechoicemultiple', 'image/video' ].includes( question.answerType ) || ( question.answerType =='dropdown' && question.allowMultiple ) ) ) {
|
|
671
667
|
if ( ( !sectionQuestion[0].linkType || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled ) ) && ( sectionQuestion[0].Multianswer == null || sectionQuestion[0].Multianswer == '' || !sectionQuestion[0].Multianswer.length ) ) {
|
|
672
668
|
validationCount++;
|
|
673
669
|
}
|
|
674
670
|
} else {
|
|
675
|
-
if ( ( !
|
|
671
|
+
if ( ( !sectionQuestion[0].linkType && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) ) {
|
|
676
672
|
validationCount++;
|
|
677
673
|
}
|
|
678
674
|
}
|
|
@@ -1088,12 +1084,15 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1088
1084
|
try {
|
|
1089
1085
|
let requestData = req.body;
|
|
1090
1086
|
requestData.questionAnswers = typeof requestData.questionAnswers == 'string' ? JSON.parse( requestData.questionAnswers ) : requestData.questionAnswers;
|
|
1091
|
-
let getChecklistQA = await processedchecklist.findOne( { _id: new ObjectId( requestData.processedcheckListId ) }, { questionAnswers: 1 } );
|
|
1087
|
+
let getChecklistQA = await processedchecklist.findOne( { _id: new ObjectId( requestData.processedcheckListId ) }, { questionAnswers: 1, redoEdit: 1 } );
|
|
1092
1088
|
let reqAnswers = requestData.questionAnswers;
|
|
1093
1089
|
logger.error( { functionName: 'updatedPayload', message: reqAnswers } );
|
|
1094
1090
|
let CLQAnswers = getChecklistQA.questionAnswers;
|
|
1095
1091
|
|
|
1096
1092
|
if ( requestData.submittype == 'submit' ) {
|
|
1093
|
+
if ( getChecklistQA?.redoEdit ) {
|
|
1094
|
+
requestData.submittype = 'draft';
|
|
1095
|
+
}
|
|
1097
1096
|
reqAnswers.forEach( ( reqA ) => {
|
|
1098
1097
|
if ( ![ 'multiplechoicemultiple', 'multipleImage', 'image/video' ].includes( reqA?.answerType ) && ( reqA.answerType == 'dropDown' && !reqA.allowMultiple ) ) {
|
|
1099
1098
|
if ( ( !reqA.linkType && ( reqA.answer == null || reqA.answer == '' ) ) || ( reqA.linkType && reqA.linkquestionenabled && ( reqA.answer == null || reqA.answer == '' ) ) ) {
|
|
@@ -1180,24 +1179,29 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1180
1179
|
if ( qaAnswers[j].answerType == 'yes/no' ) {
|
|
1181
1180
|
let qaans = qaAnswers[j].answers;
|
|
1182
1181
|
let yn = [];
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
if (
|
|
1186
|
-
if (
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
splitImgUrl.
|
|
1192
|
-
|
|
1182
|
+
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1183
|
+
for ( let k = 0; k < qaans.length; k++ ) {
|
|
1184
|
+
if ( requestSection[i].answer == qaans[k].answer ) {
|
|
1185
|
+
if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
|
|
1186
|
+
if ( requestSection[i].validationAnswer ) {
|
|
1187
|
+
let validateAns = decodeURIComponent( requestSection[i].validationAnswer.split( '?' )[0] );
|
|
1188
|
+
if ( validateAns.length ) {
|
|
1189
|
+
let splitImgUrl = validateAns.split( '/' );
|
|
1190
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1191
|
+
splitImgUrl.splice( 0, 3 );
|
|
1192
|
+
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1193
|
+
}
|
|
1193
1194
|
}
|
|
1194
1195
|
}
|
|
1196
|
+
} else {
|
|
1197
|
+
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1198
|
+
qaans[k].validationAnswer = requestSection[i].validationAnswer || '';
|
|
1195
1199
|
}
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1200
|
+
if ( requestSection[i]?.runAIData && requestSection[i]?.runAIData?.length ) {
|
|
1201
|
+
qaans[k].runAIData = requestSection[i].runAIData;
|
|
1202
|
+
}
|
|
1203
|
+
yn.push( qaans[k] );
|
|
1199
1204
|
}
|
|
1200
|
-
yn.push( qaans[k] );
|
|
1201
1205
|
}
|
|
1202
1206
|
}
|
|
1203
1207
|
let structure = {};
|
|
@@ -1237,39 +1241,44 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1237
1241
|
} else if ( qaAnswers[j].answerType == 'multiplechoicesingle' || ( qaAnswers[j].answerType == 'dropdown' && !qaAnswers[j].allowMultiple ) ) {
|
|
1238
1242
|
let qaans = qaAnswers[j].answers;
|
|
1239
1243
|
let ms = [];
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
if (
|
|
1243
|
-
if (
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
splitImgUrl.
|
|
1249
|
-
|
|
1244
|
+
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1245
|
+
for ( let k = 0; k < qaans.length; k++ ) {
|
|
1246
|
+
if ( requestSection[i].answer == qaans[k].answer ) {
|
|
1247
|
+
if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
|
|
1248
|
+
if ( requestSection[i].validationAnswer ) {
|
|
1249
|
+
let validationAnswer = decodeURIComponent( requestSection[i].validationAnswer.split( '?' )[0] );
|
|
1250
|
+
if ( validationAnswer.length ) {
|
|
1251
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1252
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1253
|
+
splitImgUrl.splice( 0, 3 );
|
|
1254
|
+
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1255
|
+
}
|
|
1250
1256
|
}
|
|
1251
1257
|
}
|
|
1252
|
-
}
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1258
|
+
} else {
|
|
1259
|
+
if ( qaans[k].validationType == 'Capture Multiple Image with description' ) {
|
|
1260
|
+
qaans[k]['validationImage']=[];
|
|
1261
|
+
if ( requestSection[i].validationImage.length ) {
|
|
1262
|
+
for ( let image of requestSection[i].validationImage ) {
|
|
1263
|
+
let validationAnswer = decodeURIComponent( image.split( '?' )[0] );
|
|
1264
|
+
if ( validationAnswer.length ) {
|
|
1265
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1266
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1267
|
+
splitImgUrl.splice( 0, 3 );
|
|
1268
|
+
qaans[k].validationImage.push( splitImgUrl.join( '/' ) || '' );
|
|
1269
|
+
}
|
|
1270
|
+
};
|
|
1271
|
+
}
|
|
1266
1272
|
}
|
|
1267
1273
|
}
|
|
1274
|
+
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1275
|
+
qaans[k].validationAnswer = requestSection[i].validationAnswer || '';
|
|
1268
1276
|
}
|
|
1269
|
-
|
|
1270
|
-
|
|
1277
|
+
if ( requestSection[i]?.runAIData && requestSection[i]?.runAIData?.length ) {
|
|
1278
|
+
qaans[k].runAIData = requestSection[i].runAIData;
|
|
1279
|
+
}
|
|
1280
|
+
ms.push( qaans[k] );
|
|
1271
1281
|
}
|
|
1272
|
-
ms.push( qaans[k] );
|
|
1273
1282
|
}
|
|
1274
1283
|
}
|
|
1275
1284
|
let structure = {};
|
|
@@ -1310,30 +1319,42 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1310
1319
|
} else if ( qaAnswers[j].answerType == 'multiplechoicemultiple' || ( qaAnswers[j].answerType == 'dropdown' && qaAnswers[j].allowMultiple ) ) {
|
|
1311
1320
|
let qaans = qaAnswers[j].answers;
|
|
1312
1321
|
let mcmo = [];
|
|
1313
|
-
|
|
1314
|
-
let
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
if (
|
|
1318
|
-
if ( separatedArray[s].
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1322
|
+
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1323
|
+
for ( let k = 0; k < qaans.length; k++ ) {
|
|
1324
|
+
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
|
|
1325
|
+
for ( let s = 0; s < separatedArray.length; s++ ) {
|
|
1326
|
+
if ( ( separatedArray[s].answer == qaans[k].answer ) ) {
|
|
1327
|
+
if ( ( getChecklistQA?.redoEdit && qaans[k].redo == separatedArray[s].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1328
|
+
if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
|
|
1329
|
+
if ( separatedArray[s].validationAnswer ) {
|
|
1330
|
+
let validationAnswer = decodeURIComponent( separatedArray[s].validationAnswer.split( '?' )[0] );
|
|
1331
|
+
if ( validationAnswer.length ) {
|
|
1332
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1333
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1334
|
+
splitImgUrl.splice( 0, 3 );
|
|
1335
|
+
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1325
1338
|
}
|
|
1339
|
+
} else {
|
|
1340
|
+
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1341
|
+
qaans[k].validationAnswer = separatedArray[s].validationAnswer || '';
|
|
1342
|
+
}
|
|
1343
|
+
if ( separatedArray[s]?.runAIData && separatedArray[s]?.runAIData?.length ) {
|
|
1344
|
+
qaans[k].runAIData = separatedArray[s].runAIData;
|
|
1326
1345
|
}
|
|
1327
1346
|
}
|
|
1328
|
-
|
|
1329
|
-
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1330
|
-
qaans[k].validationAnswer = separatedArray[s].validationAnswer || '';
|
|
1347
|
+
mcmo.push( qaans[k] );
|
|
1331
1348
|
}
|
|
1332
|
-
|
|
1333
|
-
mcmo.push( qaans[k] );
|
|
1334
1349
|
}
|
|
1335
1350
|
}
|
|
1336
1351
|
}
|
|
1352
|
+
qaAnswers[j].answers.forEach( ( ele ) => {
|
|
1353
|
+
if ( typeof ele?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1354
|
+
ele.redo = false;
|
|
1355
|
+
}
|
|
1356
|
+
} );
|
|
1357
|
+
|
|
1337
1358
|
let structure = {};
|
|
1338
1359
|
structure.qno = qaAnswers[j].qno;
|
|
1339
1360
|
structure.uniqueqno = qaAnswers[j].uniqueqno;
|
|
@@ -1372,37 +1393,42 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1372
1393
|
} else if ( [ 'image/video', 'multipleImage' ].includes( qaAnswers[j].answerType ) ) {
|
|
1373
1394
|
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
|
|
1374
1395
|
let mcmi = [];
|
|
1396
|
+
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1375
1397
|
// for (let k = 0; k < qaans.length; k++) {
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1398
|
+
for ( let s = 0; s < separatedArray.length; s++ ) {
|
|
1399
|
+
if ( separatedArray[s].answer && separatedArray[s].answer !='' ) {
|
|
1400
|
+
let newAnswer = {};
|
|
1401
|
+
let validationAnswer = decodeURIComponent( separatedArray[s].answer.split( '?' )[0] );
|
|
1402
|
+
if ( validationAnswer.length ) {
|
|
1403
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1404
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1405
|
+
splitImgUrl.splice( 0, 3 );
|
|
1406
|
+
newAnswer.answer = splitImgUrl.join( '/' ) || '';
|
|
1407
|
+
}
|
|
1385
1408
|
}
|
|
1386
|
-
}
|
|
1387
1409
|
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1410
|
+
newAnswer.answeroptionNumber = 0;
|
|
1411
|
+
newAnswer.sopFlag = false;
|
|
1412
|
+
newAnswer.validation = false;
|
|
1413
|
+
newAnswer.validationType = '';
|
|
1414
|
+
newAnswer.referenceImage = '';
|
|
1415
|
+
newAnswer.allowUploadfromGallery = false;
|
|
1416
|
+
newAnswer.descriptivetype = '';
|
|
1417
|
+
newAnswer.showLinked = false;
|
|
1418
|
+
newAnswer.linkedQuestion = 0;
|
|
1419
|
+
newAnswer.nestedQuestion = [];
|
|
1420
|
+
newAnswer.index = s;
|
|
1421
|
+
newAnswer.runAI = qaAnswers[j].answers[0]?.runAI || false;
|
|
1422
|
+
newAnswer.runAIFeatures = qaAnswers[j].answers[0]?.runAIFeatures || [];
|
|
1423
|
+
newAnswer.runAIDescription = qaAnswers[j].answers[0]?.runAIDescription || '';
|
|
1424
|
+
if ( qaAnswers[j].answerType == 'image/video' ) {
|
|
1425
|
+
newAnswer.answerType = separatedArray[s].answerType;
|
|
1426
|
+
}
|
|
1427
|
+
if ( separatedArray[s]?.runAIData && separatedArray[s]?.runAIData?.length ) {
|
|
1428
|
+
newAnswer.runAIData = separatedArray[s].runAIData;
|
|
1429
|
+
}
|
|
1430
|
+
mcmi.push( newAnswer );
|
|
1404
1431
|
}
|
|
1405
|
-
mcmi.push( newAnswer );
|
|
1406
1432
|
}
|
|
1407
1433
|
}
|
|
1408
1434
|
// }
|
|
@@ -1442,71 +1468,76 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1442
1468
|
newArray.push( structure );
|
|
1443
1469
|
} else {
|
|
1444
1470
|
let des = [];
|
|
1445
|
-
if (
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
if ( validationAnswer.length ) {
|
|
1451
|
-
let splitImgUrl = validationAnswer.split( '/' );
|
|
1452
|
-
if ( splitImgUrl.length > 1 ) {
|
|
1453
|
-
splitImgUrl.splice( 0, 3 );
|
|
1454
|
-
requestSection[i].answer = splitImgUrl.join( '/' );
|
|
1471
|
+
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1472
|
+
if ( requestSection[i].answer != 'null' && requestSection[i].answer != '' && requestSection[i].answer != null ) {
|
|
1473
|
+
let validationAnswer = '';
|
|
1474
|
+
if ( requestSection[i].answer.split( '?' ).length > 1 || requestSection[i].answer.includes( 'https://' ) ) {
|
|
1475
|
+
validationAnswer = decodeURIComponent( requestSection[i].answer.split( '?' )[0] );
|
|
1455
1476
|
}
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1477
|
+
if ( validationAnswer.length ) {
|
|
1478
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1479
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1480
|
+
splitImgUrl.splice( 0, 3 );
|
|
1481
|
+
requestSection[i].answer = splitImgUrl.join( '/' );
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
let ansstructure = {
|
|
1485
|
+
answer: requestSection[i].answer,
|
|
1486
|
+
answeroptionNumber: 1,
|
|
1487
|
+
sopFlag: false,
|
|
1488
|
+
validation: false,
|
|
1489
|
+
validationType: '',
|
|
1490
|
+
validationAnswer: '',
|
|
1491
|
+
referenceImage: qaAnswers[j].answers[0].referenceImage || '',
|
|
1492
|
+
multiReferenceImage: qaAnswers[j].answers[0].multiReferenceImage || [],
|
|
1493
|
+
showLinked: qaAnswers[j].answers[0].showLinked,
|
|
1494
|
+
linkedQuestion: qaAnswers[j].answers[0].linkedQuestion,
|
|
1495
|
+
runAI: qaAnswers[j].answers[0]?.runAI || false,
|
|
1496
|
+
runAIFeatures: qaAnswers[j]?.answers[0]?.runAIFeatures || [],
|
|
1497
|
+
runAIDescription: qaAnswers[j].answers[0]?.runAIDescription || '',
|
|
1498
|
+
};
|
|
1499
|
+
if ( qaAnswers[j].answerType == 'date' ) {
|
|
1500
|
+
ansstructure.dateRangeType = requestSection[i].dateRangeType || false;
|
|
1475
1501
|
if ( qaAnswers[j].compliance ) {
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1502
|
+
if ( qaAnswers[j].compliance ) {
|
|
1503
|
+
let ansArray = requestSection[i].answer.split( ',' );
|
|
1504
|
+
if ( ansArray.includes( '-' ) ) {
|
|
1505
|
+
ansArray = requestSection[i].answer.split( '-' );
|
|
1506
|
+
}
|
|
1507
|
+
if ( ansArray.length > 1 && ansArray.some( ( date ) => dayjs( date, 'DD MMM YYYY' ).format( 'DD-MM-YYYY' ) >= qaAnswers[j]?.answers[0]?.startDate && dayjs( date, 'DD MMM YYYY' ) <= qaAnswers[j]?.answers[0]?.endDate ) ) {
|
|
1508
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1509
|
+
} else if ( ansArray.length > 1 && ( dayjs( ansArray?.[0], 'DD MMM YYYY' ).format( 'DD-MM-YYYY' ) >= qaAnswers[j]?.answers[0]?.startDate && dayjs( ansArray?.[1], 'DD MMM YYYY' ).format( 'DD-MM-YYYY' ) <= qaAnswers[j]?.answers[0]?.endDate ) ) {
|
|
1510
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1511
|
+
} else if ( dayjs( requestSection[i].answer, 'DD MMM YYYY' ) >= qaAnswers[j]?.answers[0]?.startDate && dayjs( requestSection[i].answer, 'DD MMM YYYY' ) <= qaAnswers[j]?.answers[0]?.endDate ) {
|
|
1512
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1513
|
+
} else {
|
|
1514
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1515
|
+
}
|
|
1479
1516
|
}
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
if ( qaAnswers[j].answerType == 'linearscale' ) {
|
|
1520
|
+
if ( qaAnswers[j].compliance ) {
|
|
1521
|
+
let linearAnswer = requestSection[i].answer.split( 'to' );
|
|
1522
|
+
if ( parseInt( linearAnswer?.[0] ) >= qaAnswers[j]?.answers[0]?.minValue && parseInt( linearAnswer?.[1] ) <= qaAnswers[j]?.answers[0]?.maxValue ) {
|
|
1485
1523
|
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1486
1524
|
} else {
|
|
1487
1525
|
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1488
1526
|
}
|
|
1489
1527
|
}
|
|
1528
|
+
ansstructure.linearType = qaAnswers[j]?.answers[0]?.linearType;
|
|
1529
|
+
ansstructure.matchedCount = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1530
|
+
ansstructure.notMatchedCount = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1490
1531
|
}
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
let linearAnswer = requestSection[i].answer.split( 'to' );
|
|
1495
|
-
if ( parseInt( linearAnswer?.[0] ) >= qaAnswers[j]?.answers[0]?.minValue && parseInt( linearAnswer?.[1] ) <= qaAnswers[j]?.answers[0]?.maxValue ) {
|
|
1496
|
-
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1497
|
-
} else {
|
|
1498
|
-
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1499
|
-
}
|
|
1532
|
+
if ( qaAnswers[j].answerType == 'image' ) {
|
|
1533
|
+
ansstructure.matchedCount = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1534
|
+
ansstructure.notMatchedCount = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1500
1535
|
}
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
if ( qaAnswers[j].answerType == 'image' ) {
|
|
1506
|
-
ansstructure.matchedCount = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1507
|
-
ansstructure.notMatchedCount = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1536
|
+
if ( requestSection[i]?.runAIData && requestSection[i]?.runAIData?.length ) {
|
|
1537
|
+
ansstructure.runAIData = requestSection[i].runAIData;
|
|
1538
|
+
}
|
|
1539
|
+
des.push( ansstructure );
|
|
1508
1540
|
}
|
|
1509
|
-
des.push( ansstructure );
|
|
1510
1541
|
}
|
|
1511
1542
|
let structure = {};
|
|
1512
1543
|
structure.qno = qaAnswers[j].qno;
|
|
@@ -1558,6 +1589,18 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1558
1589
|
|
|
1559
1590
|
requestData.questionAnswers = sectionFormat;
|
|
1560
1591
|
logger.error( { message: requestData.questionAnswers, error: 'QuestionanswersPayload' } );
|
|
1592
|
+
|
|
1593
|
+
if ( requestData.submittype == 'submit' ) {
|
|
1594
|
+
for ( let section of sectionFormat ) {
|
|
1595
|
+
for ( let question of section.questions ) {
|
|
1596
|
+
let mustValidate = !question.linkType || ( question.linkType && question.linkquestionenabled );
|
|
1597
|
+
if ( mustValidate && ( !question.userAnswer || !question.userAnswer.length ) ) {
|
|
1598
|
+
return res.sendError( 'Please Fill All Fields', 400 );
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1561
1604
|
next();
|
|
1562
1605
|
} catch ( error ) {
|
|
1563
1606
|
logger.error( { function: 'sopMobilechecklistMultiSectionFormatter', error: error, body: req.body } );
|
|
@@ -1938,7 +1981,7 @@ export async function sopMobileTaskMultiSectionFormatter( req, res, next ) {
|
|
|
1938
1981
|
let des = [];
|
|
1939
1982
|
if ( requestSection[i].answer != 'null' && requestSection[i].answer != '' && requestSection[i].answer != null ) {
|
|
1940
1983
|
let validationAnswer = '';
|
|
1941
|
-
if ( requestSection[i].answer.split( '?' ).length > 1 ) {
|
|
1984
|
+
if ( requestSection[i].answer.split( '?' ).length > 1 || requestSection[i].answer.includes( 'https://' ) ) {
|
|
1942
1985
|
validationAnswer = decodeURIComponent( requestSection[i].answer.split( '?' )[0] );
|
|
1943
1986
|
}
|
|
1944
1987
|
if ( validationAnswer.length ) {
|
|
@@ -2037,7 +2080,13 @@ function QuestionFlag( req, res ) {
|
|
|
2037
2080
|
|
|
2038
2081
|
async function updateRecurringFlagTracker( processedChecklist, questionAnswers, currentDateTime ) {
|
|
2039
2082
|
try {
|
|
2040
|
-
if ( !processedChecklist?.
|
|
2083
|
+
if ( !processedChecklist?.sourceCheckList_id ) return;
|
|
2084
|
+
|
|
2085
|
+
const isUserBased = processedChecklist?.coverage === 'user';
|
|
2086
|
+
const storeId = isUserBased ? '' : ( processedChecklist?.store_id || '' );
|
|
2087
|
+
const userId = isUserBased ? ( processedChecklist?.userId ? String( processedChecklist.userId ) : ( processedChecklist?.userEmail || '' ) ) : '';
|
|
2088
|
+
if ( !isUserBased && !storeId ) return;
|
|
2089
|
+
if ( isUserBased && !userId ) return;
|
|
2041
2090
|
|
|
2042
2091
|
const today = currentDateTime ? currentDateTime.format( 'YYYY-MM-DD' ) : dayjs().format( 'YYYY-MM-DD' );
|
|
2043
2092
|
const yesterday = dayjs( today, 'YYYY-MM-DD' ).subtract( 1, 'day' ).format( 'YYYY-MM-DD' );
|
|
@@ -2045,7 +2094,7 @@ async function updateRecurringFlagTracker( processedChecklist, questionAnswers,
|
|
|
2045
2094
|
const trackerKeyBase = {
|
|
2046
2095
|
client_id: processedChecklist.client_id,
|
|
2047
2096
|
sourceCheckList_id: processedChecklist.sourceCheckList_id,
|
|
2048
|
-
store_id:
|
|
2097
|
+
...( isUserBased ) ? { user_id: userId } : { store_id: storeId },
|
|
2049
2098
|
};
|
|
2050
2099
|
|
|
2051
2100
|
const existingRows = await recurringFlagTracker.find( trackerKeyBase, { section_id: 1, qno: 1, consecutiveCount: 1, lastFlaggedDate: 1 } );
|
|
@@ -2065,7 +2114,7 @@ async function updateRecurringFlagTracker( processedChecklist, questionAnswers,
|
|
|
2065
2114
|
const flaggedNow = Array.isArray( question?.userAnswer ) && question.userAnswer.some( ( a ) => a?.sopFlag === true );
|
|
2066
2115
|
const key = `${sectionId}::${qno}`;
|
|
2067
2116
|
const existing = existingMap.get( key );
|
|
2068
|
-
|
|
2117
|
+
console.log( flaggedNow, 'test' );
|
|
2069
2118
|
if ( flaggedNow ) {
|
|
2070
2119
|
let newCount;
|
|
2071
2120
|
if ( !existing ) {
|
|
@@ -2085,8 +2134,11 @@ async function updateRecurringFlagTracker( processedChecklist, questionAnswers,
|
|
|
2085
2134
|
filter: { ...trackerKeyBase, section_id: sectionId, qno },
|
|
2086
2135
|
update: {
|
|
2087
2136
|
$set: {
|
|
2137
|
+
coverage: isUserBased ? 'user' : 'store',
|
|
2088
2138
|
checkListName: processedChecklist.checkListName,
|
|
2089
|
-
storeName: processedChecklist.storeName,
|
|
2139
|
+
storeName: isUserBased ? '' : ( processedChecklist.storeName || '' ),
|
|
2140
|
+
userName: processedChecklist.userName || '',
|
|
2141
|
+
userEmail: processedChecklist.userEmail || '',
|
|
2090
2142
|
sectionName: section?.sectionName || '',
|
|
2091
2143
|
qname: question?.qname || '',
|
|
2092
2144
|
consecutiveCount: newCount,
|
|
@@ -2103,15 +2155,19 @@ async function updateRecurringFlagTracker( processedChecklist, questionAnswers,
|
|
|
2103
2155
|
ops.push( {
|
|
2104
2156
|
updateOne: {
|
|
2105
2157
|
filter: { ...trackerKeyBase, section_id: sectionId, qno },
|
|
2106
|
-
update: { $set: {
|
|
2158
|
+
update: { $set: { lastFlaggedDate: today } },
|
|
2107
2159
|
},
|
|
2108
2160
|
} );
|
|
2109
2161
|
}
|
|
2110
2162
|
} );
|
|
2111
2163
|
} );
|
|
2112
|
-
|
|
2113
2164
|
if ( ops.length ) {
|
|
2114
|
-
|
|
2165
|
+
try {
|
|
2166
|
+
let data = await recurringFlagTracker.bulkWrite( ops, { ordered: false } );
|
|
2167
|
+
console.log( 'recurringFlagTracker bulkWrite result', data );
|
|
2168
|
+
} catch ( bulkErr ) {
|
|
2169
|
+
logger.error( { function: 'updateRecurringFlagTracker.bulkWrite', code: bulkErr?.code, message: bulkErr?.message, writeErrors: bulkErr?.writeErrors } );
|
|
2170
|
+
}
|
|
2115
2171
|
}
|
|
2116
2172
|
} catch ( error ) {
|
|
2117
2173
|
logger.error( { function: 'updateRecurringFlagTracker', error } );
|
|
@@ -2165,6 +2221,9 @@ export async function submitChecklist( req, res ) {
|
|
|
2165
2221
|
let flagCount = QuestionFlag( req, res );
|
|
2166
2222
|
updateData.questionFlag = flagCount;
|
|
2167
2223
|
updateData.submitTime_string = currentDateTime.format( 'hh:mm A, DD MMM YYYY' );
|
|
2224
|
+
if ( getchecklist?.[0]?.redoEdit != undefined ) {
|
|
2225
|
+
updateData.redoEdit = false;
|
|
2226
|
+
}
|
|
2168
2227
|
if ( requestData.deviceDetails && requestData.deviceDetails != '' ) {
|
|
2169
2228
|
updateData.deviceDetails =JSON.parse( requestData.deviceDetails );
|
|
2170
2229
|
}
|
|
@@ -2253,7 +2312,10 @@ export async function submitChecklist( req, res ) {
|
|
|
2253
2312
|
// };
|
|
2254
2313
|
// await detectionService.create( detectionData );
|
|
2255
2314
|
if ( requestData.submittype == 'submit' ) {
|
|
2256
|
-
|
|
2315
|
+
console.log( checklistDetails?.recurringFlag?.notifyType?.length );
|
|
2316
|
+
if ( checklistDetails?.recurringFlag?.notifyType?.length ) {
|
|
2317
|
+
updateRecurringFlagTracker( getchecklist[0], requestData.questionAnswers, currentDateTime );
|
|
2318
|
+
}
|
|
2257
2319
|
updateOpenSearch( req.user, requestData );
|
|
2258
2320
|
let openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
2259
2321
|
// console.log( 'openSearch', openSearch );
|
|
@@ -2434,7 +2496,8 @@ export async function submitTask( req, res ) {
|
|
|
2434
2496
|
'storeResponseTime': currentDateTime.format( 'HH:mm:ss - MMM DD, YYYY' ),
|
|
2435
2497
|
'message_mode': 'retriggered',
|
|
2436
2498
|
};
|
|
2437
|
-
sendMessageToQueue( `${JSON.parse( process.env.SQS ).url}${JSON.parse( process.env.SQS ).storeHygiene}`, JSON.stringify( sqsData ) );
|
|
2499
|
+
let sqsResponse = await sendMessageToQueue( `${JSON.parse( process.env.SQS ).url}${JSON.parse( process.env.SQS ).storeHygiene}`, JSON.stringify( sqsData ) );
|
|
2500
|
+
console.log( sqsResponse );
|
|
2438
2501
|
}
|
|
2439
2502
|
if ( !excludedChecklists.includes( checklist.checkListName ) ) {
|
|
2440
2503
|
const query1 = [
|
|
@@ -2939,6 +3002,9 @@ export async function dashboardv1( req, res ) {
|
|
|
2939
3002
|
// const { store_id, date } = req.query;
|
|
2940
3003
|
const { date } = req.query;
|
|
2941
3004
|
const userId = req.user._id;
|
|
3005
|
+
let fromDate = new Date( req.query.date );
|
|
3006
|
+
let toDate = new Date( req.query.date );
|
|
3007
|
+
toDate.setDate( toDate.getDate() + 1 );
|
|
2942
3008
|
|
|
2943
3009
|
// //Get User Based Checklist //
|
|
2944
3010
|
const clientId = { client_id: req.user.clientId };
|
|
@@ -2955,7 +3021,7 @@ export async function dashboardv1( req, res ) {
|
|
|
2955
3021
|
...storeMatch,
|
|
2956
3022
|
};
|
|
2957
3023
|
const buildPipeline = ( matchExtraConditions = {} ) => [
|
|
2958
|
-
{ $match: { ...baseMatch, ...matchExtraConditions } },
|
|
3024
|
+
{ $match: { $or: [ { ...baseMatch, ...matchExtraConditions }, { $and: [ { redoStatus: true }, { scheduleStartTime_iso: { $lt: toDate } }, { scheduleEndTime_iso: { $gte: fromDate } }, { userId }, { ...storeMatch } ] } ] } },
|
|
2959
3025
|
{
|
|
2960
3026
|
$facet: {
|
|
2961
3027
|
total: [ { $count: 'total' } ],
|
|
@@ -2975,9 +3041,7 @@ export async function dashboardv1( req, res ) {
|
|
|
2975
3041
|
},
|
|
2976
3042
|
];
|
|
2977
3043
|
|
|
2978
|
-
|
|
2979
|
-
let toDate = new Date( req.query.date );
|
|
2980
|
-
toDate.setDate( toDate.getDate() + 1 );
|
|
3044
|
+
|
|
2981
3045
|
const taskBaseMatch = {
|
|
2982
3046
|
// eslint-disable-next-line camelcase
|
|
2983
3047
|
// store_id,
|
|
@@ -3026,6 +3090,8 @@ export async function dashboardv1( req, res ) {
|
|
|
3026
3090
|
processedTask.aggregate( taskQuery ),
|
|
3027
3091
|
] );
|
|
3028
3092
|
|
|
3093
|
+
console.log( checklistResult );
|
|
3094
|
+
|
|
3029
3095
|
const checklistResultData =
|
|
3030
3096
|
checklistResult.status === 'fulfilled' ?
|
|
3031
3097
|
processResult( checklistResult.value ) :
|
|
@@ -3155,6 +3221,9 @@ export async function checklistv1( req, res ) {
|
|
|
3155
3221
|
// const { store_id, date, checklistStatus, searchValue } = req.query;
|
|
3156
3222
|
const { date, checklistStatus, searchValue } = req.query;
|
|
3157
3223
|
const userId = req.user._id;
|
|
3224
|
+
let fromDate = new Date( req.query.date );
|
|
3225
|
+
let toDate = new Date( req.query.date );
|
|
3226
|
+
toDate.setDate( toDate.getDate() + 1 );
|
|
3158
3227
|
|
|
3159
3228
|
// Get User Based Checklist //
|
|
3160
3229
|
const clientId = { client_id: req.user.clientId };
|
|
@@ -3166,16 +3235,18 @@ export async function checklistv1( req, res ) {
|
|
|
3166
3235
|
// eslint-disable-next-line camelcase
|
|
3167
3236
|
// { store_id },
|
|
3168
3237
|
{ userId },
|
|
3169
|
-
{ date_string: date },
|
|
3238
|
+
{ $or: [ { date_string: date }, { $and: [ { redoStatus: true }, { scheduleEndTime_iso: { $gte: fromDate } } ] } ] },
|
|
3170
3239
|
{ timeFlagStatus: true },
|
|
3171
3240
|
...matchExtraConditions,
|
|
3172
3241
|
clientId,
|
|
3173
3242
|
storeMatch,
|
|
3174
3243
|
];
|
|
3244
|
+
|
|
3175
3245
|
if ( checklistStatus ) {
|
|
3176
3246
|
matchConditions.push( { checklistStatus } );
|
|
3177
3247
|
}
|
|
3178
3248
|
|
|
3249
|
+
|
|
3179
3250
|
const pipeline = [
|
|
3180
3251
|
{ $match: { $and: matchConditions } },
|
|
3181
3252
|
...( searchValue ?
|
|
@@ -3228,9 +3299,7 @@ export async function checklistv1( req, res ) {
|
|
|
3228
3299
|
return pipeline;
|
|
3229
3300
|
};
|
|
3230
3301
|
|
|
3231
|
-
|
|
3232
|
-
let toDate = new Date( req.query.date );
|
|
3233
|
-
toDate.setDate( toDate.getDate() + 1 );
|
|
3302
|
+
|
|
3234
3303
|
const taskBuildPipeline = ( matchExtraConditions = [], projectExtraConditions = {} ) => {
|
|
3235
3304
|
const matchConditions = [
|
|
3236
3305
|
// eslint-disable-next-line camelcase
|
|
@@ -3579,7 +3648,7 @@ export async function questionList( req, res ) {
|
|
|
3579
3648
|
return res.sendError( 'Check List Got Edited Please Fill Again', 422 );
|
|
3580
3649
|
} else {
|
|
3581
3650
|
logger.info( `v5 => Checklist Continue => store Name: ${getchecklist[0].storeName}, User Email: ${getchecklist[0].userEmail}, Checklist Name: ${getchecklist[0].checkListName}` );
|
|
3582
|
-
let bucket = JSON.parse( process.env.BUCKET );
|
|
3651
|
+
// let bucket = JSON.parse( process.env.BUCKET );
|
|
3583
3652
|
let cdnurl = JSON.parse( process.env.CDNURL );
|
|
3584
3653
|
for ( let [ secIndex, section ] of getchecklist[0].questionAnswers.entries() ) {
|
|
3585
3654
|
for ( let [ questionIndex, question ] of section.questions.entries() ) {
|
|
@@ -3605,12 +3674,12 @@ export async function questionList( req, res ) {
|
|
|
3605
3674
|
let checkvalidation = null;
|
|
3606
3675
|
if ( answer.validationAnswer && answer.validationAnswer !='' ) {
|
|
3607
3676
|
if ( answer.validationType != 'Descriptive Answer' ) {
|
|
3608
|
-
checkvalidation =
|
|
3677
|
+
checkvalidation = `${cdnurl.TraxAnswerCDN}${answer.validationAnswer}`;
|
|
3609
3678
|
} else {
|
|
3610
3679
|
checkvalidation = answer.validationAnswer;
|
|
3611
3680
|
}
|
|
3612
3681
|
}
|
|
3613
|
-
Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation } );
|
|
3682
|
+
Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation, ...( answer.redo && { redo: answer.redo } ) } );
|
|
3614
3683
|
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].index = ansIndex;
|
|
3615
3684
|
}
|
|
3616
3685
|
|
|
@@ -3626,23 +3695,23 @@ export async function questionList( req, res ) {
|
|
|
3626
3695
|
answer.referenceImage= `${cdnurl.TraxAnswerCDN}${answer.referenceImage}`;
|
|
3627
3696
|
}
|
|
3628
3697
|
if ( ( answer.validationType == 'Capture Image' || answer.validationType == 'Capture Video' ) && answer.validationAnswer && answer.validationAnswer != '' ) {
|
|
3629
|
-
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].validationAnswer =
|
|
3698
|
+
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].validationAnswer = `${cdnurl.TraxAnswerCDN}${answer.validationAnswer}`;
|
|
3630
3699
|
}
|
|
3631
3700
|
}
|
|
3632
3701
|
if ( question?.userAnswer ) {
|
|
3633
3702
|
for ( let [ userAnsIndex, userAns ] of question.userAnswer.entries() ) {
|
|
3634
3703
|
if ( ( userAns.validationType == 'Capture Image' || userAns.validationType == 'Capture Video' ) && userAns.validationAnswer && userAns.validationAnswer != '' ) {
|
|
3635
|
-
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].validationAnswer =
|
|
3704
|
+
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].validationAnswer = `${cdnurl.TraxAnswerCDN}${userAns.validationAnswer}`;
|
|
3636
3705
|
}
|
|
3637
3706
|
if ( userAns.validationType == 'Capture Multiple Image with description' ) {
|
|
3638
3707
|
let imageAnswers = userAns.validationImage;
|
|
3639
3708
|
userAns.validationImage = [];
|
|
3640
3709
|
for ( let image of imageAnswers ) {
|
|
3641
|
-
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].validationImage.push(
|
|
3710
|
+
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].validationImage.push( `${cdnurl.TraxAnswerCDN}${image}` );
|
|
3642
3711
|
}
|
|
3643
3712
|
}
|
|
3644
3713
|
if ( [ 'image', 'descriptiveImage', 'video' ].includes( question.answerType ) && userAns.answer != '' ) {
|
|
3645
|
-
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].answer
|
|
3714
|
+
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].answer =`${cdnurl.TraxAnswerCDN}${userAns.answer}`;
|
|
3646
3715
|
}
|
|
3647
3716
|
if ( userAns.referenceImage != '' ) {
|
|
3648
3717
|
// getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].referenceImage = await signedUrl( { file_path: decodeURIComponent( userAns.referenceImage ), Bucket: bucket.sop } );
|
|
@@ -3949,7 +4018,7 @@ export async function taskQuestionList( req, res ) {
|
|
|
3949
4018
|
return res.sendError( 'Task Got Edited Please Fill Again', 422 );
|
|
3950
4019
|
} else {
|
|
3951
4020
|
logger.info( `v5 => Task Continue => store Name: ${getchecklist[0].storeName}, User Email: ${getchecklist[0].userEmail}, Task Name: ${getchecklist[0].checkListName}` );
|
|
3952
|
-
let bucket = JSON.parse( process.env.BUCKET );
|
|
4021
|
+
// let bucket = JSON.parse( process.env.BUCKET );
|
|
3953
4022
|
let cdnurl = JSON.parse( process.env.CDNURL );
|
|
3954
4023
|
for ( let [ secIndex, section ] of getchecklist[0].questionAnswers.entries() ) {
|
|
3955
4024
|
for ( let [ questionIndex, question ] of section.questions.entries() ) {
|
|
@@ -3960,13 +4029,10 @@ export async function taskQuestionList( req, res ) {
|
|
|
3960
4029
|
if ( Array.isArray( questionReferenceImage ) ) {
|
|
3961
4030
|
questionReferenceImage = questionReferenceImage.filter( ( item ) => item != '' );
|
|
3962
4031
|
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].questionReferenceImage = await Promise.all(
|
|
3963
|
-
questionReferenceImage.map( async ( image ) => image ?
|
|
4032
|
+
questionReferenceImage.map( async ( image ) => image ? `${cdnurl.TraxAnswerCDN}${image}` : '' ),
|
|
3964
4033
|
);
|
|
3965
4034
|
} else if ( questionReferenceImage !== '' ) {
|
|
3966
|
-
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].questionReferenceImage =
|
|
3967
|
-
file_path: decodeURIComponent( questionReferenceImage ),
|
|
3968
|
-
Bucket: bucket.sop,
|
|
3969
|
-
} );
|
|
4035
|
+
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].questionReferenceImage = `${cdnurl.TraxAnswerCDN}${questionReferenceImage}`;
|
|
3970
4036
|
}
|
|
3971
4037
|
}
|
|
3972
4038
|
|
|
@@ -3977,13 +4043,10 @@ export async function taskQuestionList( req, res ) {
|
|
|
3977
4043
|
if ( Array.isArray( referenceImage ) ) {
|
|
3978
4044
|
referenceImage = referenceImage.filter( ( item ) => item != '' );
|
|
3979
4045
|
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].referenceImage = await Promise.all(
|
|
3980
|
-
referenceImage.map( async ( image ) => image ?
|
|
4046
|
+
referenceImage.map( async ( image ) => image ? `${cdnurl.TraxAnswerCDN}${image}` : '' ),
|
|
3981
4047
|
);
|
|
3982
4048
|
} else if ( referenceImage !== '' ) {
|
|
3983
|
-
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].referenceImage =
|
|
3984
|
-
file_path: decodeURIComponent( referenceImage ),
|
|
3985
|
-
Bucket: bucket.sop,
|
|
3986
|
-
} );
|
|
4049
|
+
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].referenceImage = `${cdnurl.TraxAnswerCDN}${referenceImage}`;
|
|
3987
4050
|
}
|
|
3988
4051
|
}
|
|
3989
4052
|
|
|
@@ -3991,7 +4054,7 @@ export async function taskQuestionList( req, res ) {
|
|
|
3991
4054
|
let checkvalidation = null;
|
|
3992
4055
|
if ( answer.validationAnswer && answer.validationAnswer != '' ) {
|
|
3993
4056
|
if ( answer.validationType != 'Descriptive Answer' ) {
|
|
3994
|
-
checkvalidation =
|
|
4057
|
+
checkvalidation = `${cdnurl.TraxAnswerCDN}${answer.validationAnswer}`;
|
|
3995
4058
|
} else {
|
|
3996
4059
|
checkvalidation = answer.validationAnswer;
|
|
3997
4060
|
}
|
|
@@ -4000,10 +4063,7 @@ export async function taskQuestionList( req, res ) {
|
|
|
4000
4063
|
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].index = ansIndex;
|
|
4001
4064
|
}
|
|
4002
4065
|
if ( ( answer.validationType == 'Capture Image' || answer.validationType == 'Capture Video' ) && answer.validationAnswer && answer.validationAnswer != '' ) {
|
|
4003
|
-
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].validationAnswer =
|
|
4004
|
-
file_path: decodeURIComponent( answer.validationAnswer ),
|
|
4005
|
-
Bucket: bucket.sop,
|
|
4006
|
-
} );
|
|
4066
|
+
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].validationAnswer = `${cdnurl.TraxAnswerCDN}${answer.validationAnswer}`;
|
|
4007
4067
|
}
|
|
4008
4068
|
}
|
|
4009
4069
|
|
|
@@ -4014,25 +4074,16 @@ export async function taskQuestionList( req, res ) {
|
|
|
4014
4074
|
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].linearType = question.answers[0].linearType;
|
|
4015
4075
|
}
|
|
4016
4076
|
if ( ( userAns.validationType == 'Capture Image' || userAns.validationType == 'Capture Video' ) && userAns.validationAnswer && userAns.validationAnswer != '' ) {
|
|
4017
|
-
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].validationAnswer =
|
|
4018
|
-
file_path: decodeURIComponent( userAns.validationAnswer ),
|
|
4019
|
-
Bucket: bucket.sop,
|
|
4020
|
-
} );
|
|
4077
|
+
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].validationAnswer = `${cdnurl.TraxAnswerCDN}${userAns.validationAnswer}`;
|
|
4021
4078
|
}
|
|
4022
4079
|
if ( [ 'image', 'descriptiveImage', 'video' ].includes( question.answerType ) && rawAnswer != '' ) {
|
|
4023
|
-
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].answer =
|
|
4024
|
-
file_path: decodeURIComponent( rawAnswer ),
|
|
4025
|
-
Bucket: bucket.sop,
|
|
4026
|
-
} );
|
|
4080
|
+
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].answer = `${cdnurl.TraxAnswerCDN}${rawAnswer}`;
|
|
4027
4081
|
}
|
|
4028
4082
|
if ( question.answerType == 'image/video' && rawAnswer != '' ) {
|
|
4029
4083
|
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].answer = `${cdnurl.TraxAnswerCDN}${rawAnswer}`;
|
|
4030
4084
|
}
|
|
4031
4085
|
if ( userAns.referenceImage != '' ) {
|
|
4032
|
-
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].referenceImage =
|
|
4033
|
-
file_path: decodeURIComponent( userAns.referenceImage ),
|
|
4034
|
-
Bucket: bucket.sop,
|
|
4035
|
-
} );
|
|
4086
|
+
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].referenceImage = `${cdnurl.TraxAnswerCDN}${userAns.referenceImage}`;
|
|
4036
4087
|
}
|
|
4037
4088
|
if ( question.answerType == 'multiplechoicemultiple' || ( question.answerType == 'dropdown' && question.allowMultiple ) ) {
|
|
4038
4089
|
let ansIndex = Multianswer.findIndex( ( item ) => item.answer == rawAnswer );
|