tango-app-api-trax 3.6.0-sec-10 → 3.6.0-sec-11
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,13 +295,11 @@ export async function PCLconfigCreation( req, res ) {
|
|
|
295
295
|
isdeleted: false,
|
|
296
296
|
},
|
|
297
297
|
} );
|
|
298
|
-
|
|
299
298
|
sectionQuery.push( {
|
|
300
299
|
$sort: {
|
|
301
300
|
sectionNumber: 1,
|
|
302
301
|
},
|
|
303
302
|
} );
|
|
304
|
-
|
|
305
303
|
let getSections = await CLquestions.aggregate( sectionQuery );
|
|
306
304
|
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 ) ) {
|
|
307
305
|
if ( getSections.length ) {
|
|
@@ -872,6 +870,11 @@ async function insertData( requestData ) {
|
|
|
872
870
|
isdeleted: false,
|
|
873
871
|
},
|
|
874
872
|
} );
|
|
873
|
+
sectionQuery.push( {
|
|
874
|
+
$sort: {
|
|
875
|
+
sectionNumber: 1,
|
|
876
|
+
},
|
|
877
|
+
} );
|
|
875
878
|
let getSections = await CLquestions.aggregate( sectionQuery );
|
|
876
879
|
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 ) ) {
|
|
877
880
|
if ( getSections.length ) {
|
|
@@ -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
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
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 == '' ) ) ) ) {
|
|
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 ) ) {
|
|
633
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 == '' ) ) ) ) {
|
|
633
|
+
validationCount++;
|
|
634
|
+
}
|
|
634
635
|
}
|
|
636
|
+
} else {
|
|
637
|
+
errorCount++;
|
|
635
638
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
}
|
|
639
|
+
// } );
|
|
640
|
+
} );
|
|
641
|
+
} else {
|
|
642
|
+
errorCount++;
|
|
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 );
|
|
641
649
|
} else {
|
|
642
|
-
|
|
650
|
+
next();
|
|
643
651
|
}
|
|
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 );
|
|
649
652
|
} else {
|
|
650
653
|
next();
|
|
651
654
|
}
|
|
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 );
|
|
@@ -402,7 +402,8 @@ export const getConfigDetails = async ( req, res ) => {
|
|
|
402
402
|
checkListId: storechecklistdetails._id,
|
|
403
403
|
isdeleted: false,
|
|
404
404
|
};
|
|
405
|
-
let
|
|
405
|
+
let sectionSort = { sectionNumber: 1 };
|
|
406
|
+
let questionDetails = await questionService.findSort( query, {}, sectionSort );
|
|
406
407
|
if ( questionDetails.length ) {
|
|
407
408
|
let sections = [];
|
|
408
409
|
let bucket = JSON.parse( process.env.BUCKET );
|
|
@@ -738,7 +739,7 @@ export const duplicateChecklist = async ( req, res ) => {
|
|
|
738
739
|
}
|
|
739
740
|
await assignedService.insertMany( users );
|
|
740
741
|
}
|
|
741
|
-
let sectionList = await questionService.
|
|
742
|
+
let sectionList = await questionService.findSort( { checkListId: checkDetails._id, client_id: req.query.clientId, isdeleted: false }, {}, { sectionNumber: 1 } );
|
|
742
743
|
if ( sectionList.length ) {
|
|
743
744
|
let sections= [];
|
|
744
745
|
for ( let i = 0; i < sectionList.length; i++ ) {
|
|
@@ -810,7 +811,7 @@ export const update = async ( req, res ) => {
|
|
|
810
811
|
return res.sendError( 'no data found', 204 );
|
|
811
812
|
}
|
|
812
813
|
|
|
813
|
-
let getExistQuestions = await questionService.
|
|
814
|
+
let getExistQuestions = await questionService.findSort( { checkListId: req.params.checklistId, client_id: req.body.clientId }, {}, { sectionNumber: 1 } );
|
|
814
815
|
|
|
815
816
|
inputBody.sections.forEach( async ( element ) => {
|
|
816
817
|
if ( !element.questions.length && inputBody.submitType == 'configure' ) {
|
|
@@ -3725,7 +3726,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3725
3726
|
await processedchecklist.deleteMany( { date_string: insertdata.date_string,
|
|
3726
3727
|
date_iso: insertdata.date_iso,
|
|
3727
3728
|
client_id: insertdata.client_id,
|
|
3728
|
-
checkListId: updatedchecklist._id, checklistStatus: 'open'
|
|
3729
|
+
checkListId: updatedchecklist._id, checklistStatus: 'open' } );
|
|
3729
3730
|
|
|
3730
3731
|
|
|
3731
3732
|
let actionType = 'deleteOpenUsers';
|
|
@@ -3739,18 +3740,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3739
3740
|
date_iso: insertdata.date_iso,
|
|
3740
3741
|
client_id: insertdata.client_id,
|
|
3741
3742
|
checkListId: updatedchecklist._id,
|
|
3742
|
-
|
|
3743
|
-
$or: [
|
|
3744
|
-
{
|
|
3745
|
-
$and: [
|
|
3746
|
-
{ checklistStatus: 'open' },
|
|
3747
|
-
{ redoStatus: true },
|
|
3748
|
-
],
|
|
3749
|
-
},
|
|
3750
|
-
{
|
|
3751
|
-
checklistStatus: 'inprogress',
|
|
3752
|
-
},
|
|
3753
|
-
],
|
|
3743
|
+
checklistStatus: 'inprogress',
|
|
3754
3744
|
}, { userId: 1, store_id: 1 } );
|
|
3755
3745
|
|
|
3756
3746
|
if ( inprogressData.length ) {
|
|
@@ -3769,7 +3759,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3769
3759
|
}
|
|
3770
3760
|
|
|
3771
3761
|
if ( deletedList.length ) {
|
|
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 }
|
|
3762
|
+
await processedchecklist.deleteMany( { date_string: insertdata.date_string, date_iso: insertdata.date_iso, client_id: insertdata.client_id, checkListId: updatedchecklist._id, _id: { $in: deletedList } } );
|
|
3773
3763
|
}
|
|
3774
3764
|
await processedchecklist.insertMany( assignUserList );
|
|
3775
3765
|
actionType = 'insertAssignUsers';
|
|
@@ -28,4 +28,8 @@ export const aggregate = async ( query = {} ) => {
|
|
|
28
28
|
return model.checklistquestionconfigModel.aggregate( query );
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
+
export const findSort = async ( query={}, field={}, sort = {} ) => {
|
|
32
|
+
return model.checklistquestionconfigModel.find( query, field ).sort( sort );
|
|
33
|
+
};
|
|
34
|
+
|
|
31
35
|
|