tango-app-api-trax 3.4.0-alpha-3 → 3.4.0-alpha-5
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
|
@@ -3205,7 +3205,9 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3205
3205
|
let findQuestion = getsubmitDetails[0].questionAnswers[index].questions.findIndex( ( ele ) => ele.qname.trim() == qns?.oldQname?.trim() || ele.qname.trim() == qns.qname.trim() );
|
|
3206
3206
|
if ( findQuestion != -1 ) {
|
|
3207
3207
|
let data = JSON.parse( JSON.stringify( getsubmitDetails[0].questionAnswers[index].questions[findQuestion] ) );
|
|
3208
|
-
getsubmitDetails[0].questionAnswers[index].questions[findQuestion].qno
|
|
3208
|
+
if ( getsubmitDetails[0].questionAnswers[index].questions[findQuestion].qno != qns.qno ) {
|
|
3209
|
+
question.push( { question: qns, type: 'noChange' } );
|
|
3210
|
+
}
|
|
3209
3211
|
delete data.userAnswer;
|
|
3210
3212
|
delete data.parentanswer;
|
|
3211
3213
|
delete data.remarks;
|
|
@@ -3246,13 +3248,44 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3246
3248
|
}
|
|
3247
3249
|
} );
|
|
3248
3250
|
// getsubmitDetails[0].questionAnswers[index].questions = question;
|
|
3249
|
-
|
|
3251
|
+
if ( question.length ) {
|
|
3252
|
+
sectionList.push( { sectionName: section.sectionName, oldName: section.sectionOldName, question: question, type: 'edit' } );
|
|
3253
|
+
}
|
|
3250
3254
|
} else {
|
|
3251
3255
|
modifiedCount++;
|
|
3252
3256
|
sectionList.push( { section: section, type: 'add' } );
|
|
3253
3257
|
}
|
|
3254
3258
|
}
|
|
3259
|
+
let removed = [];
|
|
3260
|
+
getsubmitDetails[0].questionAnswers.forEach( ( section, sectionIdx ) => {
|
|
3261
|
+
let sectionIndex = questionList.findIndex( ( sec ) => section.sectionName == sec?.sectionOldName || section.sectionName == sec.sectionName );
|
|
3262
|
+
if ( sectionIndex == -1 ) {
|
|
3263
|
+
removed.push( { section: section.sectionName, type: 'delete' } );
|
|
3264
|
+
} else {
|
|
3265
|
+
let question = [];
|
|
3266
|
+
section.questions.forEach( ( qn ) => {
|
|
3267
|
+
let questionIndex = questionList[sectionIndex].questions.findIndex( ( ele ) => qn.qname.trim() == ele?.oldQname?.trim() || qn.qname.trim() == ele.qname.trim() );
|
|
3268
|
+
if ( questionIndex == -1 ) {
|
|
3269
|
+
question.push( qn.qname );
|
|
3270
|
+
}
|
|
3271
|
+
} );
|
|
3272
|
+
if ( question.length ) {
|
|
3273
|
+
removed.push( { section: section.sectionName, question: question, type: 'qnDelete' } );
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
} );
|
|
3277
|
+
removed.forEach( ( ele ) => {
|
|
3278
|
+
if ( ele?.type == 'delete' ) {
|
|
3279
|
+
getsubmitDetails[0].questionAnswers = getsubmitDetails[0].questionAnswers.filter( ( section ) => section.sectionName != ele.section );
|
|
3280
|
+
} else {
|
|
3281
|
+
let sectionIndex = getsubmitDetails[0].questionAnswers.findIndex( ( section ) => section.sectionName == ele?.section );
|
|
3282
|
+
getsubmitDetails[0].questionAnswers[sectionIndex].questions = getsubmitDetails[0].questionAnswers[sectionIndex].questions.filter( ( qns ) => !qns.qname.includes( ele.question ) );
|
|
3283
|
+
}
|
|
3284
|
+
} );
|
|
3285
|
+
|
|
3255
3286
|
// getsubmitDetails[0].questionAnswers = sectionList;
|
|
3287
|
+
logger.info( 'removedSections =>', { data: JSON.stringify( removed ) } );
|
|
3288
|
+
logger.info( 'modifiedSections =>', { data: JSON.stringify( sectionList ) } );
|
|
3256
3289
|
sectionList.forEach( ( sec ) => {
|
|
3257
3290
|
if ( sec.type == 'add' ) {
|
|
3258
3291
|
getsubmitDetails[0].questionAnswers.push( sec.section );
|
|
@@ -3268,7 +3301,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3268
3301
|
}
|
|
3269
3302
|
return acc;
|
|
3270
3303
|
}, [] );
|
|
3271
|
-
if ( questions.length && [ 'qnEdit', 'nameChange' ].includes( qn.type ) ) {
|
|
3304
|
+
if ( questions.length && [ 'qnEdit', 'nameChange', 'noChange' ].includes( qn.type ) ) {
|
|
3272
3305
|
if ( qn.type == 'qnEdit' ) {
|
|
3273
3306
|
let checkLinkType = getsubmitDetails[0].questionAnswers[sectionDetails].questions[questions[0]].linkType;
|
|
3274
3307
|
if ( checkLinkType && !qn.question.linkType ) {
|
|
@@ -3309,7 +3342,11 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3309
3342
|
} );
|
|
3310
3343
|
getsubmitDetails[0].questionAnswers[sectionDetails].questions[qnIdx] = qn.question;
|
|
3311
3344
|
} else {
|
|
3312
|
-
|
|
3345
|
+
if ( qn.type == 'nameChange' ) {
|
|
3346
|
+
getsubmitDetails[0].questionAnswers[sectionDetails].questions[qnIdx].qname = qn.question.qname;
|
|
3347
|
+
} else {
|
|
3348
|
+
getsubmitDetails[0].questionAnswers[sectionDetails].questions[qnIdx].qno = qn.question.qno;
|
|
3349
|
+
}
|
|
3313
3350
|
}
|
|
3314
3351
|
} );
|
|
3315
3352
|
}
|
|
@@ -3325,6 +3362,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3325
3362
|
getsubmitDetails[0].approvalStatus = false;
|
|
3326
3363
|
}
|
|
3327
3364
|
let data = { ...getsubmitDetails[0]._doc };
|
|
3365
|
+
logger.info( 'modifiedData =>', { data: JSON.stringify( data ) } );
|
|
3328
3366
|
await processedchecklist.updateOne( { _id: getsubmitDetails[0]._id }, data );
|
|
3329
3367
|
if ( editSubmit && getsubmitDetails[0].checklistStatus == 'submit' ) {
|
|
3330
3368
|
let user = {
|