tango-app-api-trax 1.0.0-beta-task.4 → 1.0.0-beta-task.7
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 +2 -2
- package/src/controllers/gallery.controller.js +5 -0
- package/src/controllers/internalTrax.controller.js +3 -2
- package/src/controllers/mobileTrax.controller.js +88 -43
- package/src/controllers/trax.controller.js +3 -0
- package/src/controllers/traxDashboard.controllers.js +4 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-trax",
|
|
3
|
-
"version": "1.0.0-beta-task.
|
|
3
|
+
"version": "1.0.0-beta-task.7",
|
|
4
4
|
"description": "Trax",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"mongodb": "^6.8.0",
|
|
27
27
|
"nodemon": "^3.1.4",
|
|
28
28
|
"path": "^0.12.7",
|
|
29
|
-
"tango-api-schema": "2.2.
|
|
29
|
+
"tango-api-schema": "2.2.5",
|
|
30
30
|
"tango-app-api-middleware": "3.1.43-alpha.10",
|
|
31
31
|
"url": "^0.11.4",
|
|
32
32
|
"winston": "^3.13.1",
|
|
@@ -443,6 +443,11 @@ export async function getLogs( req, res ) {
|
|
|
443
443
|
|
|
444
444
|
export async function approvalstatus( req, res ) {
|
|
445
445
|
try {
|
|
446
|
+
if ( ( req?.user?.userType == 'client' && req.user.role == 'superadmin' ) ) {
|
|
447
|
+
return res.sendError( 'No Content', 204 );
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
|
|
446
451
|
let Approver = await ApproverModel.find( { checkListId: req.body.checklistId } );
|
|
447
452
|
if ( Approver.length === 0 ) {
|
|
448
453
|
return res.sendSuccess( 'suceess' );
|
|
@@ -599,6 +599,7 @@ export async function updatePublish( req, res ) {
|
|
|
599
599
|
try {
|
|
600
600
|
let query = {
|
|
601
601
|
publish: true,
|
|
602
|
+
checkListType: 'custom',
|
|
602
603
|
$or: [
|
|
603
604
|
{ scheduleDate: { $lt: new Date() } },
|
|
604
605
|
{ configEndDate: { $lt: new Date() } },
|
|
@@ -1352,8 +1353,8 @@ export async function taskPushNotification( req, res ) {
|
|
|
1352
1353
|
const message = {
|
|
1353
1354
|
tokens: item.token,
|
|
1354
1355
|
notification: {
|
|
1355
|
-
title: 'Reminder to Fill
|
|
1356
|
-
body: `${item.checklistName}
|
|
1356
|
+
title: 'Reminder to Fill task',
|
|
1357
|
+
body: `${item.checklistName} task is going to breach within few minutes`,
|
|
1357
1358
|
},
|
|
1358
1359
|
data: {
|
|
1359
1360
|
customKey: 'customValue',
|
|
@@ -596,7 +596,10 @@ export async function sopMobilechecklistMultiSectionFormatter( req, res, next )
|
|
|
596
596
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
597
597
|
if ( qaAnswers[j]?.redo ) {
|
|
598
598
|
structure.redo = false;
|
|
599
|
-
}
|
|
599
|
+
};
|
|
600
|
+
if ( qaAnswers[j]?.redoComment ) {
|
|
601
|
+
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
602
|
+
};
|
|
600
603
|
newArray.push( structure );
|
|
601
604
|
} else if ( qaAnswers[j].answerType == 'multiplechoicesingle' ) {
|
|
602
605
|
let qaans = qaAnswers[j].answers;
|
|
@@ -638,7 +641,10 @@ export async function sopMobilechecklistMultiSectionFormatter( req, res, next )
|
|
|
638
641
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
639
642
|
if ( qaAnswers[j]?.redo ) {
|
|
640
643
|
structure.redo = false;
|
|
641
|
-
}
|
|
644
|
+
};
|
|
645
|
+
if ( qaAnswers[j]?.redoComment ) {
|
|
646
|
+
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
647
|
+
};
|
|
642
648
|
newArray.push( structure );
|
|
643
649
|
} else if ( qaAnswers[j].answerType == 'multiplechoicemultiple' ) {
|
|
644
650
|
let qaans = qaAnswers[j].answers;
|
|
@@ -684,7 +690,10 @@ export async function sopMobilechecklistMultiSectionFormatter( req, res, next )
|
|
|
684
690
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
685
691
|
if ( qaAnswers[j]?.redo ) {
|
|
686
692
|
structure.redo = false;
|
|
687
|
-
}
|
|
693
|
+
};
|
|
694
|
+
if ( qaAnswers[j]?.redoComment ) {
|
|
695
|
+
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
696
|
+
};
|
|
688
697
|
newArray.push( structure );
|
|
689
698
|
} else if ( qaAnswers[j].answerType == 'multipleImage' ) {
|
|
690
699
|
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
|
|
@@ -735,7 +744,10 @@ export async function sopMobilechecklistMultiSectionFormatter( req, res, next )
|
|
|
735
744
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
736
745
|
if ( qaAnswers[j]?.redo ) {
|
|
737
746
|
structure.redo = false;
|
|
738
|
-
}
|
|
747
|
+
};
|
|
748
|
+
if ( qaAnswers[j]?.redoComment ) {
|
|
749
|
+
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
750
|
+
};
|
|
739
751
|
newArray.push( structure );
|
|
740
752
|
} else {
|
|
741
753
|
let des = [];
|
|
@@ -781,7 +793,10 @@ export async function sopMobilechecklistMultiSectionFormatter( req, res, next )
|
|
|
781
793
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
782
794
|
if ( qaAnswers[j]?.redo ) {
|
|
783
795
|
structure.redo = false;
|
|
784
|
-
}
|
|
796
|
+
};
|
|
797
|
+
if ( qaAnswers[j]?.redoComment ) {
|
|
798
|
+
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
799
|
+
};
|
|
785
800
|
newArray.push( structure );
|
|
786
801
|
}
|
|
787
802
|
}
|
|
@@ -874,13 +889,17 @@ export async function sopMobileTaskMultiSectionFormatter( req, res, next ) {
|
|
|
874
889
|
structure.remarks = requestSection[i].remarks;
|
|
875
890
|
structure.answers = qaAnswers[j].answers;
|
|
876
891
|
structure.userAnswer = yn;
|
|
877
|
-
structure.linkType = qaAnswers[j].linkType
|
|
878
|
-
structure.linkquestionenabled = requestSection[i].linkquestionenabled
|
|
879
|
-
structure.parentanswer = requestSection[i].parentanswer
|
|
880
|
-
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage
|
|
881
|
-
structure.descriptivetype = qaAnswers[j].descriptivetype
|
|
882
|
-
|
|
883
|
-
|
|
892
|
+
structure.linkType = qaAnswers[j].linkType;
|
|
893
|
+
structure.linkquestionenabled = requestSection[i].linkquestionenabled;
|
|
894
|
+
structure.parentanswer = requestSection[i].parentanswer;
|
|
895
|
+
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
|
|
896
|
+
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
897
|
+
if ( qaAnswers[j]?.redo ) {
|
|
898
|
+
structure.redo = false;
|
|
899
|
+
};
|
|
900
|
+
if ( qaAnswers[j]?.redoComment ) {
|
|
901
|
+
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
902
|
+
};
|
|
884
903
|
newArray.push( structure );
|
|
885
904
|
} else if ( qaAnswers[j].answerType == 'multiplechoicesingle' ) {
|
|
886
905
|
let qaans = qaAnswers[j].answers;
|
|
@@ -915,13 +934,17 @@ export async function sopMobileTaskMultiSectionFormatter( req, res, next ) {
|
|
|
915
934
|
structure.remarks = requestSection[i].remarks;
|
|
916
935
|
structure.answers = qaAnswers[j].answers;
|
|
917
936
|
structure.userAnswer = ms;
|
|
918
|
-
structure.linkType = qaAnswers[j].linkType
|
|
919
|
-
structure.linkquestionenabled = requestSection[i].linkquestionenabled
|
|
920
|
-
structure.parentanswer = requestSection[i].parentanswer
|
|
921
|
-
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage
|
|
922
|
-
structure.descriptivetype = qaAnswers[j].descriptivetype
|
|
923
|
-
|
|
924
|
-
|
|
937
|
+
structure.linkType = qaAnswers[j].linkType;
|
|
938
|
+
structure.linkquestionenabled = requestSection[i].linkquestionenabled;
|
|
939
|
+
structure.parentanswer = requestSection[i].parentanswer;
|
|
940
|
+
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
|
|
941
|
+
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
942
|
+
if ( qaAnswers[j]?.redo ) {
|
|
943
|
+
structure.redo = false;
|
|
944
|
+
};
|
|
945
|
+
if ( qaAnswers[j]?.redoComment ) {
|
|
946
|
+
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
947
|
+
};
|
|
925
948
|
newArray.push( structure );
|
|
926
949
|
} else if ( qaAnswers[j].answerType == 'multiplechoicemultiple' ) {
|
|
927
950
|
let qaans = qaAnswers[j].answers;
|
|
@@ -960,13 +983,17 @@ export async function sopMobileTaskMultiSectionFormatter( req, res, next ) {
|
|
|
960
983
|
structure.remarks = requestSection[i].remarks;
|
|
961
984
|
structure.answers = qaAnswers[j].answers;
|
|
962
985
|
structure.userAnswer = mcmo;
|
|
963
|
-
structure.linkType = qaAnswers[j].linkType
|
|
964
|
-
structure.linkquestionenabled = requestSection[i].linkquestionenabled
|
|
965
|
-
structure.parentanswer = requestSection[i].parentanswer
|
|
966
|
-
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage
|
|
967
|
-
structure.descriptivetype = qaAnswers[j].descriptivetype
|
|
968
|
-
|
|
969
|
-
|
|
986
|
+
structure.linkType = qaAnswers[j].linkType;
|
|
987
|
+
structure.linkquestionenabled = requestSection[i].linkquestionenabled;
|
|
988
|
+
structure.parentanswer = requestSection[i].parentanswer;
|
|
989
|
+
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
|
|
990
|
+
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
991
|
+
if ( qaAnswers[j]?.redo ) {
|
|
992
|
+
structure.redo = false;
|
|
993
|
+
};
|
|
994
|
+
if ( qaAnswers[j]?.redoComment ) {
|
|
995
|
+
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
996
|
+
};
|
|
970
997
|
newArray.push( structure );
|
|
971
998
|
} else if ( qaAnswers[j].answerType == 'multipleImage' ) {
|
|
972
999
|
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
|
|
@@ -1010,13 +1037,17 @@ export async function sopMobileTaskMultiSectionFormatter( req, res, next ) {
|
|
|
1010
1037
|
structure.remarks = requestSection[i].remarks;
|
|
1011
1038
|
structure.answers = qaAnswers[j].answers;
|
|
1012
1039
|
structure.userAnswer = mcmi;
|
|
1013
|
-
structure.linkType = qaAnswers[j].linkType
|
|
1014
|
-
structure.linkquestionenabled = requestSection[i].linkquestionenabled
|
|
1015
|
-
structure.parentanswer = requestSection[i].parentanswer
|
|
1016
|
-
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage
|
|
1017
|
-
structure.descriptivetype = qaAnswers[j].descriptivetype
|
|
1018
|
-
|
|
1019
|
-
|
|
1040
|
+
structure.linkType = qaAnswers[j].linkType;
|
|
1041
|
+
structure.linkquestionenabled = requestSection[i].linkquestionenabled;
|
|
1042
|
+
structure.parentanswer = requestSection[i].parentanswer;
|
|
1043
|
+
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
|
|
1044
|
+
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1045
|
+
if ( qaAnswers[j]?.redo ) {
|
|
1046
|
+
structure.redo = false;
|
|
1047
|
+
};
|
|
1048
|
+
if ( qaAnswers[j]?.redoComment ) {
|
|
1049
|
+
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
1050
|
+
};
|
|
1020
1051
|
newArray.push( structure );
|
|
1021
1052
|
} else {
|
|
1022
1053
|
let des = [];
|
|
@@ -1058,13 +1089,17 @@ export async function sopMobileTaskMultiSectionFormatter( req, res, next ) {
|
|
|
1058
1089
|
structure.remarks = requestSection[i].remarks;
|
|
1059
1090
|
structure.answers = qaAnswers[j].answers;
|
|
1060
1091
|
structure.userAnswer = des;
|
|
1061
|
-
structure.linkType = qaAnswers[j].linkType
|
|
1062
|
-
structure.linkquestionenabled = requestSection[i].linkquestionenabled
|
|
1063
|
-
structure.parentanswer = requestSection[i].parentanswer
|
|
1064
|
-
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage
|
|
1065
|
-
structure.descriptivetype = qaAnswers[j].descriptivetype
|
|
1066
|
-
|
|
1067
|
-
|
|
1092
|
+
structure.linkType = qaAnswers[j].linkType;
|
|
1093
|
+
structure.linkquestionenabled = requestSection[i].linkquestionenabled;
|
|
1094
|
+
structure.parentanswer = requestSection[i].parentanswer;
|
|
1095
|
+
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
|
|
1096
|
+
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1097
|
+
if ( qaAnswers[j]?.redo ) {
|
|
1098
|
+
structure.redo = false;
|
|
1099
|
+
};
|
|
1100
|
+
if ( qaAnswers[j]?.redoComment ) {
|
|
1101
|
+
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
1102
|
+
};
|
|
1068
1103
|
newArray.push( structure );
|
|
1069
1104
|
}
|
|
1070
1105
|
}
|
|
@@ -1763,6 +1798,7 @@ export async function checklistv1( req, res ) {
|
|
|
1763
1798
|
timeDifference: { $subtract: [ '$scheduleEndTime_iso', '$date_iso' ] },
|
|
1764
1799
|
redoStatus: { $ifNull: [ '$redoStatus', false ] },
|
|
1765
1800
|
type: { $ifNull: [ '$checkListType', '' ] },
|
|
1801
|
+
priorityType: { $ifNull: [ '$priorityType', '' ] },
|
|
1766
1802
|
},
|
|
1767
1803
|
},
|
|
1768
1804
|
];
|
|
@@ -2001,6 +2037,7 @@ export async function taskQuestionList( req, res ) {
|
|
|
2001
2037
|
questionAnswers: { $ifNull: [ '$questionAnswers', '' ] },
|
|
2002
2038
|
userEmail: { $ifNull: [ '$userEmail', '' ] },
|
|
2003
2039
|
storeName: { $ifNull: [ '$storeName', '' ] },
|
|
2040
|
+
redoStatus: { $ifNull: [ '$redoStatus', false ] },
|
|
2004
2041
|
},
|
|
2005
2042
|
},
|
|
2006
2043
|
];
|
|
@@ -2086,9 +2123,17 @@ export async function taskQuestionList( req, res ) {
|
|
|
2086
2123
|
}
|
|
2087
2124
|
|
|
2088
2125
|
if ( [ 'multiplechoicemultiple', 'multipleImage' ].includes( answerType ) ) {
|
|
2089
|
-
question.Multianswer = multiAnswer.length ?
|
|
2090
|
-
multiAnswer.map( ( item ) => ( {
|
|
2091
|
-
|
|
2126
|
+
question.Multianswer = multiAnswer.length > 0 ?
|
|
2127
|
+
multiAnswer.map( ( item ) => ( {
|
|
2128
|
+
answer: item.validationAnswer ? item.answer : null,
|
|
2129
|
+
no: item.no,
|
|
2130
|
+
validationAnswer: item.validationAnswer,
|
|
2131
|
+
} ) ) :
|
|
2132
|
+
answers.map( ( _, index ) => ( {
|
|
2133
|
+
answer: null,
|
|
2134
|
+
no: index,
|
|
2135
|
+
validationAnswer: null,
|
|
2136
|
+
} ) );
|
|
2092
2137
|
}
|
|
2093
2138
|
}
|
|
2094
2139
|
}
|
|
@@ -1839,6 +1839,8 @@ export async function insertSingleProcessData( checklistId, processId = 0, oldDa
|
|
|
1839
1839
|
insertdata.locationCount = getCLconfig.locationCount;
|
|
1840
1840
|
insertdata.scheduleRepeatedType = getCLconfig.scheduleRepeatedType;
|
|
1841
1841
|
insertdata.allowedMultiSubmit = getCLconfig.allowedMultiSubmit;
|
|
1842
|
+
insertdata.approver = getCLconfig?.approver || [];
|
|
1843
|
+
insertdata.remainder = getCLconfig?.remainder || [];
|
|
1842
1844
|
let collectSections = [];
|
|
1843
1845
|
let sectionQuery = [];
|
|
1844
1846
|
sectionQuery.push( {
|
|
@@ -2029,6 +2031,7 @@ async function insertPCBulkV3( getCLconfig, checklistId, currentdate, updatedche
|
|
|
2029
2031
|
assigndeletequery.client_id = insertdata.client_id;
|
|
2030
2032
|
assigndeletequery.checkListId = updatedchecklist._id;
|
|
2031
2033
|
assigndeletequery.checklistStatus = { $nin: [ 'submit' ] };
|
|
2034
|
+
assigndeletequery.redoStatus = false;
|
|
2032
2035
|
if ( getCLconfig?.allowedMultiSubmit && processId ) {
|
|
2033
2036
|
let processedDetails = await processedchecklist.findOne( { _id: processId } );
|
|
2034
2037
|
if ( processedDetails ) {
|
|
@@ -3528,16 +3528,15 @@ export const checklistDropdown = async ( req, res ) => {
|
|
|
3528
3528
|
export async function sendAlert( req, res ) {
|
|
3529
3529
|
try {
|
|
3530
3530
|
let inputBody = req.body;
|
|
3531
|
+
if ( inputBody?.id ) {
|
|
3532
|
+
inputBody.id = inputBody.id.map( ( item ) => new mongoose.Types.ObjectId( item ) );
|
|
3533
|
+
}
|
|
3531
3534
|
let query = {
|
|
3532
3535
|
date_iso: new Date( dayjs().format( 'YYYY-MM-DD' ) ),
|
|
3533
|
-
sourceCheckList_id: new mongoose.Types.ObjectId( inputBody.sourceCheckList_id ),
|
|
3536
|
+
...( inputBody?.sourceCheckList_id ) ? { sourceCheckList_id: new mongoose.Types.ObjectId( inputBody.sourceCheckList_id ) } : { _id: { $in: inputBody.id } },
|
|
3534
3537
|
checklistStatus: { $ne: 'submit' },
|
|
3535
3538
|
timeFlag: 0,
|
|
3536
3539
|
};
|
|
3537
|
-
if ( inputBody.userEmail && inputBody.storeName ) {
|
|
3538
|
-
query.userEmail = inputBody.userEmail;
|
|
3539
|
-
query.storeName = inputBody.storeName;
|
|
3540
|
-
}
|
|
3541
3540
|
|
|
3542
3541
|
query = [ { $match: query } ];
|
|
3543
3542
|
|