tango-app-api-trax 3.6.0-sec-9 → 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 ) {
|
|
@@ -309,7 +307,9 @@ export async function PCLconfigCreation( req, res ) {
|
|
|
309
307
|
let collectQuestions = {};
|
|
310
308
|
collectQuestions.section_id = element3._id;
|
|
311
309
|
collectQuestions.sectionName = element3.section;
|
|
310
|
+
collectQuestions.sectionOldName = element3.sectionOldName || '';
|
|
312
311
|
collectQuestions.questions = element3.question;
|
|
312
|
+
collectQuestions.sectionNumber = element3.sectionNumber|| '';
|
|
313
313
|
collectSections.push( collectQuestions );
|
|
314
314
|
}
|
|
315
315
|
}
|
|
@@ -870,6 +870,11 @@ async function insertData( requestData ) {
|
|
|
870
870
|
isdeleted: false,
|
|
871
871
|
},
|
|
872
872
|
} );
|
|
873
|
+
sectionQuery.push( {
|
|
874
|
+
$sort: {
|
|
875
|
+
sectionNumber: 1,
|
|
876
|
+
},
|
|
877
|
+
} );
|
|
873
878
|
let getSections = await CLquestions.aggregate( sectionQuery );
|
|
874
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 ) ) {
|
|
875
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' ) {
|
|
@@ -2983,6 +2984,7 @@ export async function insertSingleProcessData( checklistId, processId = 0, oldDa
|
|
|
2983
2984
|
collectQuestions.sectionName = element3.section;
|
|
2984
2985
|
collectQuestions.sectionOldName = element3.sectionOldName;
|
|
2985
2986
|
collectQuestions.questions = element3.question;
|
|
2987
|
+
collectQuestions.sectionNumber = element3.sectionNumber || 0;
|
|
2986
2988
|
collectSections.push( collectQuestions );
|
|
2987
2989
|
}
|
|
2988
2990
|
}
|
|
@@ -3724,7 +3726,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3724
3726
|
await processedchecklist.deleteMany( { date_string: insertdata.date_string,
|
|
3725
3727
|
date_iso: insertdata.date_iso,
|
|
3726
3728
|
client_id: insertdata.client_id,
|
|
3727
|
-
checkListId: updatedchecklist._id, checklistStatus: 'open'
|
|
3729
|
+
checkListId: updatedchecklist._id, checklistStatus: 'open' } );
|
|
3728
3730
|
|
|
3729
3731
|
|
|
3730
3732
|
let actionType = 'deleteOpenUsers';
|
|
@@ -3738,18 +3740,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3738
3740
|
date_iso: insertdata.date_iso,
|
|
3739
3741
|
client_id: insertdata.client_id,
|
|
3740
3742
|
checkListId: updatedchecklist._id,
|
|
3741
|
-
|
|
3742
|
-
$or: [
|
|
3743
|
-
{
|
|
3744
|
-
$and: [
|
|
3745
|
-
{ checklistStatus: 'open' },
|
|
3746
|
-
{ redoStatus: true },
|
|
3747
|
-
],
|
|
3748
|
-
},
|
|
3749
|
-
{
|
|
3750
|
-
checklistStatus: 'inprogress',
|
|
3751
|
-
},
|
|
3752
|
-
],
|
|
3743
|
+
checklistStatus: 'inprogress',
|
|
3753
3744
|
}, { userId: 1, store_id: 1 } );
|
|
3754
3745
|
|
|
3755
3746
|
if ( inprogressData.length ) {
|
|
@@ -3768,7 +3759,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3768
3759
|
}
|
|
3769
3760
|
|
|
3770
3761
|
if ( deletedList.length ) {
|
|
3771
|
-
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 } } );
|
|
3772
3763
|
}
|
|
3773
3764
|
await processedchecklist.insertMany( assignUserList );
|
|
3774
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
|
|