tango-app-api-trax 3.4.1-alpha-12 → 3.4.1-alpha-14
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
|
@@ -245,10 +245,10 @@ export async function startChecklist( req, res ) {
|
|
|
245
245
|
for ( let [ index, data ] of getchecklist.entries() ) {
|
|
246
246
|
for ( let [ secIndex, section ] of data.questionAnswers.entries() ) {
|
|
247
247
|
questions = [];
|
|
248
|
-
for ( let question of section.questions ) {
|
|
248
|
+
for ( let [ questionIdx, question ] of section.questions.entries() ) {
|
|
249
249
|
let linkedQuestions;
|
|
250
250
|
if ( !question.linkType ) {
|
|
251
|
-
question.uniqueNo = parseInt( getOtp() );
|
|
251
|
+
question.uniqueNo = parseInt( getOtp() )+ Date.now() + questionIdx;
|
|
252
252
|
questions.push( question );
|
|
253
253
|
linkedQuestions = [];
|
|
254
254
|
let questionList = new Map( section.questions.map( ( ele ) => [ ele.qno, ele ] ) );
|
|
@@ -259,7 +259,7 @@ export async function startChecklist( req, res ) {
|
|
|
259
259
|
answer.nestedQuestion.forEach( ( qn, qidx ) => {
|
|
260
260
|
let getQn = questionList.get( qn );
|
|
261
261
|
if ( getQn ) {
|
|
262
|
-
let randomNo = parseInt( getOtp() );
|
|
262
|
+
let randomNo = parseInt( getOtp() ) + Date.now() + qidx;
|
|
263
263
|
getQn = JSON.parse( JSON.stringify( getQn ) );
|
|
264
264
|
getQn = { ...getQn, uniqueNo: randomNo };
|
|
265
265
|
nesedQuestion.push( getQn );
|
|
@@ -2759,13 +2759,13 @@ export async function questionList( req, res ) {
|
|
|
2759
2759
|
for ( let [ index, data ] of getchecklist.entries() ) {
|
|
2760
2760
|
for ( let [ secIndex, section ] of data.questionAnswers.entries() ) {
|
|
2761
2761
|
questions = [];
|
|
2762
|
-
for ( let question of section.questions ) {
|
|
2762
|
+
for ( let [ questionIndex, question ] of section.questions.entries() ) {
|
|
2763
2763
|
let linkedQuestions;
|
|
2764
2764
|
let uniqueShow = false;
|
|
2765
2765
|
if ( !question.linkType ) {
|
|
2766
2766
|
if ( !question?.uniqueNo ) {
|
|
2767
2767
|
uniqueShow = true;
|
|
2768
|
-
question.uniqueNo = parseInt( getOtp() );
|
|
2768
|
+
question.uniqueNo = parseInt( getOtp() ) + Date.now() + questionIndex;
|
|
2769
2769
|
}
|
|
2770
2770
|
questions.push( question );
|
|
2771
2771
|
linkedQuestions = [];
|
|
@@ -2780,13 +2780,13 @@ export async function questionList( req, res ) {
|
|
|
2780
2780
|
question.answers.forEach( ( answer ) => {
|
|
2781
2781
|
if ( answer.linkedQuestion ) {
|
|
2782
2782
|
let nesedQuestion = [];
|
|
2783
|
-
answer.oldNestedQuestion = JSON.parse( JSON.stringify( answer.nestedQuestion ) );
|
|
2783
|
+
answer.oldNestedQuestion = !uniqueShow ? JSON.parse( JSON.stringify( answer.oldNestedQuestion ) ) : JSON.parse( JSON.stringify( answer.nestedQuestion ) );
|
|
2784
2784
|
answer.nestedQuestion.forEach( ( qn, qidx ) => {
|
|
2785
2785
|
let getQn = questionList.get( qn );
|
|
2786
2786
|
if ( getQn ) {
|
|
2787
2787
|
let randomNo;
|
|
2788
|
-
if ( !getQn?.uniqueNo ) {
|
|
2789
|
-
randomNo = parseInt( getOtp() );
|
|
2788
|
+
if ( !getQn?.uniqueNo || uniqueShow ) {
|
|
2789
|
+
randomNo = parseInt( getOtp() ) + Date.now() + qidx;
|
|
2790
2790
|
} else {
|
|
2791
2791
|
randomNo = getQn?.uniqueNo;
|
|
2792
2792
|
}
|
|
@@ -2804,7 +2804,7 @@ export async function questionList( req, res ) {
|
|
|
2804
2804
|
let nestedLinkqn = [];
|
|
2805
2805
|
ele.answers.forEach( ( ans ) => {
|
|
2806
2806
|
if ( ans.linkedQuestion ) {
|
|
2807
|
-
ans.oldNestedQuestion = JSON.parse( JSON.stringify( ans.nestedQuestion ) );
|
|
2807
|
+
ans.oldNestedQuestion = !uniqueShow ? JSON.parse( JSON.stringify( ans.oldNestedQuestion ) ) : JSON.parse( JSON.stringify( ans.nestedQuestion ) );
|
|
2808
2808
|
ans.nestedQuestion.forEach( ( nested, idx ) => {
|
|
2809
2809
|
let findRandom = nesedQuestion.find( ( qn ) => ( uniqueShow ? qn.qno == nested : qn.uniqueNo == nested ) && !nestedLinkqn.includes( qn.uniqueNo ) && !qn.updated );
|
|
2810
2810
|
if ( findRandom ) {
|
|
@@ -3184,7 +3184,6 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3184
3184
|
delete data.parentanswer;
|
|
3185
3185
|
delete data.remarks;
|
|
3186
3186
|
delete data.linkquestionenabled;
|
|
3187
|
-
let uniqueNo = data.uniqueNo;
|
|
3188
3187
|
delete data.uniqueNo;
|
|
3189
3188
|
if ( data.descriptivetype == null ) {
|
|
3190
3189
|
delete data.descriptivetype;
|
|
@@ -3207,25 +3206,69 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3207
3206
|
logger.info( 'compare =>', compare );
|
|
3208
3207
|
logger.info( 'qno =>', data.qno );
|
|
3209
3208
|
modifiedCount++;
|
|
3210
|
-
question.push( qns );
|
|
3209
|
+
question.push( { question: qns, type: 'qnEdit' } );
|
|
3211
3210
|
} else {
|
|
3212
|
-
getsubmitDetails[0].questionAnswers[index].questions[findQuestion].qname
|
|
3213
|
-
|
|
3214
|
-
|
|
3211
|
+
if ( getsubmitDetails[0].questionAnswers[index].questions[findQuestion].qname != qns.qname ) {
|
|
3212
|
+
question.push( { type: 'nameChange', question: qns } );
|
|
3213
|
+
}
|
|
3214
|
+
// getsubmitDetails[0].questionAnswers[index].questions[findQuestion].qname = qns.qname;
|
|
3215
3215
|
}
|
|
3216
3216
|
} else {
|
|
3217
3217
|
modifiedCount++;
|
|
3218
|
-
question.push( qns );
|
|
3218
|
+
question.push( { question: qns, type: 'add' } );
|
|
3219
3219
|
}
|
|
3220
3220
|
} );
|
|
3221
|
-
getsubmitDetails[0].questionAnswers[index].questions = question;
|
|
3222
|
-
sectionList.push(
|
|
3221
|
+
// getsubmitDetails[0].questionAnswers[index].questions = question;
|
|
3222
|
+
sectionList.push( { sectionName: section.sectionName, oldName: section.sectionOldName, question: question, type: 'edit' } );
|
|
3223
3223
|
} else {
|
|
3224
3224
|
modifiedCount++;
|
|
3225
|
-
sectionList.push( section );
|
|
3225
|
+
sectionList.push( { sectionName: section?.sectionName, oldName: section?.sectionOldName, question: section.questions, type: 'add' } );
|
|
3226
3226
|
}
|
|
3227
3227
|
}
|
|
3228
|
-
|
|
3228
|
+
console.log( JSON.stringify( sectionList ) );
|
|
3229
|
+
// getsubmitDetails[0].questionAnswers = sectionList;
|
|
3230
|
+
sectionList.forEach( ( sec ) => {
|
|
3231
|
+
if ( sec.type == 'add' ) {
|
|
3232
|
+
getsubmitDetails[0].questionAnswers.push( sec );
|
|
3233
|
+
} else {
|
|
3234
|
+
sec.question.forEach( ( qn ) => {
|
|
3235
|
+
console.log( qn, 'qn' );
|
|
3236
|
+
let sectionDetails = getsubmitDetails[0].questionAnswers.findIndex( ( section ) => section.sectionName == sec?.oldName || section.sectionName == sec.sectionName );
|
|
3237
|
+
console.log( sectionDetails, 'detauls' );
|
|
3238
|
+
if ( qn.type == 'add' ) {
|
|
3239
|
+
getsubmitDetails[0].questionAnswers[sectionDetails].questions.push( qn.question );
|
|
3240
|
+
} else {
|
|
3241
|
+
let questions = getsubmitDetails[0].questionAnswers[sectionDetails].questions.reduce( ( acc, ele, idx ) => {
|
|
3242
|
+
if ( ele.qname.trim() == qn?.question?.oldQname?.trim() || ele.qname.trim() == qn.question.qname.trim() ) {
|
|
3243
|
+
acc.push( idx );
|
|
3244
|
+
}
|
|
3245
|
+
return acc;
|
|
3246
|
+
}, [] );
|
|
3247
|
+
console.log( questions, 'question' );
|
|
3248
|
+
if ( questions.length && [ 'qnEdit', 'nameChange' ].includes( qn.type ) ) {
|
|
3249
|
+
if ( qn.type == 'qnEdit' ) {
|
|
3250
|
+
let checkLinkType = getsubmitDetails[0].questionAnswers[sectionDetails].questions[questions[0]].linkType;
|
|
3251
|
+
if ( checkLinkType && !qn.question.linkType ) {
|
|
3252
|
+
questions.forEach( ( qnIdx, index ) => {
|
|
3253
|
+
if ( index != 0 ) {
|
|
3254
|
+
getsubmitDetails[0].questionAnswers[sectionDetails].questions[questions[0]].splice( qnIdx, 1 );
|
|
3255
|
+
}
|
|
3256
|
+
} );
|
|
3257
|
+
questions = [ questions[0] ];
|
|
3258
|
+
}
|
|
3259
|
+
}
|
|
3260
|
+
questions.forEach( ( qnIdx ) => {
|
|
3261
|
+
if ( qn.type == 'qnEdit' ) {
|
|
3262
|
+
getsubmitDetails[0].questionAnswers[sectionDetails].questions[qnIdx] = qn.question;
|
|
3263
|
+
} else {
|
|
3264
|
+
getsubmitDetails[0].questionAnswers[sectionDetails].questions[qnIdx].qname = qn.question.qname;
|
|
3265
|
+
}
|
|
3266
|
+
} );
|
|
3267
|
+
}
|
|
3268
|
+
}
|
|
3269
|
+
} );
|
|
3270
|
+
}
|
|
3271
|
+
} );
|
|
3229
3272
|
if ( modifiedCount ) {
|
|
3230
3273
|
getsubmitDetails[0].checklistStatus = 'inprogress';
|
|
3231
3274
|
getsubmitDetails[0].date_string = dayjs( currentdate ).format( 'YYYY-MM-DD' );
|
|
@@ -3234,6 +3277,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3234
3277
|
getsubmitDetails[0].approvalStatus = false;
|
|
3235
3278
|
}
|
|
3236
3279
|
let data = { ...getsubmitDetails[0]._doc };
|
|
3280
|
+
console.log( JSON.stringify( data ), 'data' );
|
|
3237
3281
|
await processedchecklist.updateOne( { _id: getsubmitDetails[0]._id }, data );
|
|
3238
3282
|
if ( editSubmit && getsubmitDetails[0].checklistStatus == 'submit' ) {
|
|
3239
3283
|
let user = {
|