tango-app-api-trax 3.7.18 → 3.7.20
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
|
@@ -169,6 +169,9 @@ export async function startChecklist( req, res ) {
|
|
|
169
169
|
currentDateTime = dayjs();
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
+
if ( getBeforeChecklist[0]?.client_id == '458' && currentDateTime <= dayjs( getBeforeChecklist?.[0]?.scheduleStartTime_iso ) ) {
|
|
173
|
+
return res.sendError( `Checklist will be start ${getBeforeChecklist?.[0]?.scheduleStartTime}`, 422 );
|
|
174
|
+
}
|
|
172
175
|
updateData.checklistStatus = 'inprogress';
|
|
173
176
|
updateData.startMobileTime = requestData?.currentTime;
|
|
174
177
|
updateData.questionAnswers = getBeforeChecklist[0]?.redoStatus ? getBeforeChecklist[0].questionAnswers : PCLQusestion.questionAnswers;
|
|
@@ -215,10 +218,6 @@ export async function startChecklist( req, res ) {
|
|
|
215
218
|
} );
|
|
216
219
|
let getupdatedchecklist = await processedchecklist.aggregate( findQuery );
|
|
217
220
|
let bucket = JSON.parse( process.env.BUCKET );
|
|
218
|
-
if ( req?.body?.section ) {
|
|
219
|
-
getupdatedchecklist[0]['sectionLength'] = getupdatedchecklist[0].questionAnswers.length;
|
|
220
|
-
getupdatedchecklist[0].questionAnswers= [ getupdatedchecklist[0].questionAnswers[0] ];
|
|
221
|
-
}
|
|
222
221
|
getupdatedchecklist[0].questionAnswers.forEach( ( section ) => {
|
|
223
222
|
section.questions.forEach( async ( question ) => {
|
|
224
223
|
if ( question.questionReferenceImage && question.questionReferenceImage!='' ) {
|
|
@@ -682,90 +681,6 @@ export async function sopMobilechecklistQuestionValidatorv1( req, res, next ) {
|
|
|
682
681
|
}
|
|
683
682
|
};
|
|
684
683
|
|
|
685
|
-
export async function sopMobilechecklistQuestionValidatorv2( req, res, next ) {
|
|
686
|
-
try {
|
|
687
|
-
let requestData = req.body;
|
|
688
|
-
|
|
689
|
-
logger.error( { function: 'CheckEmptyQA', error: requestData } );
|
|
690
|
-
|
|
691
|
-
requestData.questionAnswers = typeof requestData.questionAnswers == 'string' ? JSON.parse( requestData.questionAnswers ) : requestData.questionAnswers;
|
|
692
|
-
let getChecklistQA = await processedchecklist.findOne( { _id: new ObjectId( requestData.processedcheckListId ) }, { questionAnswers: 1, sourceCheckList_id: 1 } );
|
|
693
|
-
if ( !getChecklistQA ) {
|
|
694
|
-
return res.sendError( 'Check List Got Edited Please Fill Again', 422 );
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
if ( getChecklistQA && requestData.submittype == 'submit' ) {
|
|
698
|
-
let checkChecklistStatus = await checklistService.findOne( { _id: getChecklistQA.sourceCheckList_id }, { publish: 1 } );
|
|
699
|
-
if ( !checkChecklistStatus.publish ) {
|
|
700
|
-
return res.sendError( 'Checklist got edited.please contact admin', 400 );
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
if ( !requestData.questionAnswers.length ) {
|
|
705
|
-
return res.sendError( 'Please Fill all Required Fields', 400 );
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
if ( requestData.submittype == 'submit' ) {
|
|
709
|
-
let reqAnswers = requestData.questionAnswers;
|
|
710
|
-
logger.error( { functionName: 'payload', message: reqAnswers } );
|
|
711
|
-
let CLQAnswers = getChecklistQA.questionAnswers;
|
|
712
|
-
logger.error( { functionName: 'CLQAnswers', message: CLQAnswers } );
|
|
713
|
-
let validationCount= 0;
|
|
714
|
-
let errorCount = 0;
|
|
715
|
-
let originalSectionIndex = CLQAnswers.findIndex( ( section ) => reqAnswers[0].sectionName == section?.sectionOldName || reqAnswers[0].sectionName == section?.sectionName );
|
|
716
|
-
if ( originalSectionIndex == -1 || CLQAnswers.length != req.body.sectionLength ) {
|
|
717
|
-
errorCount++;
|
|
718
|
-
}
|
|
719
|
-
let originalSection = CLQAnswers[originalSectionIndex];
|
|
720
|
-
reqAnswers.forEach( ( reqSection ) => {
|
|
721
|
-
reqSection.section_id = originalSection.section_id;
|
|
722
|
-
} );
|
|
723
|
-
originalSection.questions.forEach( ( question ) => {
|
|
724
|
-
let sectionQuestion = reqAnswers.find( ( secQuestion ) => secQuestion.qname == question.oldQname || secQuestion.qname == question.qname );
|
|
725
|
-
if ( sectionQuestion ) {
|
|
726
|
-
if ( question.answerType == 'multiplechoicemultiple' && ( sectionQuestion.Multianswer == null || sectionQuestion.Multianswer == '' || !sectionQuestion.Multianswer.length ) ) {
|
|
727
|
-
validationCount++;
|
|
728
|
-
} else {
|
|
729
|
-
if ( ![ 'multiplechoicemultiple', 'multipleImage' ].includes( question.answerType ) && ( ( !sectionQuestion.linkType && ( sectionQuestion.answer == null || sectionQuestion.answer == '' ) ) || ( sectionQuestion.linkType && sectionQuestion.linkquestionenabled && ( sectionQuestion.answer == null || sectionQuestion.answer == '' ) ) ) ) {
|
|
730
|
-
validationCount++;
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
} else {
|
|
734
|
-
errorCount++;
|
|
735
|
-
}
|
|
736
|
-
} );
|
|
737
|
-
CLQAnswers.splice( originalSectionIndex, 1 );
|
|
738
|
-
CLQAnswers.forEach( ( section ) => {
|
|
739
|
-
section.questions.forEach( ( question ) => {
|
|
740
|
-
if ( !question.linkType || ( question.linkType && question.linkquestionenabled ) ) {
|
|
741
|
-
if ( !question?.userAnswer?.length ) {
|
|
742
|
-
validationCount++;
|
|
743
|
-
} else {
|
|
744
|
-
question.userAnswer.forEach( ( ans ) => {
|
|
745
|
-
if ( ans.answer == null || ans.answer == '' ) {
|
|
746
|
-
validationCount++;
|
|
747
|
-
}
|
|
748
|
-
} );
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
} );
|
|
752
|
-
} );
|
|
753
|
-
if ( validationCount ) {
|
|
754
|
-
return res.sendError( 'Please Fill all Required Fields', 400 );
|
|
755
|
-
} else if ( errorCount ) {
|
|
756
|
-
return res.sendError( 'Checklist got edited.please contact admin', 400 );
|
|
757
|
-
} else {
|
|
758
|
-
next();
|
|
759
|
-
}
|
|
760
|
-
} else {
|
|
761
|
-
next();
|
|
762
|
-
}
|
|
763
|
-
} catch ( e ) {
|
|
764
|
-
logger.error( { function: 'sopMobilechecklistQuestionValidator', error: e, body: req.body } );
|
|
765
|
-
return res.sendError( e, 500 );
|
|
766
|
-
}
|
|
767
|
-
};
|
|
768
|
-
|
|
769
684
|
export async function sopMobileTaskQuestionValidator( req, res, next ) {
|
|
770
685
|
try {
|
|
771
686
|
let requestData = req.body;
|
|
@@ -1567,408 +1482,6 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1567
1482
|
}
|
|
1568
1483
|
};
|
|
1569
1484
|
|
|
1570
|
-
export async function sopMobilechecklistMultiSectionFormatterv2( req, res, next ) {
|
|
1571
|
-
try {
|
|
1572
|
-
let requestData = req.body;
|
|
1573
|
-
requestData.questionAnswers = typeof requestData.questionAnswers == 'string' ? JSON.parse( requestData.questionAnswers ) : requestData.questionAnswers;
|
|
1574
|
-
let getChecklistQA = await processedchecklist.findOne( { _id: new ObjectId( requestData.processedcheckListId ) }, { questionAnswers: 1 } );
|
|
1575
|
-
let reqAnswers = requestData.questionAnswers;
|
|
1576
|
-
logger.error( { functionName: 'updatedPayload', message: reqAnswers } );
|
|
1577
|
-
let CLQAnswers = getChecklistQA.questionAnswers;
|
|
1578
|
-
let originalSectionIndex = CLQAnswers.findIndex( ( section ) => reqAnswers[0].sectionName == section?.sectionOldName || reqAnswers[0].sectionName == section?.sectionName );
|
|
1579
|
-
let origSection = CLQAnswers[originalSectionIndex];
|
|
1580
|
-
if ( originalSectionIndex != -1 ) {
|
|
1581
|
-
CLQAnswers.splice( originalSectionIndex, 1 );
|
|
1582
|
-
}
|
|
1583
|
-
|
|
1584
|
-
if ( requestData.submittype == 'submit' ) {
|
|
1585
|
-
reqAnswers.forEach( ( reqA ) => {
|
|
1586
|
-
if ( ![ 'multiplechoicemultiple', 'multipleImage' ].includes( reqA?.answerType ) ) {
|
|
1587
|
-
if ( ( !reqA.linkType && ( reqA.answer == null || reqA.answer == '' ) ) || ( reqA.linkType && reqA.linkquestionenabled && ( reqA.answer == null || reqA.answer == '' ) ) ) {
|
|
1588
|
-
return res.sendError( 'Please Fill All Fields', 400 );
|
|
1589
|
-
}
|
|
1590
|
-
}
|
|
1591
|
-
} );
|
|
1592
|
-
CLQAnswers.forEach( ( section ) => {
|
|
1593
|
-
section.questions.forEach( ( question ) => {
|
|
1594
|
-
if ( !question.linkType || ( question.linkType && question.linkquestionenabled ) ) {
|
|
1595
|
-
if ( !question.userAnswer.length ) {
|
|
1596
|
-
return res.sendError( 'Please Fill All Fields', 400 );
|
|
1597
|
-
} else {
|
|
1598
|
-
question.userAnswer.forEach( ( ans ) => {
|
|
1599
|
-
if ( ans.answer == null || ans.answer == '' ) {
|
|
1600
|
-
return res.sendError( 'Please Fill All Fields', 400 );
|
|
1601
|
-
}
|
|
1602
|
-
} );
|
|
1603
|
-
}
|
|
1604
|
-
}
|
|
1605
|
-
} );
|
|
1606
|
-
} );
|
|
1607
|
-
}
|
|
1608
|
-
|
|
1609
|
-
if ( requestData?.editSubmit && requestData?.editSubmit == 'true' ) {
|
|
1610
|
-
reqAnswers.forEach( ( item ) => item.section_id = section.section_id );
|
|
1611
|
-
origSection.questions.forEach( ( question ) => {
|
|
1612
|
-
let sectionQuestion = requestSection.filter( ( secQuestion ) => secQuestion.qname == question.oldQname || secQuestion.qname == question.qname );
|
|
1613
|
-
if ( !sectionQuestion.length ) {
|
|
1614
|
-
let data = { ...requestSection[0] };
|
|
1615
|
-
data.answerType = question.answerType;
|
|
1616
|
-
data.qno = question.qno;
|
|
1617
|
-
data.uniqueqno = question.uniqueqno;
|
|
1618
|
-
data.uniqueqid = question.uniqueqid;
|
|
1619
|
-
data.qname = question.qname;
|
|
1620
|
-
data.oldQname = question?.oldQname || question.qname;
|
|
1621
|
-
data.answer = 'null';
|
|
1622
|
-
data.remarks = '';
|
|
1623
|
-
data.validationAnswer = '';
|
|
1624
|
-
data.Multianswer = [];
|
|
1625
|
-
data.linkType = question.linkType;
|
|
1626
|
-
data.linkquestionenabled = question.linkType;
|
|
1627
|
-
data.linkedQuestion = null;
|
|
1628
|
-
data.showLinked = null;
|
|
1629
|
-
data.parentanswer = '';
|
|
1630
|
-
data.dateRangeType = false;
|
|
1631
|
-
reqAnswers.push( data );
|
|
1632
|
-
}
|
|
1633
|
-
} );
|
|
1634
|
-
}
|
|
1635
|
-
|
|
1636
|
-
let sectionData;
|
|
1637
|
-
const uniqueArray = [ { id: origSection.section_id, name: origSection.sectionName } ];
|
|
1638
|
-
for ( let section of uniqueArray ) {
|
|
1639
|
-
let newArray = [];
|
|
1640
|
-
let qaAnswers = origSection.questions;
|
|
1641
|
-
let requestSection = reqAnswers;
|
|
1642
|
-
for ( let i = 0; i < requestSection.length; i++ ) {
|
|
1643
|
-
for ( let j = 0; j < qaAnswers.length; j++ ) {
|
|
1644
|
-
if ( requestSection[i].qname == qaAnswers[j].oldQname || requestSection[i].qname == qaAnswers[j].qname ) {
|
|
1645
|
-
if ( qaAnswers[j].answerType == 'yes/no' ) {
|
|
1646
|
-
let qaans = qaAnswers[j].answers;
|
|
1647
|
-
let yn = [];
|
|
1648
|
-
for ( let k = 0; k < qaans.length; k++ ) {
|
|
1649
|
-
if ( requestSection[i].answer == qaans[k].answer ) {
|
|
1650
|
-
if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
|
|
1651
|
-
if ( requestSection[i].validationAnswer ) {
|
|
1652
|
-
let validateAns = decodeURIComponent( requestSection[i].validationAnswer.split( '?' )[0] );
|
|
1653
|
-
if ( validateAns.length ) {
|
|
1654
|
-
let splitImgUrl = validateAns.split( '/' );
|
|
1655
|
-
if ( splitImgUrl.length > 1 ) {
|
|
1656
|
-
splitImgUrl.splice( 0, 3 );
|
|
1657
|
-
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1658
|
-
}
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
} else {
|
|
1662
|
-
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1663
|
-
qaans[k].validationAnswer = requestSection[i].validationAnswer || '';
|
|
1664
|
-
}
|
|
1665
|
-
yn.push( qaans[k] );
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
|
-
let structure = {};
|
|
1669
|
-
structure.qno = qaAnswers[j].qno;
|
|
1670
|
-
structure.uniqueqno = qaAnswers[j].uniqueqno;
|
|
1671
|
-
structure.uniqueqid = qaAnswers[j].uniqueqid;
|
|
1672
|
-
structure.qname = qaAnswers[j].qname;
|
|
1673
|
-
structure.answerType = qaAnswers[j].answerType;
|
|
1674
|
-
structure.runAI = qaAnswers[j].runAI;
|
|
1675
|
-
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1676
|
-
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1677
|
-
structure.remarks = requestSection[i].remarks;
|
|
1678
|
-
structure.answers = qaAnswers[j].answers;
|
|
1679
|
-
structure.userAnswer = yn;
|
|
1680
|
-
structure.linkType = qaAnswers[j].linkType;
|
|
1681
|
-
structure.linkquestionenabled = requestSection[i].linkquestionenabled;
|
|
1682
|
-
structure.parentanswer = requestSection[i].parentanswer;
|
|
1683
|
-
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage || '';
|
|
1684
|
-
structure.multiQuestionReferenceImage = qaAnswers[j].multiQuestionReferenceImage || [];
|
|
1685
|
-
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1686
|
-
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1687
|
-
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1688
|
-
if ( qaAnswers[j]?.taskId ) {
|
|
1689
|
-
structure.taskId = qaAnswers[j]?.taskId;
|
|
1690
|
-
structure.task = true;
|
|
1691
|
-
}
|
|
1692
|
-
if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1693
|
-
structure.redo = false;
|
|
1694
|
-
} else if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'draft' ) {
|
|
1695
|
-
structure.redo = qaAnswers[j]?.redo;
|
|
1696
|
-
}
|
|
1697
|
-
if ( qaAnswers[j]?.redoComment ) {
|
|
1698
|
-
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
1699
|
-
};
|
|
1700
|
-
newArray.push( structure );
|
|
1701
|
-
} else if ( qaAnswers[j].answerType == 'multiplechoicesingle' ) {
|
|
1702
|
-
let qaans = qaAnswers[j].answers;
|
|
1703
|
-
let ms = [];
|
|
1704
|
-
for ( let k = 0; k < qaans.length; k++ ) {
|
|
1705
|
-
if ( requestSection[i].answer == qaans[k].answer ) {
|
|
1706
|
-
if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
|
|
1707
|
-
if ( requestSection[i].validationAnswer ) {
|
|
1708
|
-
let validationAnswer = decodeURIComponent( requestSection[i].validationAnswer.split( '?' )[0] );
|
|
1709
|
-
if ( validationAnswer.length ) {
|
|
1710
|
-
let splitImgUrl = validationAnswer.split( '/' );
|
|
1711
|
-
if ( splitImgUrl.length > 1 ) {
|
|
1712
|
-
splitImgUrl.splice( 0, 3 );
|
|
1713
|
-
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1714
|
-
}
|
|
1715
|
-
}
|
|
1716
|
-
}
|
|
1717
|
-
} else {
|
|
1718
|
-
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1719
|
-
qaans[k].validationAnswer = requestSection[i].validationAnswer || '';
|
|
1720
|
-
}
|
|
1721
|
-
ms.push( qaans[k] );
|
|
1722
|
-
}
|
|
1723
|
-
}
|
|
1724
|
-
let structure = {};
|
|
1725
|
-
structure.qno = qaAnswers[j].qno;
|
|
1726
|
-
structure.uniqueqno = qaAnswers[j].uniqueqno;
|
|
1727
|
-
structure.uniqueqid = qaAnswers[j].uniqueqid;
|
|
1728
|
-
structure.qname = qaAnswers[j].qname;
|
|
1729
|
-
structure.answerType = qaAnswers[j].answerType;
|
|
1730
|
-
structure.runAI = qaAnswers[j].runAI;
|
|
1731
|
-
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1732
|
-
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1733
|
-
structure.remarks = requestSection[i].remarks;
|
|
1734
|
-
structure.answers = qaAnswers[j].answers;
|
|
1735
|
-
structure.userAnswer = ms;
|
|
1736
|
-
structure.linkType = qaAnswers[j].linkType;
|
|
1737
|
-
structure.linkquestionenabled = requestSection[i].linkquestionenabled;
|
|
1738
|
-
structure.parentanswer = requestSection[i].parentanswer;
|
|
1739
|
-
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage || '';
|
|
1740
|
-
structure.multiQuestionReferenceImage = qaAnswers[j].multiQuestionReferenceImage || [];
|
|
1741
|
-
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1742
|
-
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1743
|
-
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1744
|
-
if ( qaAnswers[j]?.taskId ) {
|
|
1745
|
-
structure.taskId = qaAnswers[j]?.taskId;
|
|
1746
|
-
structure.task = true;
|
|
1747
|
-
}
|
|
1748
|
-
if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1749
|
-
structure.redo = false;
|
|
1750
|
-
} else if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'draft' ) {
|
|
1751
|
-
structure.redo = qaAnswers[j]?.redo;
|
|
1752
|
-
}
|
|
1753
|
-
if ( qaAnswers[j]?.redoComment ) {
|
|
1754
|
-
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
1755
|
-
};
|
|
1756
|
-
newArray.push( structure );
|
|
1757
|
-
} else if ( qaAnswers[j].answerType == 'multiplechoicemultiple' ) {
|
|
1758
|
-
let qaans = qaAnswers[j].answers;
|
|
1759
|
-
let mcmo = [];
|
|
1760
|
-
for ( let k = 0; k < qaans.length; k++ ) {
|
|
1761
|
-
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
|
|
1762
|
-
for ( let s = 0; s < separatedArray.length; s++ ) {
|
|
1763
|
-
if ( separatedArray[s].answer == qaans[k].answer ) {
|
|
1764
|
-
if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
|
|
1765
|
-
if ( separatedArray[s].validationAnswer ) {
|
|
1766
|
-
let validationAnswer = decodeURIComponent( separatedArray[s].validationAnswer.split( '?' )[0] );
|
|
1767
|
-
if ( validationAnswer.length ) {
|
|
1768
|
-
let splitImgUrl = validationAnswer.split( '/' );
|
|
1769
|
-
if ( splitImgUrl.length > 1 ) {
|
|
1770
|
-
splitImgUrl.splice( 0, 3 );
|
|
1771
|
-
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1772
|
-
}
|
|
1773
|
-
}
|
|
1774
|
-
}
|
|
1775
|
-
} else {
|
|
1776
|
-
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1777
|
-
qaans[k].validationAnswer = separatedArray[s].validationAnswer || '';
|
|
1778
|
-
}
|
|
1779
|
-
|
|
1780
|
-
mcmo.push( qaans[k] );
|
|
1781
|
-
}
|
|
1782
|
-
}
|
|
1783
|
-
}
|
|
1784
|
-
let structure = {};
|
|
1785
|
-
structure.qno = qaAnswers[j].qno;
|
|
1786
|
-
structure.uniqueqno = qaAnswers[j].uniqueqno;
|
|
1787
|
-
structure.qno = qaAnswers[j].qno;
|
|
1788
|
-
structure.qname = qaAnswers[j].qname;
|
|
1789
|
-
structure.answerType = qaAnswers[j].answerType;
|
|
1790
|
-
structure.runAI = qaAnswers[j].runAI;
|
|
1791
|
-
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1792
|
-
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1793
|
-
structure.remarks = requestSection[i].remarks;
|
|
1794
|
-
structure.answers = qaAnswers[j].answers;
|
|
1795
|
-
structure.userAnswer = mcmo;
|
|
1796
|
-
structure.linkType = qaAnswers[j].linkType;
|
|
1797
|
-
structure.linkquestionenabled = requestSection[i].linkquestionenabled;
|
|
1798
|
-
structure.parentanswer = requestSection[i].parentanswer;
|
|
1799
|
-
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage || '';
|
|
1800
|
-
structure.multiQuestionReferenceImage = qaAnswers[j].multiQuestionReferenceImage || [];
|
|
1801
|
-
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1802
|
-
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1803
|
-
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1804
|
-
if ( qaAnswers[j]?.taskId ) {
|
|
1805
|
-
structure.taskId = qaAnswers[j]?.taskId;
|
|
1806
|
-
structure.task = true;
|
|
1807
|
-
}
|
|
1808
|
-
if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1809
|
-
structure.redo = false;
|
|
1810
|
-
} else if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'draft' ) {
|
|
1811
|
-
structure.redo = qaAnswers[j]?.redo;
|
|
1812
|
-
}
|
|
1813
|
-
if ( qaAnswers[j]?.redoComment ) {
|
|
1814
|
-
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
1815
|
-
};
|
|
1816
|
-
newArray.push( structure );
|
|
1817
|
-
} else if ( qaAnswers[j].answerType == 'multipleImage' ) {
|
|
1818
|
-
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
|
|
1819
|
-
let mcmi = [];
|
|
1820
|
-
// for (let k = 0; k < qaans.length; k++) {
|
|
1821
|
-
for ( let s = 0; s < separatedArray.length; s++ ) {
|
|
1822
|
-
if ( separatedArray[s].answer && separatedArray[s].answer !='' ) {
|
|
1823
|
-
let newAnswer = {};
|
|
1824
|
-
let validationAnswer = decodeURIComponent( separatedArray[s].answer.split( '?' )[0] );
|
|
1825
|
-
if ( validationAnswer.length ) {
|
|
1826
|
-
let splitImgUrl = validationAnswer.split( '/' );
|
|
1827
|
-
if ( splitImgUrl.length > 1 ) {
|
|
1828
|
-
splitImgUrl.splice( 0, 3 );
|
|
1829
|
-
newAnswer.answer = splitImgUrl.join( '/' ) || '';
|
|
1830
|
-
}
|
|
1831
|
-
}
|
|
1832
|
-
|
|
1833
|
-
newAnswer.answeroptionNumber = 0;
|
|
1834
|
-
newAnswer.sopFlag = false;
|
|
1835
|
-
newAnswer.validation = false;
|
|
1836
|
-
newAnswer.validationType = '';
|
|
1837
|
-
newAnswer.referenceImage = '';
|
|
1838
|
-
newAnswer.allowUploadfromGallery = false;
|
|
1839
|
-
newAnswer.descriptivetype = '';
|
|
1840
|
-
newAnswer.showLinked = false;
|
|
1841
|
-
newAnswer.linkedQuestion = 0;
|
|
1842
|
-
newAnswer.nestedQuestion = [];
|
|
1843
|
-
newAnswer.index = s;
|
|
1844
|
-
newAnswer.runAI = qaAnswers[j].answers[0]?.runAI || false;
|
|
1845
|
-
newAnswer.runAIFeatures = qaAnswers[j].answers[0]?.runAIFeatures || [];
|
|
1846
|
-
newAnswer.runAIDescription = qaAnswers[j].answers[0]?.runAIDescription || '';
|
|
1847
|
-
mcmi.push( newAnswer );
|
|
1848
|
-
}
|
|
1849
|
-
}
|
|
1850
|
-
// }
|
|
1851
|
-
let structure = {};
|
|
1852
|
-
structure.qno = qaAnswers[j].qno;
|
|
1853
|
-
structure.uniqueqno = qaAnswers[j].uniqueqno;
|
|
1854
|
-
structure.uniqueqid = qaAnswers[j].uniqueqid;
|
|
1855
|
-
structure.qname = qaAnswers[j].qname;
|
|
1856
|
-
structure.answerType = qaAnswers[j].answerType;
|
|
1857
|
-
structure.runAI = qaAnswers[j].runAI;
|
|
1858
|
-
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1859
|
-
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1860
|
-
structure.remarks = requestSection[i].remarks;
|
|
1861
|
-
structure.answers = qaAnswers[j].answers;
|
|
1862
|
-
structure.userAnswer = mcmi;
|
|
1863
|
-
structure.linkType = qaAnswers[j].linkType;
|
|
1864
|
-
structure.linkquestionenabled = requestSection[i].linkquestionenabled;
|
|
1865
|
-
structure.parentanswer = requestSection[i].parentanswer;
|
|
1866
|
-
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage || '';
|
|
1867
|
-
structure.multiQuestionReferenceImage = qaAnswers[j].multiQuestionReferenceImage || [];
|
|
1868
|
-
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1869
|
-
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1870
|
-
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1871
|
-
if ( qaAnswers[j]?.taskId ) {
|
|
1872
|
-
structure.taskId = qaAnswers[j]?.taskId;
|
|
1873
|
-
structure.task = true;
|
|
1874
|
-
}
|
|
1875
|
-
if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1876
|
-
structure.redo = false;
|
|
1877
|
-
} else if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'draft' ) {
|
|
1878
|
-
structure.redo = qaAnswers[j]?.redo;
|
|
1879
|
-
}
|
|
1880
|
-
if ( qaAnswers[j]?.redoComment ) {
|
|
1881
|
-
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
1882
|
-
};
|
|
1883
|
-
newArray.push( structure );
|
|
1884
|
-
} else {
|
|
1885
|
-
let des = [];
|
|
1886
|
-
if ( requestSection[i].answer != 'null' && requestSection[i].answer != '' && requestSection[i].answer != null ) {
|
|
1887
|
-
let validationAnswer = '';
|
|
1888
|
-
if ( requestSection[i].answer.split( '?' ).length > 1 ) {
|
|
1889
|
-
validationAnswer = decodeURIComponent( requestSection[i].answer.split( '?' )[0] );
|
|
1890
|
-
}
|
|
1891
|
-
if ( validationAnswer.length ) {
|
|
1892
|
-
let splitImgUrl = validationAnswer.split( '/' );
|
|
1893
|
-
if ( splitImgUrl.length > 1 ) {
|
|
1894
|
-
splitImgUrl.splice( 0, 3 );
|
|
1895
|
-
requestSection[i].answer = splitImgUrl.join( '/' );
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
1898
|
-
let ansstructure = {
|
|
1899
|
-
answer: requestSection[i].answer,
|
|
1900
|
-
answeroptionNumber: 1,
|
|
1901
|
-
sopFlag: false,
|
|
1902
|
-
validation: false,
|
|
1903
|
-
validationType: '',
|
|
1904
|
-
validationAnswer: '',
|
|
1905
|
-
referenceImage: qaAnswers[j].answers[0].referenceImage || '',
|
|
1906
|
-
multiReferenceImage: qaAnswers[j].answers[0].multiReferenceImage || [],
|
|
1907
|
-
showLinked: qaAnswers[j].answers[0].showLinked,
|
|
1908
|
-
linkedQuestion: qaAnswers[j].answers[0].linkedQuestion,
|
|
1909
|
-
runAI: qaAnswers[j].answers[0]?.runAI || false,
|
|
1910
|
-
runAIFeatures: qaAnswers[j]?.answers[0]?.runAIFeatures || [],
|
|
1911
|
-
runAIDescription: qaAnswers[j].answers[0]?.runAIDescription || '',
|
|
1912
|
-
};
|
|
1913
|
-
if ( qaAnswers[j].answerType == 'date' ) {
|
|
1914
|
-
ansstructure.dateRangeType = requestSection[i].dateRangeType || false;
|
|
1915
|
-
}
|
|
1916
|
-
des.push( ansstructure );
|
|
1917
|
-
}
|
|
1918
|
-
let structure = {};
|
|
1919
|
-
structure.qno = qaAnswers[j].qno;
|
|
1920
|
-
structure.uniqueqno = qaAnswers[j].uniqueqno;
|
|
1921
|
-
structure.uniqueqid = qaAnswers[j].uniqueqid;
|
|
1922
|
-
structure.qname = qaAnswers[j].qname;
|
|
1923
|
-
structure.answerType = qaAnswers[j].answerType;
|
|
1924
|
-
structure.runAI = qaAnswers[j].runAI;
|
|
1925
|
-
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1926
|
-
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1927
|
-
structure.remarks = requestSection[i].remarks;
|
|
1928
|
-
structure.answers = qaAnswers[j].answers;
|
|
1929
|
-
structure.userAnswer = des;
|
|
1930
|
-
structure.linkType = qaAnswers[j].linkType;
|
|
1931
|
-
structure.linkquestionenabled = requestSection[i].linkquestionenabled;
|
|
1932
|
-
structure.parentanswer = requestSection[i].parentanswer;
|
|
1933
|
-
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage || '';
|
|
1934
|
-
structure.multiQuestionReferenceImage = qaAnswers[j].multiQuestionReferenceImage || [];
|
|
1935
|
-
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1936
|
-
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1937
|
-
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1938
|
-
if ( qaAnswers[j]?.taskId ) {
|
|
1939
|
-
structure.taskId = qaAnswers[j]?.taskId;
|
|
1940
|
-
structure.task = true;
|
|
1941
|
-
}
|
|
1942
|
-
if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1943
|
-
structure.redo = false;
|
|
1944
|
-
} else if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'draft' ) {
|
|
1945
|
-
structure.redo = qaAnswers[j]?.redo;
|
|
1946
|
-
}
|
|
1947
|
-
if ( qaAnswers[j]?.redoComment ) {
|
|
1948
|
-
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
1949
|
-
};
|
|
1950
|
-
newArray.push( structure );
|
|
1951
|
-
}
|
|
1952
|
-
}
|
|
1953
|
-
}
|
|
1954
|
-
}
|
|
1955
|
-
sectionData = {
|
|
1956
|
-
'section_id': section.id,
|
|
1957
|
-
'sectionName': section.name,
|
|
1958
|
-
'questions': newArray,
|
|
1959
|
-
};
|
|
1960
|
-
}
|
|
1961
|
-
|
|
1962
|
-
CLQAnswers.splice( originalSectionIndex, 0, sectionData );
|
|
1963
|
-
requestData.questionAnswers = CLQAnswers;
|
|
1964
|
-
logger.error( { message: requestData.questionAnswers, error: 'QuestionanswersPayload' } );
|
|
1965
|
-
next();
|
|
1966
|
-
} catch ( error ) {
|
|
1967
|
-
logger.error( { function: 'sopMobilechecklistMultiSectionFormatter', error: error, body: req.body } );
|
|
1968
|
-
return res.sendError( error, 500 );
|
|
1969
|
-
}
|
|
1970
|
-
};
|
|
1971
|
-
|
|
1972
1485
|
export async function sopMobileTaskMultiSectionFormatter( req, res, next ) {
|
|
1973
1486
|
try {
|
|
1974
1487
|
let requestData = req.body;
|
|
@@ -2368,7 +1881,7 @@ export async function submitChecklist( req, res ) {
|
|
|
2368
1881
|
updateData.questionFlag = flagCount;
|
|
2369
1882
|
updateData.submitTime_string = currentDateTime.format( 'hh:mm A, DD MMM YYYY' );
|
|
2370
1883
|
if ( requestData.deviceDetails && requestData.deviceDetails != '' ) {
|
|
2371
|
-
updateData.deviceDetails =
|
|
1884
|
+
updateData.deviceDetails =JSON.parse( requestData.deviceDetails );
|
|
2372
1885
|
}
|
|
2373
1886
|
if ( requestData.submittype == 'draft' ) {
|
|
2374
1887
|
logger.info( `v5 => Checklist Save => store Name: ${getchecklist[0].storeName}, User Email: ${getchecklist[0].userEmail}, Checklist Name: ${getchecklist[0].checkListName}` );
|
|
@@ -3717,13 +3230,6 @@ export async function questionList( req, res ) {
|
|
|
3717
3230
|
logger.info( `v5 => Checklist Continue => store Name: ${getchecklist[0].storeName}, User Email: ${getchecklist[0].userEmail}, Checklist Name: ${getchecklist[0].checkListName}` );
|
|
3718
3231
|
let bucket = JSON.parse( process.env.BUCKET );
|
|
3719
3232
|
let cdnurl = JSON.parse( process.env.CDNURL );
|
|
3720
|
-
if ( req?.query?.sectionIndex ) {
|
|
3721
|
-
if ( getchecklist[0].questionAnswers.length <= req?.query?.sectionIndex ) {
|
|
3722
|
-
return res.sendError( 'Check List Got Edited Please Fill Again', 422 );
|
|
3723
|
-
}
|
|
3724
|
-
getchecklist[0]['sectionLength'] = getchecklist[0].questionAnswers.length;
|
|
3725
|
-
getchecklist[0].questionAnswers = [ getchecklist[0].questionAnswers[req?.query?.sectionIndex] ];
|
|
3726
|
-
}
|
|
3727
3233
|
for ( let [ secIndex, section ] of getchecklist[0].questionAnswers.entries() ) {
|
|
3728
3234
|
for ( let [ questionIndex, question ] of section.questions.entries() ) {
|
|
3729
3235
|
let Multianswer = [];
|
|
@@ -4732,13 +4238,6 @@ export async function questionListV1( req, res ) {
|
|
|
4732
4238
|
logger.info( `v5 => Checklist Continue => store Name: ${getchecklist[0].storeName}, User Email: ${getchecklist[0].userEmail}, Checklist Name: ${getchecklist[0].checkListName}` );
|
|
4733
4239
|
let bucket = JSON.parse( process.env.BUCKET );
|
|
4734
4240
|
let cdnurl = JSON.parse( process.env.CDNURL );
|
|
4735
|
-
if ( req?.query?.sectionIndex ) {
|
|
4736
|
-
if ( getchecklist[0].questionAnswers.length <= req?.query?.sectionIndex ) {
|
|
4737
|
-
return res.sendError( 'Check List Got Edited Please Fill Again', 422 );
|
|
4738
|
-
}
|
|
4739
|
-
getchecklist[0]['sectionLength'] = getchecklist[0].questionAnswers.length;
|
|
4740
|
-
getchecklist[0].questionAnswers = [ getchecklist[0].questionAnswers[req?.query?.sectionIndex] ];
|
|
4741
|
-
}
|
|
4742
4241
|
for ( let [ secIndex, section ] of getchecklist[0].questionAnswers.entries() ) {
|
|
4743
4242
|
for ( let [ questionIndex, question ] of section.questions.entries() ) {
|
|
4744
4243
|
let Multianswer = [];
|
|
@@ -149,7 +149,6 @@ export const startSchema = joi.object( {
|
|
|
149
149
|
date: joi.string().required(),
|
|
150
150
|
processedcheckListId: joi.string().required(),
|
|
151
151
|
currentTime: joi.string().optional().allow( '' ),
|
|
152
|
-
section: joi.boolean().optional(),
|
|
153
152
|
} );
|
|
154
153
|
|
|
155
154
|
export const startValidation = {
|
|
@@ -12,7 +12,6 @@ mobileRouter
|
|
|
12
12
|
.post( '/startTask', isAllowedSessionHandler, validate( startValidation ), mobileController.startTask )
|
|
13
13
|
.post( '/submitCheckList', isAllowedSessionHandler, mobileController.sopMobilechecklistValidater, mobileController.sopMobilechecklistQuestionValidator, mobileController.sopMobilechecklistMultiSectionFormatter, mobileController.submitChecklist )
|
|
14
14
|
.post( '/submitCheckListv5', isAllowedSessionHandler, mobileController.sopMobilechecklistValidater, mobileController.sopMobilechecklistQuestionValidatorv1, mobileController.sopMobilechecklistMultiSectionFormatterv1, mobileController.submitChecklist )
|
|
15
|
-
.post( '/submitCheckListv6', isAllowedSessionHandler, mobileController.sopMobilechecklistValidater, mobileController.sopMobilechecklistQuestionValidatorv2, mobileController.sopMobilechecklistMultiSectionFormatterv2, mobileController.submitChecklist )
|
|
16
15
|
.post( '/submitTask', isAllowedSessionHandler, mobileController.sopMobilechecklistValidater, mobileController.sopMobileTaskQuestionValidator, mobileController.sopMobileTaskMultiSectionFormatter, mobileController.submitTask )
|
|
17
16
|
.post( '/submiteyeTestTask', isAllowedSessionHandler, mobileController.submiteyeTestTask )
|
|
18
17
|
.get( '/dashboard', isAllowedSessionHandler, validate( dashboardValidation ), mobileController.dashboard )
|