tango-app-api-trax 3.8.29 → 3.8.30
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-trax",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.30",
|
|
4
4
|
"description": "Trax",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"nodemon": "^3.1.4",
|
|
30
30
|
"path": "^0.12.7",
|
|
31
31
|
"puppeteer": "^24.39.1",
|
|
32
|
-
"tango-api-schema": "^2.5.
|
|
32
|
+
"tango-api-schema": "^2.5.92",
|
|
33
33
|
"tango-app-api-middleware": "^3.5.2",
|
|
34
34
|
"url": "^0.11.4",
|
|
35
35
|
"winston": "^3.13.1",
|
|
@@ -451,37 +451,83 @@ export async function redoChecklist( req, res ) {
|
|
|
451
451
|
let findQuestion = question[sectionIndex].questions.findIndex( ( ele ) => ele.qno == req.body.payload.qno );
|
|
452
452
|
|
|
453
453
|
let data = { ...question[sectionIndex].questions[findQuestion], redo: true, redoComment: req.body.payload?.checklistDescription || '' };
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
454
|
+
let answerIndex = req.body.payload?.answerIndex;
|
|
455
|
+
let isSingleAnswerRedo = answerIndex != null;
|
|
456
|
+
|
|
457
|
+
if ( !isSingleAnswerRedo ) {
|
|
458
|
+
// if ( checklistDetails.client_id == '458' ) {
|
|
459
|
+
data.answers.forEach( ( item ) => {
|
|
460
|
+
if ( item.showLinked ) {
|
|
461
|
+
item.nestedQuestion.forEach( ( ele ) => {
|
|
462
|
+
let eleIndex = question[sectionIndex].questions.findIndex( ( qn ) => qn.qno == parseInt( ele ) );
|
|
463
|
+
let element = { ...question[sectionIndex].questions[eleIndex], redo: true, redoComment: '', linkquestionenabled: false };
|
|
464
|
+
question[sectionIndex].questions[eleIndex] = element;
|
|
465
|
+
question[sectionIndex].questions[eleIndex].userAnswer = [];
|
|
466
|
+
question[sectionIndex].questions[eleIndex].remarks = '';
|
|
467
|
+
} );
|
|
468
|
+
}
|
|
469
|
+
} );
|
|
470
|
+
// data.answers.forEach( ( item ) => {
|
|
471
|
+
// if ( item.showLinked ) {
|
|
472
|
+
// item.nestedQuestion = [];
|
|
473
|
+
// item.showLinked = false;
|
|
474
|
+
// item.linkedQuestion = 0;
|
|
475
|
+
// }
|
|
476
|
+
// } );
|
|
477
|
+
// }
|
|
478
|
+
}
|
|
479
|
+
let userAnswer = Array.isArray( data.userAnswer ) ? [ ...data.userAnswer ] : [];
|
|
480
|
+
|
|
481
|
+
question[sectionIndex].questions[findQuestion] = data;
|
|
482
|
+
if ( isSingleAnswerRedo ) {
|
|
483
|
+
let targetQuestion = question[sectionIndex].questions[findQuestion];
|
|
484
|
+
let targetUserAnswerIndex = targetQuestion.userAnswer?.findIndex( ( ele ) => ele.answer == req.body.payload.answerName );
|
|
485
|
+
let targetUserAnswer = targetQuestion.userAnswer[targetUserAnswerIndex];
|
|
486
|
+
if ( targetUserAnswer && Array.isArray( targetQuestion.answers ) ) {
|
|
487
|
+
let matchedAnsIdx = targetQuestion.answers.findIndex( ( ans ) => {
|
|
488
|
+
// if ( targetUserAnswer.no !== undefined && ans.index === targetUserAnswer.no ) return true;
|
|
489
|
+
// if ( targetUserAnswer.index !== undefined && ans.index === targetUserAnswer.index ) return true;
|
|
490
|
+
// if ( targetUserAnswer.answeroptionNumber !== undefined && ans.answeroptionNumber === targetUserAnswer.answeroptionNumber ) return true;
|
|
491
|
+
return ans.answer === targetUserAnswer.answer;
|
|
463
492
|
} );
|
|
493
|
+
if ( matchedAnsIdx !== -1 ) {
|
|
494
|
+
targetQuestion.answers[matchedAnsIdx].redo = true;
|
|
495
|
+
targetQuestion.answers[matchedAnsIdx].validationAnswer = '';
|
|
496
|
+
targetQuestion.remarks = '';
|
|
497
|
+
}
|
|
498
|
+
targetQuestion.userAnswer.splice( targetUserAnswerIndex, 1 );
|
|
464
499
|
}
|
|
465
|
-
} );
|
|
466
|
-
// data.answers.forEach( ( item ) => {
|
|
467
|
-
// if ( item.showLinked ) {
|
|
468
|
-
// item.nestedQuestion = [];
|
|
469
|
-
// item.showLinked = false;
|
|
470
|
-
// item.linkedQuestion = 0;
|
|
471
|
-
// }
|
|
472
|
-
// } );
|
|
473
|
-
// }
|
|
474
|
-
let userAnswer = data.userAnswer;
|
|
475
500
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
501
|
+
let currentQno = req.body.payload.qno;
|
|
502
|
+
let parentQIndex = -1;
|
|
503
|
+
// let parentAnsIndex = -1;
|
|
504
|
+
for ( let i = 0; i < question[sectionIndex].questions.length; i++ ) {
|
|
505
|
+
let parentAnswers = question[sectionIndex].questions[i].answers || [];
|
|
506
|
+
let foundAnsIdx = parentAnswers.findIndex( ( ans ) => Array.isArray( ans?.nestedQuestion ) && ans.nestedQuestion.some( ( ele ) => parseInt( ele ) == currentQno ) );
|
|
507
|
+
if ( foundAnsIdx !== -1 ) {
|
|
508
|
+
parentQIndex = i;
|
|
509
|
+
// parentAnsIndex = foundAnsIdx;
|
|
510
|
+
break;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
if ( parentQIndex !== -1 ) {
|
|
514
|
+
let parentQno = question[sectionIndex].questions[parentQIndex].qno;
|
|
515
|
+
question[sectionIndex].questions[findQuestion].parentQno = parentQno;
|
|
516
|
+
// question[sectionIndex].questions[findQuestion].remarks = '';
|
|
517
|
+
// question[sectionIndex].questions[parentQIndex].answers[parentAnsIndex].redo = true;
|
|
518
|
+
// question[sectionIndex].questions[parentQIndex].answers[parentAnsIndex].validationAnswer = '';
|
|
519
|
+
}
|
|
520
|
+
} else {
|
|
521
|
+
question[sectionIndex].questions[findQuestion].userAnswer = [];
|
|
522
|
+
question[sectionIndex].questions[findQuestion].remarks = '';
|
|
523
|
+
}
|
|
479
524
|
checklistDetails.questionAnswers = question;
|
|
480
525
|
let updateData = {
|
|
481
|
-
checklistStatus: 'open',
|
|
526
|
+
checklistStatus: checklistDetails.checklistStatus != 'submit' ? checklistDetails.checklistStatus : 'open',
|
|
482
527
|
redoStatus: true,
|
|
483
528
|
reinitiateStatus: true,
|
|
484
529
|
questionAnswers: question,
|
|
530
|
+
...( checklistDetails.checklistStatus != 'submit' && checklistDetails.redoStatus ) ? { redoEdit: true } : {},
|
|
485
531
|
};
|
|
486
532
|
|
|
487
533
|
let response = await processedChecklist.updateOne( { _id: req.body.payload._id }, updateData );
|
|
@@ -1082,12 +1082,15 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1082
1082
|
try {
|
|
1083
1083
|
let requestData = req.body;
|
|
1084
1084
|
requestData.questionAnswers = typeof requestData.questionAnswers == 'string' ? JSON.parse( requestData.questionAnswers ) : requestData.questionAnswers;
|
|
1085
|
-
let getChecklistQA = await processedchecklist.findOne( { _id: new ObjectId( requestData.processedcheckListId ) }, { questionAnswers: 1 } );
|
|
1085
|
+
let getChecklistQA = await processedchecklist.findOne( { _id: new ObjectId( requestData.processedcheckListId ) }, { questionAnswers: 1, redoEdit: 1 } );
|
|
1086
1086
|
let reqAnswers = requestData.questionAnswers;
|
|
1087
1087
|
logger.error( { functionName: 'updatedPayload', message: reqAnswers } );
|
|
1088
1088
|
let CLQAnswers = getChecklistQA.questionAnswers;
|
|
1089
1089
|
|
|
1090
1090
|
if ( requestData.submittype == 'submit' ) {
|
|
1091
|
+
if ( getChecklistQA?.redoEdit ) {
|
|
1092
|
+
requestData.submittype = 'draft';
|
|
1093
|
+
}
|
|
1091
1094
|
reqAnswers.forEach( ( reqA ) => {
|
|
1092
1095
|
if ( ![ 'multiplechoicemultiple', 'multipleImage', 'image/video' ].includes( reqA?.answerType ) && ( reqA.answerType == 'dropDown' && !reqA.allowMultiple ) ) {
|
|
1093
1096
|
if ( ( !reqA.linkType && ( reqA.answer == null || reqA.answer == '' ) ) || ( reqA.linkType && reqA.linkquestionenabled && ( reqA.answer == null || reqA.answer == '' ) ) ) {
|
|
@@ -1307,27 +1310,35 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1307
1310
|
for ( let k = 0; k < qaans.length; k++ ) {
|
|
1308
1311
|
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
|
|
1309
1312
|
for ( let s = 0; s < separatedArray.length; s++ ) {
|
|
1310
|
-
if ( separatedArray[s].answer == qaans[k].answer ) {
|
|
1311
|
-
if ( qaans[k].
|
|
1312
|
-
if (
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
splitImgUrl.
|
|
1318
|
-
|
|
1313
|
+
if ( ( separatedArray[s].answer == qaans[k].answer ) ) {
|
|
1314
|
+
if ( ( getChecklistQA?.redoEdit && qaans[k].redo == separatedArray[s].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1315
|
+
if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
|
|
1316
|
+
if ( separatedArray[s].validationAnswer ) {
|
|
1317
|
+
let validationAnswer = decodeURIComponent( separatedArray[s].validationAnswer.split( '?' )[0] );
|
|
1318
|
+
if ( validationAnswer.length ) {
|
|
1319
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1320
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1321
|
+
splitImgUrl.splice( 0, 3 );
|
|
1322
|
+
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1323
|
+
}
|
|
1319
1324
|
}
|
|
1320
1325
|
}
|
|
1321
|
-
}
|
|
1322
|
-
} else {
|
|
1326
|
+
} else {
|
|
1323
1327
|
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1324
|
-
|
|
1328
|
+
qaans[k].validationAnswer = separatedArray[s].validationAnswer || '';
|
|
1329
|
+
}
|
|
1325
1330
|
}
|
|
1326
1331
|
|
|
1327
1332
|
mcmo.push( qaans[k] );
|
|
1328
1333
|
}
|
|
1329
1334
|
}
|
|
1330
1335
|
}
|
|
1336
|
+
qaAnswers[j].answers.forEach( ( ele ) => {
|
|
1337
|
+
if ( typeof ele?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1338
|
+
ele.redo = false;
|
|
1339
|
+
}
|
|
1340
|
+
} );
|
|
1341
|
+
|
|
1331
1342
|
let structure = {};
|
|
1332
1343
|
structure.qno = qaAnswers[j].qno;
|
|
1333
1344
|
structure.uniqueqno = qaAnswers[j].uniqueqno;
|
|
@@ -2172,6 +2183,7 @@ export async function submitChecklist( req, res ) {
|
|
|
2172
2183
|
let flagCount = QuestionFlag( req, res );
|
|
2173
2184
|
updateData.questionFlag = flagCount;
|
|
2174
2185
|
updateData.submitTime_string = currentDateTime.format( 'hh:mm A, DD MMM YYYY' );
|
|
2186
|
+
updateData.redoEdit = false;
|
|
2175
2187
|
if ( requestData.deviceDetails && requestData.deviceDetails != '' ) {
|
|
2176
2188
|
updateData.deviceDetails =JSON.parse( requestData.deviceDetails );
|
|
2177
2189
|
}
|
|
@@ -2444,7 +2456,8 @@ export async function submitTask( req, res ) {
|
|
|
2444
2456
|
'storeResponseTime': currentDateTime.format( 'HH:mm:ss - MMM DD, YYYY' ),
|
|
2445
2457
|
'message_mode': 'retriggered',
|
|
2446
2458
|
};
|
|
2447
|
-
sendMessageToQueue( `${JSON.parse( process.env.SQS ).url}${JSON.parse( process.env.SQS ).storeHygiene}`, JSON.stringify( sqsData ) );
|
|
2459
|
+
let sqsResponse = await sendMessageToQueue( `${JSON.parse( process.env.SQS ).url}${JSON.parse( process.env.SQS ).storeHygiene}`, JSON.stringify( sqsData ) );
|
|
2460
|
+
console.log( sqsResponse );
|
|
2448
2461
|
}
|
|
2449
2462
|
if ( !excludedChecklists.includes( checklist.checkListName ) ) {
|
|
2450
2463
|
const query1 = [
|
|
@@ -3620,7 +3633,7 @@ export async function questionList( req, res ) {
|
|
|
3620
3633
|
checkvalidation = answer.validationAnswer;
|
|
3621
3634
|
}
|
|
3622
3635
|
}
|
|
3623
|
-
Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation } );
|
|
3636
|
+
Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation, ...( answer.redo && { redo: answer.redo } ) } );
|
|
3624
3637
|
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].index = ansIndex;
|
|
3625
3638
|
}
|
|
3626
3639
|
|