tango-app-api-trax 3.4.1-alpha-9 → 3.4.1-alpha-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
|
@@ -206,20 +206,7 @@ export async function startChecklist( req, res ) {
|
|
|
206
206
|
} );
|
|
207
207
|
let getupdatedchecklist = await processedchecklist.aggregate( findQuery );
|
|
208
208
|
// let bucket = JSON.parse( process.env.BUCKET );
|
|
209
|
-
|
|
210
|
-
section.questions.forEach( async ( question ) => {
|
|
211
|
-
if ( question.questionReferenceImage && question.questionReferenceImage!='' ) {
|
|
212
|
-
question.questionReferenceImage = JSON.parse( process.env.CDNURL )?.TraxAnswerCDN + question.questionReferenceImage;
|
|
213
|
-
// question.questionReferenceImage = await signedUrl( { Bucket: bucket.sop, file_path: decodeURIComponent( question.questionReferenceImage ) } );
|
|
214
|
-
}
|
|
215
|
-
question.answers.forEach( async ( answer ) => {
|
|
216
|
-
if ( answer.referenceImage != '' ) {
|
|
217
|
-
answer.referenceImage = JSON.parse( process.env.CDNURL )?.TraxAnswerCDN + answer.referenceImage;
|
|
218
|
-
// answer.referenceImage = await signedUrl( { Bucket: bucket.sop, file_path: decodeURIComponent( answer.referenceImage ) } );
|
|
219
|
-
}
|
|
220
|
-
} );
|
|
221
|
-
} );
|
|
222
|
-
} );
|
|
209
|
+
|
|
223
210
|
let logInsertData = {
|
|
224
211
|
store_id: getBeforeChecklist[0]?.store_id || '',
|
|
225
212
|
storeName: getBeforeChecklist[0]?.storeName || '',
|
|
@@ -268,6 +255,7 @@ export async function startChecklist( req, res ) {
|
|
|
268
255
|
question.answers.forEach( ( answer ) => {
|
|
269
256
|
if ( answer.linkedQuestion ) {
|
|
270
257
|
let nesedQuestion = [];
|
|
258
|
+
answer.oldNestedQuestion = JSON.parse( JSON.stringify( answer.nestedQuestion ) );
|
|
271
259
|
answer.nestedQuestion.forEach( ( qn, qidx ) => {
|
|
272
260
|
let getQn = questionList.get( qn );
|
|
273
261
|
if ( getQn ) {
|
|
@@ -276,6 +264,7 @@ export async function startChecklist( req, res ) {
|
|
|
276
264
|
getQn = { ...getQn, uniqueNo: randomNo };
|
|
277
265
|
nesedQuestion.push( getQn );
|
|
278
266
|
if ( answer.linkedQuestion == getQn.qno ) {
|
|
267
|
+
answer.oldLinkedQuestion = answer.linkedQuestion;
|
|
279
268
|
answer.linkedQuestion = randomNo;
|
|
280
269
|
}
|
|
281
270
|
answer.nestedQuestion[qidx] = randomNo;
|
|
@@ -285,10 +274,12 @@ export async function startChecklist( req, res ) {
|
|
|
285
274
|
let nestedLinkqn = [];
|
|
286
275
|
ele.answers.forEach( ( ans ) => {
|
|
287
276
|
if ( ans.linkedQuestion ) {
|
|
277
|
+
ans.oldNestedQuestion = JSON.parse( JSON.stringify( ans.nestedQuestion ) );
|
|
288
278
|
ans.nestedQuestion.forEach( ( nested, idx ) => {
|
|
289
279
|
let findRandom = nesedQuestion.find( ( qn ) => qn.qno == nested && !nestedLinkqn.includes( qn.uniqueNo ) && !qn.updated );
|
|
290
280
|
if ( findRandom ) {
|
|
291
281
|
if ( ans.linkedQuestion == findRandom.qno ) {
|
|
282
|
+
ans.oldLinkedQuestion = ans.linkedQuestion;
|
|
292
283
|
ans.linkedQuestion = findRandom.uniqueNo;
|
|
293
284
|
}
|
|
294
285
|
ans.nestedQuestion[idx] = findRandom.uniqueNo;
|
|
@@ -310,6 +301,20 @@ export async function startChecklist( req, res ) {
|
|
|
310
301
|
}
|
|
311
302
|
}
|
|
312
303
|
await processedchecklist.updateOne( updateQuery, { questionAnswers: getchecklist[0].questionAnswers } );
|
|
304
|
+
getupdatedchecklist[0].questionAnswers.forEach( ( section ) => {
|
|
305
|
+
section.questions.forEach( async ( question ) => {
|
|
306
|
+
if ( question.questionReferenceImage && question.questionReferenceImage!='' ) {
|
|
307
|
+
question.questionReferenceImage = JSON.parse( process.env.CDNURL )?.TraxAnswerCDN + question.questionReferenceImage;
|
|
308
|
+
// question.questionReferenceImage = await signedUrl( { Bucket: bucket.sop, file_path: decodeURIComponent( question.questionReferenceImage ) } );
|
|
309
|
+
}
|
|
310
|
+
question.answers.forEach( async ( answer ) => {
|
|
311
|
+
if ( answer.referenceImage != '' ) {
|
|
312
|
+
answer.referenceImage = JSON.parse( process.env.CDNURL )?.TraxAnswerCDN + answer.referenceImage;
|
|
313
|
+
// answer.referenceImage = await signedUrl( { Bucket: bucket.sop, file_path: decodeURIComponent( answer.referenceImage ) } );
|
|
314
|
+
}
|
|
315
|
+
} );
|
|
316
|
+
} );
|
|
317
|
+
} );
|
|
313
318
|
return res.sendSuccess( getchecklist );
|
|
314
319
|
} else {
|
|
315
320
|
return res.sendError( 'something went wrong please try again', 500 );
|
|
@@ -2756,14 +2761,16 @@ export async function questionList( req, res ) {
|
|
|
2756
2761
|
questions = [];
|
|
2757
2762
|
for ( let question of section.questions ) {
|
|
2758
2763
|
let linkedQuestions;
|
|
2764
|
+
let uniqueShow = false;
|
|
2759
2765
|
if ( !question.linkType ) {
|
|
2760
2766
|
if ( !question?.uniqueNo ) {
|
|
2767
|
+
uniqueShow = true;
|
|
2761
2768
|
question.uniqueNo = parseInt( getOtp() );
|
|
2762
2769
|
}
|
|
2763
2770
|
questions.push( question );
|
|
2764
2771
|
linkedQuestions = [];
|
|
2765
2772
|
let questionList;
|
|
2766
|
-
if (
|
|
2773
|
+
if ( uniqueShow ) {
|
|
2767
2774
|
questionList = new Map( section.questions.map( ( ele ) => [ ele.qno, ele ] ) );
|
|
2768
2775
|
} else {
|
|
2769
2776
|
let uniqueList = question.answers.flatMap( ( ele ) => ele.nestedQuestion );
|
|
@@ -2796,7 +2803,7 @@ export async function questionList( req, res ) {
|
|
|
2796
2803
|
ele.answers.forEach( ( ans ) => {
|
|
2797
2804
|
if ( ans.linkedQuestion ) {
|
|
2798
2805
|
ans.nestedQuestion.forEach( ( nested, idx ) => {
|
|
2799
|
-
let findRandom = nesedQuestion.find( ( qn ) => (
|
|
2806
|
+
let findRandom = nesedQuestion.find( ( qn ) => ( uniqueShow ? qn.qno == nested : qn.uniqueNo == nested ) && !nestedLinkqn.includes( qn.uniqueNo ) && !qn.updated );
|
|
2800
2807
|
if ( findRandom ) {
|
|
2801
2808
|
if ( ans.linkedQuestion == findRandom.qno ) {
|
|
2802
2809
|
ans.linkedQuestion = findRandom.uniqueNo;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { fileUpload, chunkArray, logger, sendPushNotification } from 'tango-app-api-middleware';
|
|
2
2
|
import * as checklistService from '../services/checklist.service.js';
|
|
3
3
|
import * as questionService from '../services/checklistQuestion.service.js';
|
|
4
4
|
import * as assignedService from '../services/checklistAssign.service.js';
|
|
@@ -361,23 +361,23 @@ export const getConfigDetails = async ( req, res ) => {
|
|
|
361
361
|
let questionDetails = await questionService.find( query );
|
|
362
362
|
if ( questionDetails.length ) {
|
|
363
363
|
let sections = [];
|
|
364
|
-
let bucket = JSON.parse( process.env.BUCKET );
|
|
364
|
+
// let bucket = JSON.parse( process.env.BUCKET );
|
|
365
365
|
questionDetails.forEach( ( item ) => {
|
|
366
366
|
item.question.forEach( async ( question ) => {
|
|
367
367
|
if ( question.questionReferenceImage && question.questionReferenceImage !='' ) {
|
|
368
|
-
let inputData = {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
};
|
|
372
|
-
question.questionReferenceImage =
|
|
368
|
+
// let inputData = {
|
|
369
|
+
// Bucket: bucket.sop,
|
|
370
|
+
// file_path: decodeURIComponent( question.questionReferenceImage ),
|
|
371
|
+
// };
|
|
372
|
+
question.questionReferenceImage = JSON.parse( process.env.CDNURL )?.TraxAnswerCDN+question.questionReferenceImage;
|
|
373
373
|
}
|
|
374
374
|
question.answers.forEach( async ( answer ) => {
|
|
375
375
|
if ( answer.referenceImage != '' ) {
|
|
376
|
-
let inputData = {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
};
|
|
380
|
-
answer.referenceImage =
|
|
376
|
+
// let inputData = {
|
|
377
|
+
// Bucket: bucket.sop,
|
|
378
|
+
// file_path: decodeURIComponent( answer.referenceImage ),
|
|
379
|
+
// };
|
|
380
|
+
answer.referenceImage = JSON.parse( process.env.CDNURL )?.TraxAnswerCDN+answer.referenceImage;
|
|
381
381
|
}
|
|
382
382
|
} );
|
|
383
383
|
} );
|
|
@@ -862,11 +862,11 @@ export const uploadImage = async ( req, res ) => {
|
|
|
862
862
|
};
|
|
863
863
|
imgUrl = await fileUpload( params );
|
|
864
864
|
|
|
865
|
-
let inputData = {
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
};
|
|
869
|
-
imgUrl =
|
|
865
|
+
// let inputData = {
|
|
866
|
+
// Bucket: bucket.sop,
|
|
867
|
+
// file_path: imgUrl.Key,
|
|
868
|
+
// };
|
|
869
|
+
imgUrl = JSON.parse( process.env.CDNURL )?.TraxAnswerCDN+imgUrl.Key;
|
|
870
870
|
if ( !imgUrl ) {
|
|
871
871
|
return res.sendError( { message: 'Something went Wrong' }, 500 );
|
|
872
872
|
}
|
|
@@ -1468,10 +1468,12 @@ export const updateConfigurev1 =async ( req, res ) => {
|
|
|
1468
1468
|
if ( !checklistDetails ) {
|
|
1469
1469
|
return res.sendError( 'no data found', 204 );
|
|
1470
1470
|
}
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1471
|
+
let currentDate;
|
|
1472
|
+
if ( inputBody.timeZone ) {
|
|
1473
|
+
currentDate = dayjs().tz( inputBody.timeZone ).format();
|
|
1474
|
+
} else {
|
|
1475
|
+
currentDate = dayjs().format();
|
|
1476
|
+
}
|
|
1475
1477
|
let updatedscheduleEndTimeISO = dayjs.utc( inputBody?.checkListDetails?.scheduleEndTime, 'hh:mm A' ).format( 'HH:mm:ss' );
|
|
1476
1478
|
let newUpdatedDate = dayjs.utc( updatedscheduleEndTimeISO, 'HH:mm:ss' ).format();
|
|
1477
1479
|
|
|
@@ -3182,6 +3184,8 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3182
3184
|
delete data.parentanswer;
|
|
3183
3185
|
delete data.remarks;
|
|
3184
3186
|
delete data.linkquestionenabled;
|
|
3187
|
+
let uniqueNo = data.uniqueNo;
|
|
3188
|
+
delete data.uniqueNo;
|
|
3185
3189
|
if ( data.descriptivetype == null ) {
|
|
3186
3190
|
delete data.descriptivetype;
|
|
3187
3191
|
}
|
|
@@ -3193,14 +3197,20 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3193
3197
|
delete ans.index;
|
|
3194
3198
|
delete ans.validationAnswer;
|
|
3195
3199
|
delete ans.answeroptionNumber;
|
|
3200
|
+
ans.nestedQuestion = ans?.oldNestedQuestion ? ans.oldNestedQuestion : [];
|
|
3201
|
+
ans.linkedQuestion = ans?.oldLinkedQuestion ? ans.oldLinkedQuestion : 0;
|
|
3202
|
+
delete ans.oldNestedQuestion;
|
|
3203
|
+
delete ans.oldLinkedQuestion;
|
|
3196
3204
|
} );
|
|
3197
3205
|
const compare = findDifferences( data, qns );
|
|
3198
3206
|
if ( compare?.answerType || compare?.answers || compare?.linkType ) {
|
|
3199
3207
|
logger.info( 'compare =>', compare );
|
|
3208
|
+
logger.info( 'qno =>', data.qno );
|
|
3200
3209
|
modifiedCount++;
|
|
3201
3210
|
question.push( qns );
|
|
3202
3211
|
} else {
|
|
3203
3212
|
getsubmitDetails[0].questionAnswers[index].questions[findQuestion].qname = qns.qname;
|
|
3213
|
+
getsubmitDetails[0].questionAnswers[index].questions[findQuestion].uniqueNo = uniqueNo;
|
|
3204
3214
|
question.push( getsubmitDetails[0].questionAnswers[index].questions[findQuestion] );
|
|
3205
3215
|
}
|
|
3206
3216
|
} else {
|
|
@@ -3623,7 +3633,12 @@ export const selectAssign = async ( req, res ) => {
|
|
|
3623
3633
|
// //Select Store and cluster
|
|
3624
3634
|
if ( requestData.assignType == 'store' ) {
|
|
3625
3635
|
let storeQuery = [
|
|
3626
|
-
{
|
|
3636
|
+
{
|
|
3637
|
+
$match: {
|
|
3638
|
+
...( req.user.userType==='client'&&req.user.role!='superadmin' ) ? { storeId: { $in: requestData?.assignedStores } } :{ clientId: requestData.clientId },
|
|
3639
|
+
status: 'active',
|
|
3640
|
+
},
|
|
3641
|
+
},
|
|
3627
3642
|
{
|
|
3628
3643
|
$project: {
|
|
3629
3644
|
storeName: 1,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
|
-
import { isAllowedSessionHandler, validate, accessVerification, isAllowedClient } from 'tango-app-api-middleware';
|
|
2
|
+
import { isAllowedSessionHandler, validate, accessVerification, isAllowedClient, getAssinedStore } from 'tango-app-api-middleware';
|
|
3
3
|
import { checklistValidation, checklistDetailsValidation, runaiValidation, checklistPageSchema, duplicateValidation, updateChecklistValidation, uploadUserValidation, aichecklistValidation, publishValidation, selectAssign } from '../dtos/validation.dtos.js';
|
|
4
4
|
import * as traxController from '../controllers/trax.controller.js';
|
|
5
5
|
|
|
@@ -25,7 +25,7 @@ traxRouter
|
|
|
25
25
|
.get( '/zoneList', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ ] } ] } ), traxController.zoneList )
|
|
26
26
|
.get( '/aichecklist', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ ] } ] } ), validate( aichecklistValidation ), traxController.aiChecklist )
|
|
27
27
|
.get( '/predefinedChecklist', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ ] } ] } ), validate( aichecklistValidation ), traxController.preDefinedChecklist )
|
|
28
|
-
.post( '/selectAssign', validate( selectAssign ), traxController.selectAssign )
|
|
28
|
+
.post( '/selectAssign', isAllowedSessionHandler, validate( selectAssign ), getAssinedStore, traxController.selectAssign )
|
|
29
29
|
.post( '/assign', isAllowedSessionHandler, traxController.checklistAssign )
|
|
30
30
|
// .post( '/assignUpload', isAllowedSessionHandler, traxController.assignChecklistUser )
|
|
31
31
|
.post( '/updateAssign', isAllowedSessionHandler, traxController.updateAssign );
|