tango-app-api-trax 3.6.0-sec-8 → 3.6.0-sec-10
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
|
@@ -295,6 +295,13 @@ export async function PCLconfigCreation( req, res ) {
|
|
|
295
295
|
isdeleted: false,
|
|
296
296
|
},
|
|
297
297
|
} );
|
|
298
|
+
|
|
299
|
+
sectionQuery.push( {
|
|
300
|
+
$sort: {
|
|
301
|
+
sectionNumber: 1,
|
|
302
|
+
},
|
|
303
|
+
} );
|
|
304
|
+
|
|
298
305
|
let getSections = await CLquestions.aggregate( sectionQuery );
|
|
299
306
|
if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in' ].includes( getCLconfig.checkListType ) ) {
|
|
300
307
|
if ( getSections.length ) {
|
|
@@ -302,7 +309,9 @@ export async function PCLconfigCreation( req, res ) {
|
|
|
302
309
|
let collectQuestions = {};
|
|
303
310
|
collectQuestions.section_id = element3._id;
|
|
304
311
|
collectQuestions.sectionName = element3.section;
|
|
312
|
+
collectQuestions.sectionOldName = element3.sectionOldName || '';
|
|
305
313
|
collectQuestions.questions = element3.question;
|
|
314
|
+
collectQuestions.sectionNumber = element3.sectionNumber|| '';
|
|
306
315
|
collectSections.push( collectQuestions );
|
|
307
316
|
}
|
|
308
317
|
}
|
|
@@ -611,47 +611,47 @@ export async function sopMobilechecklistQuestionValidatorv1( req, res, next ) {
|
|
|
611
611
|
return res.sendError( 'Please Fill all Required Fields', 400 );
|
|
612
612
|
}
|
|
613
613
|
|
|
614
|
-
if ( requestData.submittype == 'submit' ) {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
614
|
+
// if ( requestData.submittype == 'submit' ) {
|
|
615
|
+
let reqAnswers = requestData.questionAnswers;
|
|
616
|
+
logger.error( { functionName: 'payload', message: reqAnswers } );
|
|
617
|
+
let CLQAnswers = getChecklistQA.questionAnswers;
|
|
618
|
+
logger.error( { functionName: 'CLQAnswers', message: CLQAnswers } );
|
|
619
|
+
let validationCount= 0;
|
|
620
|
+
let errorCount = 0;
|
|
621
|
+
CLQAnswers.forEach( ( section ) => {
|
|
622
|
+
let requestSection = reqAnswers.filter( ( reqSection ) => reqSection.sectionName == section?.sectionOldName || reqSection.sectionName == section?.sectionName );
|
|
623
|
+
if ( requestSection.length ) {
|
|
624
|
+
requestSection.forEach( ( item ) => item.section_id = section.section_id );
|
|
625
|
+
section.questions.forEach( ( question ) => {
|
|
626
|
+
// question.answers.forEach( ( answer ) => {
|
|
627
|
+
let sectionQuestion = requestSection.filter( ( secQuestion ) => secQuestion.qname == question.oldQname || secQuestion.qname == question.qname );
|
|
628
|
+
if ( sectionQuestion.length ) {
|
|
629
|
+
if ( question.answerType == 'multiplechoicemultiple' && ( sectionQuestion[0].Multianswer == null || sectionQuestion[0].Multianswer == '' || !sectionQuestion[0].Multianswer.length ) ) {
|
|
630
|
+
validationCount++;
|
|
631
|
+
} else {
|
|
632
|
+
if ( ![ 'multiplechoicemultiple', 'multipleImage' ].includes( question.answerType ) && ( ( !sectionQuestion[0].linkType && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) ) ) {
|
|
630
633
|
validationCount++;
|
|
631
|
-
} else {
|
|
632
|
-
if ( ![ 'multiplechoicemultiple', 'multipleImage' ].includes( question.answerType ) && ( ( !sectionQuestion[0].linkType && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) ) ) {
|
|
633
|
-
validationCount++;
|
|
634
|
-
}
|
|
635
634
|
}
|
|
636
|
-
} else {
|
|
637
|
-
errorCount++;
|
|
638
635
|
}
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
}
|
|
644
|
-
} );
|
|
645
|
-
if ( validationCount ) {
|
|
646
|
-
return res.sendError( 'Please Fill all Required Fields', 400 );
|
|
647
|
-
} else if ( errorCount ) {
|
|
648
|
-
return res.sendError( 'Checklist got edited.please contact admin', 400 );
|
|
636
|
+
} else {
|
|
637
|
+
errorCount++;
|
|
638
|
+
}
|
|
639
|
+
// } );
|
|
640
|
+
} );
|
|
649
641
|
} else {
|
|
650
|
-
|
|
642
|
+
errorCount++;
|
|
651
643
|
}
|
|
644
|
+
} );
|
|
645
|
+
if ( validationCount && requestData.submittype == 'submit' ) {
|
|
646
|
+
return res.sendError( 'Please Fill all Required Fields', 400 );
|
|
647
|
+
} else if ( errorCount && !requestData?.editSubmit ) {
|
|
648
|
+
return res.sendError( 'Checklist got edited.please contact admin', 400 );
|
|
652
649
|
} else {
|
|
653
650
|
next();
|
|
654
651
|
}
|
|
652
|
+
// } else {
|
|
653
|
+
// next();
|
|
654
|
+
// }
|
|
655
655
|
} catch ( e ) {
|
|
656
656
|
logger.error( { function: 'sopMobilechecklistQuestionValidator', error: e, body: req.body } );
|
|
657
657
|
return res.sendError( e, 500 );
|
|
@@ -2969,6 +2969,11 @@ export async function insertSingleProcessData( checklistId, processId = 0, oldDa
|
|
|
2969
2969
|
isdeleted: false,
|
|
2970
2970
|
},
|
|
2971
2971
|
} );
|
|
2972
|
+
sectionQuery.push( {
|
|
2973
|
+
$sort: {
|
|
2974
|
+
sectionNumber: 1,
|
|
2975
|
+
},
|
|
2976
|
+
} );
|
|
2972
2977
|
let getSections = await questionService.aggregate( sectionQuery );
|
|
2973
2978
|
if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection' ].includes( getCLconfig.checkListType ) ) {
|
|
2974
2979
|
if ( getSections.length ) {
|
|
@@ -2978,6 +2983,7 @@ export async function insertSingleProcessData( checklistId, processId = 0, oldDa
|
|
|
2978
2983
|
collectQuestions.sectionName = element3.section;
|
|
2979
2984
|
collectQuestions.sectionOldName = element3.sectionOldName;
|
|
2980
2985
|
collectQuestions.questions = element3.question;
|
|
2986
|
+
collectQuestions.sectionNumber = element3.sectionNumber || 0;
|
|
2981
2987
|
collectSections.push( collectQuestions );
|
|
2982
2988
|
}
|
|
2983
2989
|
}
|
|
@@ -3719,7 +3725,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3719
3725
|
await processedchecklist.deleteMany( { date_string: insertdata.date_string,
|
|
3720
3726
|
date_iso: insertdata.date_iso,
|
|
3721
3727
|
client_id: insertdata.client_id,
|
|
3722
|
-
checkListId: updatedchecklist._id, checklistStatus: 'open' } );
|
|
3728
|
+
checkListId: updatedchecklist._id, checklistStatus: 'open', redoStatus: false } );
|
|
3723
3729
|
|
|
3724
3730
|
|
|
3725
3731
|
let actionType = 'deleteOpenUsers';
|
|
@@ -3733,7 +3739,18 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3733
3739
|
date_iso: insertdata.date_iso,
|
|
3734
3740
|
client_id: insertdata.client_id,
|
|
3735
3741
|
checkListId: updatedchecklist._id,
|
|
3736
|
-
checklistStatus: 'inprogress',
|
|
3742
|
+
// checklistStatus: 'inprogress',
|
|
3743
|
+
$or: [
|
|
3744
|
+
{
|
|
3745
|
+
$and: [
|
|
3746
|
+
{ checklistStatus: 'open' },
|
|
3747
|
+
{ redoStatus: true },
|
|
3748
|
+
],
|
|
3749
|
+
},
|
|
3750
|
+
{
|
|
3751
|
+
checklistStatus: 'inprogress',
|
|
3752
|
+
},
|
|
3753
|
+
],
|
|
3737
3754
|
}, { userId: 1, store_id: 1 } );
|
|
3738
3755
|
|
|
3739
3756
|
if ( inprogressData.length ) {
|
|
@@ -3752,7 +3769,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3752
3769
|
}
|
|
3753
3770
|
|
|
3754
3771
|
if ( deletedList.length ) {
|
|
3755
|
-
await processedchecklist.deleteMany( { date_string: insertdata.date_string, date_iso: insertdata.date_iso, client_id: insertdata.client_id, checkListId: updatedchecklist._id, _id: { $in: deletedList } } );
|
|
3772
|
+
await processedchecklist.deleteMany( { date_string: insertdata.date_string, date_iso: insertdata.date_iso, client_id: insertdata.client_id, checkListId: updatedchecklist._id, _id: { $in: deletedList }, redoStatus: false } );
|
|
3756
3773
|
}
|
|
3757
3774
|
await processedchecklist.insertMany( assignUserList );
|
|
3758
3775
|
actionType = 'insertAssignUsers';
|