tango-app-api-trax 3.9.3 → 3.9.4

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.9.3",
3
+ "version": "3.9.4",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -118,7 +118,7 @@ export async function startChecklist( req, res ) {
118
118
  $and: [
119
119
  { _id: new ObjectId( requestData.processedcheckListId ) },
120
120
  { userId: req.user._id },
121
- { date_string: requestData.date },
121
+ { $or: [ { date_string: requestData.date }, { redoStatus: true } ] },
122
122
  ],
123
123
  },
124
124
  } );
@@ -137,7 +137,9 @@ export async function startChecklist( req, res ) {
137
137
  let updateQuery = {};
138
138
  updateQuery._id = new ObjectId( requestData.processedcheckListId );
139
139
  updateQuery.userId = req.user._id;
140
- updateQuery.date_string = requestData.date;
140
+ if ( getBeforeChecklist?.[0]?.date_string == dayjs().format( 'YYYY-MM-DD' ) ) {
141
+ updateQuery.date_string = requestData.date;
142
+ }
141
143
 
142
144
  if ( PCLQusestion && PCLQusestion?.questionAnswers && PCLQusestion?.questionAnswers.length > 0 ) {
143
145
  await PCLQusestion.questionAnswers.forEach( ( section ) => {
@@ -317,7 +319,7 @@ export async function startChecklist( req, res ) {
317
319
  return res.sendError( 'something went wrong please try again', 500 );
318
320
  }
319
321
  } catch ( e ) {
320
- // console.log( 'e =>', e );
322
+ console.log( 'e =>', e );
321
323
  logger.error( { function: 'startChecklist', error: e, body: req.body } );
322
324
  return res.sendError( e, 500 );
323
325
  }
@@ -661,12 +663,12 @@ export async function sopMobilechecklistQuestionValidatorv1( req, res, next ) {
661
663
  let sectionQuestion = requestSection.filter( ( secQuestion ) => secQuestion.qname == question.oldQname || secQuestion.qname == question.qname );
662
664
  if ( sectionQuestion.length ) {
663
665
  if ( requestData.submittype == 'submit' ) {
664
- if ( ( [ 'multipleImage', 'multiplechoicemultiple' ].includes( question.answerType ) || ( question.answerType =='dropdown' && question.allowMultiple ) ) ) {
666
+ if ( ( [ 'multipleImage', 'multiplechoicemultiple', 'image/video' ].includes( question.answerType ) || ( question.answerType =='dropdown' && question.allowMultiple ) ) ) {
665
667
  if ( ( !sectionQuestion[0].linkType || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled ) ) && ( sectionQuestion[0].Multianswer == null || sectionQuestion[0].Multianswer == '' || !sectionQuestion[0].Multianswer.length ) ) {
666
668
  validationCount++;
667
669
  }
668
670
  } else {
669
- if ( ( ![ 'multiplechoicemultiple', 'multipleImage' ].includes( question.answerType ) && ( question.answerType =='dropdown' && !question.allowMultiple ) ) && ( ( !sectionQuestion[0].linkType && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) ) ) {
671
+ if ( ( !sectionQuestion[0].linkType && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) ) {
670
672
  validationCount++;
671
673
  }
672
674
  }
@@ -1819,7 +1821,6 @@ export async function sopMobilechecklistMultiSectionFormatterv2( req, res, next
1819
1821
  let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
1820
1822
  for ( let s = 0; s < separatedArray.length; s++ ) {
1821
1823
  if ( ( separatedArray[s].answer == qaans[k].answer ) ) {
1822
- console.log( qaans[k].redo, separatedArray[s].redo, qaans[k].redo == separatedArray[s].redo, qaans[k].answer );
1823
1824
  if ( ( getChecklistQA?.redoEdit && qaans[k].redo == separatedArray[s].redo ) || !getChecklistQA?.redoEdit ) {
1824
1825
  if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
1825
1826
  if ( separatedArray[s].validationAnswer ) {
@@ -2723,6 +2724,9 @@ export async function submitChecklist( req, res ) {
2723
2724
  let flagCount = QuestionFlag( req, res );
2724
2725
  updateData.questionFlag = flagCount;
2725
2726
  updateData.submitTime_string = currentDateTime.format( 'hh:mm A, DD MMM YYYY' );
2727
+ if ( getchecklist?.[0]?.redoEdit != undefined ) {
2728
+ updateData.redoEdit = false;
2729
+ }
2726
2730
  if ( requestData.deviceDetails && requestData.deviceDetails != '' ) {
2727
2731
  updateData.deviceDetails =JSON.parse( requestData.deviceDetails );
2728
2732
  }
@@ -3503,6 +3507,9 @@ export async function dashboardv1( req, res ) {
3503
3507
  // const { store_id, date } = req.query;
3504
3508
  const { date } = req.query;
3505
3509
  const userId = req.user._id;
3510
+ let fromDate = new Date( req.query.date );
3511
+ let toDate = new Date( req.query.date );
3512
+ toDate.setDate( toDate.getDate() + 1 );
3506
3513
 
3507
3514
  // //Get User Based Checklist //
3508
3515
  const clientId = { client_id: req.user.clientId };
@@ -3519,7 +3526,7 @@ export async function dashboardv1( req, res ) {
3519
3526
  ...storeMatch,
3520
3527
  };
3521
3528
  const buildPipeline = ( matchExtraConditions = {} ) => [
3522
- { $match: { ...baseMatch, ...matchExtraConditions } },
3529
+ { $match: { $or: [ { ...baseMatch, ...matchExtraConditions }, { $and: [ { redoStatus: true }, { scheduleStartTime_iso: { $lt: toDate } }, { scheduleEndTime_iso: { $gte: fromDate } }, { userId }, { ...storeMatch } ] } ] } },
3523
3530
  {
3524
3531
  $facet: {
3525
3532
  total: [ { $count: 'total' } ],
@@ -3539,9 +3546,7 @@ export async function dashboardv1( req, res ) {
3539
3546
  },
3540
3547
  ];
3541
3548
 
3542
- let fromDate = new Date( req.query.date );
3543
- let toDate = new Date( req.query.date );
3544
- toDate.setDate( toDate.getDate() + 1 );
3549
+
3545
3550
  const taskBaseMatch = {
3546
3551
  // eslint-disable-next-line camelcase
3547
3552
  // store_id,
@@ -3719,6 +3724,9 @@ export async function checklistv1( req, res ) {
3719
3724
  // const { store_id, date, checklistStatus, searchValue } = req.query;
3720
3725
  const { date, checklistStatus, searchValue } = req.query;
3721
3726
  const userId = req.user._id;
3727
+ let fromDate = new Date( req.query.date );
3728
+ let toDate = new Date( req.query.date );
3729
+ toDate.setDate( toDate.getDate() + 1 );
3722
3730
 
3723
3731
  // Get User Based Checklist //
3724
3732
  const clientId = { client_id: req.user.clientId };
@@ -3730,7 +3738,7 @@ export async function checklistv1( req, res ) {
3730
3738
  // eslint-disable-next-line camelcase
3731
3739
  // { store_id },
3732
3740
  { userId },
3733
- { date_string: date },
3741
+ { $or: [ { date_string: date }, { $and: [ { redoStatus: true }, { scheduleStartTime_iso: { $lt: toDate } }, { scheduleEndTime_iso: { $gte: fromDate } } ] } ] },
3734
3742
  { timeFlagStatus: true },
3735
3743
  ...matchExtraConditions,
3736
3744
  clientId,
@@ -3792,9 +3800,7 @@ export async function checklistv1( req, res ) {
3792
3800
  return pipeline;
3793
3801
  };
3794
3802
 
3795
- let fromDate = new Date( req.query.date );
3796
- let toDate = new Date( req.query.date );
3797
- toDate.setDate( toDate.getDate() + 1 );
3803
+
3798
3804
  const taskBuildPipeline = ( matchExtraConditions = [], projectExtraConditions = {} ) => {
3799
3805
  const matchConditions = [
3800
3806
  // eslint-disable-next-line camelcase
@@ -4174,7 +4180,7 @@ export async function questionList( req, res ) {
4174
4180
  checkvalidation = answer.validationAnswer;
4175
4181
  }
4176
4182
  }
4177
- Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation } );
4183
+ Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation, ...( answer.redo && { redo: answer.redo } ) } );
4178
4184
  getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].index = ansIndex;
4179
4185
  }
4180
4186