tango-app-api-trax 3.3.1-beta-4 → 3.3.1-beta-6

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.3.1-beta-4",
3
+ "version": "3.3.1-beta-6",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -26,7 +26,7 @@
26
26
  "mongodb": "^6.8.0",
27
27
  "nodemon": "^3.1.4",
28
28
  "path": "^0.12.7",
29
- "tango-api-schema": "^2.2.32",
29
+ "tango-api-schema": "^2.2.35",
30
30
  "tango-app-api-middleware": "^3.1.50",
31
31
  "url": "^0.11.4",
32
32
  "winston": "^3.13.1",
@@ -19,6 +19,7 @@ import utc from 'dayjs/plugin/utc.js';
19
19
  import { logger } from 'tango-app-api-middleware';
20
20
  import mongoose from 'mongoose';
21
21
  import { sendPushNotification } from 'tango-app-api-middleware';
22
+ import * as planoService from '../services/planogram.service.js';
22
23
 
23
24
 
24
25
  const ObjectId = mongoose.Types.ObjectId;
@@ -416,6 +417,11 @@ async function insertData( requestData ) {
416
417
  element4.scheduleRepeatedType = getCLconfig.scheduleRepeatedType;
417
418
  element4.approvalEnable = getCLconfig.approver.length ? true : false;
418
419
  element4.remainder = getCLconfig?.remainder || [];
420
+ if ( getCLconfig?.isPlano ) {
421
+ let planoDetails = await planoService.findOne( { storeId: element4.store_id, clientId: getCLconfig.client_id }, { _id: 1 } );
422
+ element4.planoId = planoDetails?._id;
423
+ element4.isPlano = getCLconfig?.isPlano;
424
+ }
419
425
  }
420
426
  if ( userIdList.length ) {
421
427
  allQuestion = allQuestion.filter( ( item ) => typeof item._id == 'undefined' );
@@ -247,6 +247,10 @@ export async function startChecklist( req, res ) {
247
247
  questions.push( question );
248
248
  let linkedAnswer = new Set( question.answers.filter( ( ele ) => ele.showLinked ).flatMap( ( ele ) => ele.nestedQuestion ) );
249
249
  let linkedQuestion = section.questions.filter( ( qn ) => linkedAnswer.has( qn.qno ) );
250
+ linkedQuestion = JSON.parse( JSON.stringify( linkedQuestion ) );
251
+ linkedQuestion.forEach( ( linkQn ) => {
252
+ linkQn.parentQuestion = question.qno;
253
+ } );
250
254
  questions.push( ...linkedQuestion );
251
255
  }
252
256
  }
@@ -694,6 +698,7 @@ export async function sopMobilechecklistMultiSectionFormatter( req, res, next )
694
698
  structure.parentanswer = requestSection[i].parentanswer;
695
699
  structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
696
700
  structure.descriptivetype = qaAnswers[j].descriptivetype;
