tango-app-api-trax 3.5.0-alpha-3 → 3.5.1-alpha-1

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.5.0-alpha-3",
3
+ "version": "3.5.1-alpha-1",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -591,47 +591,47 @@ export async function sopMobilechecklistQuestionValidatorv1( req, res, next ) {
591
591
  return res.sendError( 'Please Fill all Required Fields', 400 );
592
592
  }
593
593
 
594
- if ( requestData.submittype == 'submit' ) {
595
- let reqAnswers = requestData.questionAnswers;
596
- logger.error( { functionName: 'payload', message: reqAnswers } );
597
- let CLQAnswers = getChecklistQA.questionAnswers;
598
- logger.error( { functionName: 'CLQAnswers', message: CLQAnswers } );
599
- let validationCount= 0;
600
- let errorCount = 0;
601
- CLQAnswers.forEach( ( section ) => {
602
- let requestSection = reqAnswers.filter( ( reqSection ) => reqSection.sectionName == section?.sectionOldName || reqSection.sectionName == section?.sectionName );
603
- if ( requestSection.length ) {
604
- requestSection.forEach( ( item ) => item.section_id = section.section_id );
605
- section.questions.forEach( ( question ) => {
606
- // question.answers.forEach( ( answer ) => {
607
- let sectionQuestion = requestSection.filter( ( secQuestion ) => secQuestion.qname == question.oldQname || secQuestion.qname == question.qname );
608
- if ( sectionQuestion.length ) {
609
- if ( question.answerType == 'multiplechoicemultiple' && ( sectionQuestion[0].Multianswer == null || sectionQuestion[0].Multianswer == '' || !sectionQuestion[0].Multianswer.length ) ) {
594
+ // if ( requestData.submittype == 'submit' ) {
595
+ let reqAnswers = requestData.questionAnswers;
596
+ logger.error( { functionName: 'payload', message: reqAnswers } );
597
+ let CLQAnswers = getChecklistQA.questionAnswers;
598
+ logger.error( { functionName: 'CLQAnswers', message: CLQAnswers } );
599
+ let validationCount= 0;
600
+ let errorCount = 0;
601
+ CLQAnswers.forEach( ( section ) => {
602
+ let requestSection = reqAnswers.filter( ( reqSection ) => reqSection.sectionName == section?.sectionOldName || reqSection.sectionName == section?.sectionName );
603
+ if ( requestSection.length ) {
604
+ requestSection.forEach( ( item ) => item.section_id = section.section_id );
605
+ section.questions.forEach( ( question ) => {
606
+ // question.answers.forEach( ( answer ) => {
607
+ let sectionQuestion = requestSection.filter( ( secQuestion ) => secQuestion.qname == question.oldQname || secQuestion.qname == question.qname );
608
+ if ( sectionQuestion.length ) {
609
+ if ( question.answerType == 'multiplechoicemultiple' && ( sectionQuestion[0].Multianswer == null || sectionQuestion[0].Multianswer == '' || !sectionQuestion[0].Multianswer.length ) ) {
610
+ validationCount++;
611
+ } else {
612
+ 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 == '' ) ) ) ) {
610
613
  validationCount++;
611
- } else {
612
- 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 == '' ) ) ) ) {
613
- validationCount++;
614
- }
615
614
  }
616
- } else {
617
- errorCount++;
618
615
  }
619
- // } );
620
- } );
621
- } else {
622
- errorCount++;
623
- }
624
- } );
625
- if ( validationCount ) {
626
- return res.sendError( 'Please Fill all Required Fields', 400 );
627
- } else if ( errorCount ) {
628
- return res.sendError( 'Checklist got edited.please contact admin', 400 );
616
+ } else {
617
+ errorCount++;
618
+ }
619
+ // } );
620
+ } );
629
621
  } else {
630
- next();
622
+ errorCount++;
631
623
  }
624
+ } );
625
+ if ( validationCount && requestData.submittype == 'submit' ) {
626
+ return res.sendError( 'Please Fill all Required Fields', 400 );
627
+ } else if ( errorCount ) {
628
+ return res.sendError( 'Checklist got edited.please contact admin', 400 );
632
629
  } else {
633
630
  next();
634
631
  }
632
+ // } else {
633
+ // next();
634
+ // }
635
635
  } catch ( e ) {
636
636
  logger.error( { function: 'sopMobilechecklistQuestionValidator', error: e, body: req.body } );
637
637
  return res.sendError( e, 500 );
@@ -3720,7 +3720,18 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
3720
3720
  date_iso: insertdata.date_iso,
3721
3721
  client_id: insertdata.client_id,
3722
3722
  checkListId: updatedchecklist._id,
3723
- checklistStatus: 'inprogress',
3723
+ // checklistStatus: 'inprogress',
3724
+ $or: [
3725
+ {
3726
+ $and: [
3727
+ { checklistStatus: 'open' },
3728
+ { redoStatus: true },
3729
+ ],
3730
+ },
3731
+ {
3732
+ checklistStatus: 'inprogress',
3733
+ },
3734
+ ],
3724
3735
  }, { userId: 1, store_id: 1 } );
3725
3736
 
3726
3737
  if ( inprogressData.length ) {
@@ -3739,7 +3750,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
3739
3750
  }
3740
3751
 
3741
3752
  if ( deletedList.length ) {
3742
- await processedchecklist.deleteMany( { date_string: insertdata.date_string, date_iso: insertdata.date_iso, client_id: insertdata.client_id, checkListId: updatedchecklist._id, _id: { $in: deletedList } } );
3753
+ 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 } );
3743
3754
  }
3744
3755
  await processedchecklist.insertMany( assignUserList );
3745
3756
  actionType = 'insertAssignUsers';