tango-app-api-trax 3.7.12-qid-2 → 3.7.12-qid-4

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.7.12-qid-2",
3
+ "version": "3.7.12-qid-4",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -863,6 +863,17 @@ export const duplicateChecklist = async ( req, res ) => {
863
863
  sectionDetails.checkList = dupDetails.checkListName;
864
864
  sectionDetails.createdAt = new Date();
865
865
  sectionDetails.updatedAt = new Date();
866
+ for ( let j = 0; j < sectionDetails.question.length; j++ ) {
867
+ let questionArr = sectionDetails.question[j];
868
+ if ( questionArr && questionArr.uniqueqid && questionArr.uniqueqid != '' ) {
869
+ let spliteID = questionArr.uniqueqid.split( '-' );
870
+ questionArr.uniqueqid =
871
+ spliteID[0] + '-' +
872
+ dupDetails.checkListNumber + '-' +
873
+ spliteID[2] + '-' +
874
+ spliteID[3];
875
+ }
876
+ }
866
877
  delete sectionDetails['_id'];
867
878
  sections.push( sectionDetails );
868
879
  }
@@ -870,8 +881,10 @@ export const duplicateChecklist = async ( req, res ) => {
870
881
  let actionType = 'Duplicated';
871
882
  let teamsMsg;
872
883
  let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
873
- teamsMsg = 'ClientId: '+ checkDetails.client_id + ', Action: '+ actionType + ', ChecklistId: '+ data._id + ', Checklist Name: '+ checkDetails.checkListName + ', UpDatedBy: '+ req.user.email;
874
- sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
884
+ if ( teamsAlertUrls && teamsAlertUrls !='' ) {
885
+ teamsMsg = 'ClientId: '+ checkDetails.client_id + ', Action: '+ actionType + ', ChecklistId: '+ data._id + ', Checklist Name: '+ checkDetails.checkListName + ', UpDatedBy: '+ req.user.email;
886
+ sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
887
+ }
875
888
 
876
889
  let logObj = {
877
890
  client_id: checkDetails.client_id,
@@ -983,7 +996,9 @@ export const update = async ( req, res ) => {
983
996
  // } );
984
997
 
985
998
  // Find max uniqueqno (cast to number, ignore null/undefined)
986
- let maxQID;
999
+ let maxQID = 0;
1000
+ // console.log( 'section.sectionNumber =>', section.sectionNumber );
1001
+ // console.log( 'maxQID =>', maxQID );
987
1002
  if ( section.questions && section.questions.length > 0 ) {
988
1003
  // let qids = section.questions
989
1004
  // .filter( ( q ) => q.uniqueqno != null )
@@ -991,11 +1006,14 @@ export const update = async ( req, res ) => {
991
1006
  // console.log( 'Extracted QIDs =>', qids );
992
1007
  // let maxQID = Math.max( 0, ...qids );
993
1008
  // console.log( 'maxQID =>', maxQID );
1009
+
994
1010
  if ( section.maxQuestionNumber > 0 ) {
995
1011
  maxQID = section.maxQuestionNumber || 0;
996
- } else {
997
- maxQID = section.questions.length || 0;
998
1012
  }
1013
+
1014
+ // else {
1015
+ // maxQID = 0;
1016
+ // }
999
1017
  for ( let [ index1, questions ] of section.questions.entries() ) {
1000
1018
  if ( questions?.uniqueqno == null || questions.uniqueqno === 0 ) {
1001
1019
  maxQID++;
@@ -1819,6 +1837,7 @@ export const updateConfigure =async ( req, res ) => {
1819
1837
 
1820
1838
  export const updateConfigurev1 =async ( req, res ) => {
1821
1839
  try {
1840
+ console.log( '123' );
1822
1841
  let inputBody = req.body;
1823
1842
  let id;
1824
1843
  let checklistDetails;
@@ -1840,7 +1859,7 @@ export const updateConfigurev1 =async ( req, res ) => {
1840
1859
  }
1841
1860
  }
1842
1861
 
1843
- if ( !inputBody.checkListDetails.assignedUsers.length && inputBody.submitType == 'publish' ) {
1862
+ if ( !inputBody?.checkListDetails?.assignedUsers?.length && inputBody.submitType == 'publish' ) {
1844
1863
  return res.sendError( 'Please Assigned a user', 400 );
1845
1864
  }
1846
1865