701
+ structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
697
702
  if ( qaAnswers[j]?.taskId ) {
698
703
  structure.taskId = qaAnswers[j]?.taskId;
699
704
  structure.task = true;
@@ -745,6 +750,7 @@ export async function sopMobilechecklistMultiSectionFormatter( req, res, next )
745
750
  structure.parentanswer = requestSection[i].parentanswer;
746
751
  structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
747
752
  structure.descriptivetype = qaAnswers[j].descriptivetype;
753
+ structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
748
754
  if ( qaAnswers[j]?.taskId ) {
749
755
  structure.taskId = qaAnswers[j]?.taskId;
750
756
  structure.task = true;
@@ -800,6 +806,7 @@ export async function sopMobilechecklistMultiSectionFormatter( req, res, next )
800
806
  structure.parentanswer = requestSection[i].parentanswer;
801
807
  structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
802
808
  structure.descriptivetype = qaAnswers[j].descriptivetype;
809
+ structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
803
810
  if ( qaAnswers[j]?.taskId ) {
804
811
  structure.taskId = qaAnswers[j]?.taskId;
805
812
  structure.task = true;
@@ -860,6 +867,7 @@ export async function sopMobilechecklistMultiSectionFormatter( req, res, next )
860
867
  structure.parentanswer = requestSection[i].parentanswer;
861
868
  structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
862
869
  structure.descriptivetype = qaAnswers[j].descriptivetype;
870
+ structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
863
871
  if ( qaAnswers[j]?.taskId ) {
864
872
  structure.taskId = qaAnswers[j]?.taskId;
865
873
  structure.task = true;
@@ -918,6 +926,7 @@ export async function sopMobilechecklistMultiSectionFormatter( req, res, next )
918
926
  structure.parentanswer = requestSection[i].parentanswer;
919
927
  structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
920
928
  structure.descriptivetype = qaAnswers[j].descriptivetype;
929
+ structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
921
930
  if ( qaAnswers[j]?.taskId ) {
922
931
  structure.taskId = qaAnswers[j]?.taskId;
923
932
  structure.task = true;
@@ -1079,6 +1088,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
1079
1088
  structure.parentanswer = requestSection[i].parentanswer;
1080
1089
  structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
1081
1090
  structure.descriptivetype = qaAnswers[j].descriptivetype;
1091
+ structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
1082
1092
  if ( qaAnswers[j]?.taskId ) {
1083
1093
  structure.taskId = qaAnswers[j]?.taskId;
1084
1094
  structure.task = true;
@@ -1130,6 +1140,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
1130
1140
  structure.parentanswer = requestSection[i].parentanswer;
1131
1141
  structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
1132
1142
  structure.descriptivetype = qaAnswers[j].descriptivetype;
1143
+ structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
1133
1144
  if ( qaAnswers[j]?.taskId ) {
1134
1145
  structure.taskId = qaAnswers[j]?.taskId;
1135
1146
  structure.task = true;
@@ -1185,6 +1196,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
1185
1196
  structure.parentanswer = requestSection[i].parentanswer;
1186
1197
  structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
1187
1198
  structure.descriptivetype = qaAnswers[j].descriptivetype;
1199
+ structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
1188
1200
  if ( qaAnswers[j]?.taskId ) {
1189
1201
  structure.taskId = qaAnswers[j]?.taskId;
1190
1202
  structure.task = true;
@@ -1245,6 +1257,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
1245
1257
  structure.parentanswer = requestSection[i].parentanswer;
1246
1258
  structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
1247
1259
  structure.descriptivetype = qaAnswers[j].descriptivetype;
1260
+ structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
1248
1261
  if ( qaAnswers[j]?.taskId ) {
1249
1262
  structure.taskId = qaAnswers[j]?.taskId;
1250
1263
  structure.task = true;
@@ -1303,6 +1316,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
1303
1316
  structure.parentanswer = requestSection[i].parentanswer;
1304
1317
  structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
1305
1318
  structure.descriptivetype = qaAnswers[j].descriptivetype;
1319
+ structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
1306
1320
  if ( qaAnswers[j]?.taskId ) {
1307
1321
  structure.taskId = qaAnswers[j]?.taskId;
1308
1322
  structure.task = true;
@@ -2331,7 +2345,7 @@ export async function checklistv1( req, res ) {
2331
2345
  const { store_id, date, checklistStatus, searchValue } = req.query;
2332
2346
  const userId = req.user._id;
2333
2347
 
2334
- const buildPipeline = ( matchExtraConditions = [], type ) => {
2348
+ const buildPipeline = ( matchExtraConditions = [], projectExtraConditions = {} ) => {
2335
2349
  const matchConditions = [
2336
2350
  // eslint-disable-next-line camelcase
2337
2351
  { store_id },
@@ -2379,6 +2393,7 @@ export async function checklistv1( req, res ) {
2379
2393
  redoStatus: { $ifNull: [ '$redoStatus', false ] },
2380
2394
  type: { $ifNull: [ '$checkListType', '' ] },
2381
2395
  priorityType: { $ifNull: [ '$priorityType', '' ] },
2396
+ ...projectExtraConditions,
2382
2397
  },
2383
2398
  },
2384
2399
  ];
@@ -2387,8 +2402,8 @@ export async function checklistv1( req, res ) {
2387
2402
  };
2388
2403
 
2389
2404
  const [ checklistResult, taskResult ] = await Promise.allSettled( [
2390
- processedchecklist.aggregate( buildPipeline( [ { checkListType: 'custom' } ], 'checklist' ) ),
2391
- processedTask.aggregate( buildPipeline( [], 'task' ) ),
2405
+ processedchecklist.aggregate( buildPipeline( [ { checkListType: 'custom' } ], { isPlano: 1, planoId: 1 } ) ),
2406
+ processedTask.aggregate( buildPipeline( [], { isPlano: 1, planoId: 1 } ) ),
2392
2407
  ] );
2393
2408
 
2394
2409
  const checklistData = checklistResult.status === 'fulfilled' ? checklistResult.value : [];
@@ -2586,7 +2601,11 @@ export async function questionList( req, res ) {
2586
2601
  if ( !question.linkType ) {
2587
2602
  questions.push( question );
2588
2603
  let linkedAnswer = new Set( question.answers.filter( ( ele ) => ele.showLinked ).flatMap( ( ele ) => ele.nestedQuestion ) );
2589
- let linkedQuestion = section.questions.filter( ( qn ) => linkedAnswer.has( qn.qno ) );
2604
+ let linkedQuestion = section.questions.filter( ( qn ) => qn?.parentQuestion ? qn?.parentQuestion == question.qno && linkedAnswer.has( qn.qno ) : linkedAnswer.has( qn.qno ) );
2605
+ linkedQuestion = JSON.parse( JSON.stringify( linkedQuestion ) );
2606
+ linkedQuestion.forEach( ( linkQn ) => {
2607
+ linkQn.parentQuestion = question.qno;
2608
+ } );
2590
2609
  questions.push( ...linkedQuestion );
2591
2610
  }
2592
2611
  }