tango-app-api-trax 3.3.1-beta-15 → 3.3.1-beta-17
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
|
@@ -963,6 +963,105 @@ export const assignedUserDetails = async ( req, res ) => {
|
|
|
963
963
|
}
|
|
964
964
|
};
|
|
965
965
|
|
|
966
|
+
export const assignedUserDetailsv1 = async ( req, res ) => {
|
|
967
|
+
try {
|
|
968
|
+
if ( !req.params.checklistId ) {
|
|
969
|
+
return res.sendError( { message: 'checklist Id is required' }, 400 );
|
|
970
|
+
}
|
|
971
|
+
// let limit = parseInt( req.query.limit ) || 5;
|
|
972
|
+
// let page = parseInt( req.query.offset ) || 0;
|
|
973
|
+
// let skip = limit * page;
|
|
974
|
+
|
|
975
|
+
let query = [ { $match: { checkListId: new ObjectId( req.params.checklistId ), ...( req.body.coverage ) ? { coverage: req.body.coverage } : {} } } ];
|
|
976
|
+
if ( req.query.search.trim() && req.query.search.trim() != '' ) {
|
|
977
|
+
let searchValue = req.query.search;
|
|
978
|
+
searchValue = searchValue.split( ',' ).map( ( item ) => item.trim().toLowerCase() );
|
|
979
|
+
if ( searchValue.length > 1 ) {
|
|
980
|
+
query.push( { $addFields: { storeLower: { $toLower: '$storeName' } } } );
|
|
981
|
+
query.push( { $match: { storeLower: { $in: searchValue } } } );
|
|
982
|
+
} else {
|
|
983
|
+
query.push( { $match: { storeName: { $regex: req.query.search.trim(), $options: 'i' } } } );
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
query.push( { $sort: { _id: -1 } } );
|
|
988
|
+
|
|
989
|
+
let checklistDetails = await assignedService.aggregate( query );
|
|
990
|
+
if ( !checklistDetails.length ) {
|
|
991
|
+
return res.sendError( 'no data found', 204 );
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
let userDetails = [];
|
|
995
|
+
let storeList = [];
|
|
996
|
+
let userList = [];
|
|
997
|
+
await Promise.all( checklistDetails.map( async ( ele ) => {
|
|
998
|
+
if ( ele?.store_id || ele?.clusterName ) {
|
|
999
|
+
storeList.push( ele.assignId );
|
|
1000
|
+
} else {
|
|
1001
|
+
userList.push( ele.assignId );
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
if ( ele?.clusterName ) {
|
|
1005
|
+
let clusterDetails = await clusterServices.findOneCluster( { _id: ele.assignId }, { stores: 1 } );
|
|
1006
|
+
if ( clusterDetails ) {
|
|
1007
|
+
let storeDetails = await storeService.find( { _id: { $in: clusterDetails.stores.map( ( item ) => item.store ) } } );
|
|
1008
|
+
storeDetails.forEach( ( item ) => {
|
|
1009
|
+
userDetails.push( {
|
|
1010
|
+
id: ele._id,
|
|
1011
|
+
userName: item.spocDetails?.[0]?.name,
|
|
1012
|
+
userEmail: item.spocDetails?.[0]?.email,
|
|
1013
|
+
store_id: item?.storeId,
|
|
1014
|
+
storeName: item?.storeName,
|
|
1015
|
+
userPhone: item.spocDetails?.[0]?.phone,
|
|
1016
|
+
city: ele?.city,
|
|
1017
|
+
checkFlag: ele.checkFlag,
|
|
1018
|
+
clusterName: ele?.clusterName || '',
|
|
1019
|
+
teamName: ele?.teamName || '',
|
|
1020
|
+
} );
|
|
1021
|
+
} );
|
|
1022
|
+
}
|
|
1023
|
+
} else if ( ele?.teamName ) {
|
|
1024
|
+
let teamDetails = await teamsServices.findOneTeams( { _id: ele.assignId }, { users: 1, teamName: 1 } );
|
|
1025
|
+
if ( teamDetails ) {
|
|
1026
|
+
let teamUserDetails = await userService.find( { _id: { $in: teamDetails.users.map( ( item ) => item.userId ) } } );
|
|
1027
|
+
teamUserDetails.forEach( ( item ) => {
|
|
1028
|
+
userDetails.push( {
|
|
1029
|
+
id: ele._id,
|
|
1030
|
+
userName: item.userName,
|
|
1031
|
+
userEmail: item.email,
|
|
1032
|
+
store_id: ele?.storeId,
|
|
1033
|
+
storeName: ele?.storeName,
|
|
1034
|
+
userPhone: item?.mobileNumber,
|
|
1035
|
+
city: ele?.city,
|
|
1036
|
+
checkFlag: ele.checkFlag,
|
|
1037
|
+
clusterName: ele?.clusterName || '',
|
|
1038
|
+
teamName: ele?.teamName || '',
|
|
1039
|
+
} );
|
|
1040
|
+
} );
|
|
1041
|
+
}
|
|
1042
|
+
} else {
|
|
1043
|
+
userDetails.push( {
|
|
1044
|
+
id: ele._id,
|
|
1045
|
+
userName: ele.userName,
|
|
1046
|
+
userEmail: ele.userEmail,
|
|
1047
|
+
store_id: ele?.store_id,
|
|
1048
|
+
storeName: ele?.storeName,
|
|
1049
|
+
userPhone: ele.userPhone,
|
|
1050
|
+
city: ele.city,
|
|
1051
|
+
checkFlag: ele.checkFlag,
|
|
1052
|
+
clusterName: ele?.clusterName || '',
|
|
1053
|
+
teamName: ele?.teamName || '',
|
|
1054
|
+
} );
|
|
1055
|
+
}
|
|
1056
|
+
} ) );
|
|
1057
|
+
|
|
1058
|
+
return res.sendSuccess( { count: userDetails.length, storeList, userList, users: limitedData } );
|
|
1059
|
+
} catch ( e ) {
|
|
1060
|
+
logger.error( 'assignedUserDetails =>', e );
|
|
1061
|
+
return res.sendError( e, 500 );
|
|
1062
|
+
}
|
|
1063
|
+
};
|
|
1064
|
+
|
|
966
1065
|
export const runAIInsert = async ( req, res ) => {
|
|
967
1066
|
try {
|
|
968
1067
|
let requestData = req.body;
|
|
@@ -1471,18 +1570,19 @@ export const updateConfigurev1 =async ( req, res ) => {
|
|
|
1471
1570
|
response = await checklistService.create( configDetails );
|
|
1472
1571
|
id = response._id;
|
|
1473
1572
|
}
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1573
|
+
if ( inputBody.checkListDetails.assignedUsers.length ) {
|
|
1574
|
+
await assignedService.deleteMany( { checkListId: inputBody.checkListDetails._id } );
|
|
1575
|
+
await Promise.all( inputBody.checkListDetails.assignedUsers.map( async ( user ) => {
|
|
1576
|
+
let data = {
|
|
1577
|
+
...user,
|
|
1578
|
+
clientId: req.body.clientId,
|
|
1579
|
+
checkListName: checklistDetails.checkListName,
|
|
1580
|
+
checklistId: checklistDetails._id,
|
|
1581
|
+
coverage: checklistDetails.coverage,
|
|
1582
|
+
};
|
|
1583
|
+
await assignUsers( data );
|
|
1584
|
+
} ) );
|
|
1585
|
+
}
|
|
1486
1586
|
if ( inputBody.coverage ) {
|
|
1487
1587
|
await assignedService.deleteMany( { coverage: { $ne: inputBody.coverage } } );
|
|
1488
1588
|
}
|
|
@@ -2732,6 +2832,322 @@ async function insertPCBulkV3( getCLconfig, checklistId, currentdate, updatedche
|
|
|
2732
2832
|
}
|
|
2733
2833
|
}
|
|
2734
2834
|
|
|
2835
|
+
// async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedchecklist, date, startTimeIso, endTimeIso, insertdata, processId, oldData, editSubmit, showEdit ) {
|
|
2836
|
+
// let getquestionQuery = [];
|
|
2837
|
+
// if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection' ].includes( getCLconfig.checkListType ) ) {
|
|
2838
|
+
// getquestionQuery.push(
|
|
2839
|
+
// {
|
|
2840
|
+
// $match: {
|
|
2841
|
+
// checkListId: new ObjectId( checklistId ),
|
|
2842
|
+
// checkFlag: true,
|
|
2843
|
+
// },
|
|
2844
|
+
// },
|
|
2845
|
+
// {
|
|
2846
|
+
// $group: {
|
|
2847
|
+
// '_id': '$store_id',
|
|
2848
|
+
// 'store_id': { $first: '$store_id' },
|
|
2849
|
+
// 'client_id': { $first: '$client_id' },
|
|
2850
|
+
// 'storeName': { $first: '$storeName' },
|
|
2851
|
+
// 'userId': { $first: '$userId' },
|
|
2852
|
+
// 'userEmail': { $first: '$userEmail' },
|
|
2853
|
+
// 'userName': { $first: '$userName' },
|
|
2854
|
+
// 'checkFlag': { $first: '$checkFlag' },
|
|
2855
|
+
// 'checkListId': { $first: '$checkListId' },
|
|
2856
|
+
// 'checkListName': { $first: '$checkListName' },
|
|
2857
|
+
// 'country': { $first: '$country' },
|
|
2858
|
+
// 'createdAt': { $first: '$createdAt' },
|
|
2859
|
+
// 'updatedAt': { $first: '$updatedAt' },
|
|
2860
|
+
// },
|
|
2861
|
+
// },
|
|
2862
|
+
// );
|
|
2863
|
+
// } else {
|
|
2864
|
+
// getquestionQuery.push( {
|
|
2865
|
+
// $match: {
|
|
2866
|
+
// checkListId: new ObjectId( checklistId ),
|
|
2867
|
+
// checkFlag: true,
|
|
2868
|
+
// isdeleted: false,
|
|
2869
|
+
// },
|
|
2870
|
+
// } );
|
|
2871
|
+
// }
|
|
2872
|
+
// let allQuestion = await assignedService.aggregate( getquestionQuery );
|
|
2873
|
+
// if ( allQuestion ) {
|
|
2874
|
+
// let userIdList = [];
|
|
2875
|
+
// let tokenList = [];
|
|
2876
|
+
// let notifyUserList = [];
|
|
2877
|
+
// let status = [ { checklistStatus: { $ne: 'open' } } ];
|
|
2878
|
+
// let assignUserList = [];
|
|
2879
|
+
// await Promise.all( allQuestion.map( async ( element4 ) => {
|
|
2880
|
+
// let getToken = await userService.findOne( { _id: element4.userId }, { fcmToken: 1 } );
|
|
2881
|
+
// if ( getToken && getToken?.fcmToken && element4?.sendNotification && showEdit ) {
|
|
2882
|
+
// tokenList.push( getToken.fcmToken );
|
|
2883
|
+
// }
|
|
2884
|
+
// if ( !element4?.sendNotification ) {
|
|
2885
|
+
// notifyUserList.push( { token: getToken?.fcmToken, storeName: element4.storeName, id: element4._id } );
|
|
2886
|
+
// }
|
|
2887
|
+
// if ( !getCLconfig?.allowedMultiSubmit ) {
|
|
2888
|
+
// let query;
|
|
2889
|
+
// if ( getCLconfig.allowOnce && ![ 'onetime', 'daily' ].includes( getCLconfig.schedule ) ) {
|
|
2890
|
+
// if ( [ 'weekday', 'weekly', 'monthly' ].includes( getCLconfig.schedule ) ) {
|
|
2891
|
+
// let startDate; let endDate;
|
|
2892
|
+
// if ( [ 'weekday', 'weekly' ].includes( getCLconfig.schedule ) ) {
|
|
2893
|
+
// startDate = dayjs.utc( date ).clone().startOf( 'week' );
|
|
2894
|
+
// endDate = dayjs.utc( date ).clone().endOf( 'week' );
|
|
2895
|
+
// } else {
|
|
2896
|
+
// startDate = dayjs.utc( date ).clone().startOf( 'month' );
|
|
2897
|
+
// endDate = dayjs.utc( date ).clone().endOf( 'month' );
|
|
2898
|
+
// }
|
|
2899
|
+
// query = {
|
|
2900
|
+
// sourceCheckList_id: getCLconfig._id,
|
|
2901
|
+
// $or: [
|
|
2902
|
+
// { submitTime: { $exists: true } },
|
|
2903
|
+
// ...status,
|
|
2904
|
+
// ],
|
|
2905
|
+
// userId: element4.userId,
|
|
2906
|
+
// ...( getCLconfig.coverage == 'store' ) ? { store_id: element4.store_id }:{},
|
|
2907
|
+
// $and: [ {
|
|
2908
|
+
// date_iso: {
|
|
2909
|
+
// $gte: new Date( startDate.format( 'YYYY-MM-DD' ) ),
|
|
2910
|
+
// $lte: new Date( endDate.format( 'YYYY-MM-DD' ) ) },
|
|
2911
|
+
// } ],
|
|
2912
|
+
// };
|
|
2913
|
+
// } else {
|
|
2914
|
+
// if ( getCLconfig.schedule == 'range' ) {
|
|
2915
|
+
// query = {
|
|
2916
|
+
// sourceCheckList_id: getCLconfig._id,
|
|
2917
|
+
// $or: [
|
|
2918
|
+
// { submitTime: { $exists: true } },
|
|
2919
|
+
// ...status,
|
|
2920
|
+
// ],
|
|
2921
|
+
// userId: element4.userId,
|
|
2922
|
+
// ...( getCLconfig.coverage == 'store' ) ? { store_id: element4.store_id }:{},
|
|
2923
|
+
// $and: [
|
|
2924
|
+
// {
|
|
2925
|
+
// date_iso: {
|
|
2926
|
+
// $gte: new Date( dayjs( getCLconfig.configStartDate ).format( 'YYYY-MM-DD' ) ),
|
|
2927
|
+
// $lte: new Date( dayjs( getCLconfig.configEndDate ).format( 'YYYY-MM-DD' ) ),
|
|
2928
|
+
// },
|
|
2929
|
+
// },
|
|
2930
|
+
// ],
|
|
2931
|
+
// };
|
|
2932
|
+
// }
|
|
2933
|
+
// }
|
|
2934
|
+
// } else {
|
|
2935
|
+
// query = {
|
|
2936
|
+
// date_string: date,
|
|
2937
|
+
// sourceCheckList_id: getCLconfig._id,
|
|
2938
|
+
// $or: [
|
|
2939
|
+
// ...status,
|
|
2940
|
+
// { submitTime: { $exists: true } },
|
|
2941
|
+
// ],
|
|
2942
|
+
// userId: element4.userId,
|
|
2943
|
+
// ...( getCLconfig.coverage == 'store' ) ? { store_id: element4.store_id }:{},
|
|
2944
|
+
// };
|
|
2945
|
+
// }
|
|
2946
|
+
// let getsubmitDetails = await processedchecklist.find( query );
|
|
2947
|
+
// function findDifferences( obj1, obj2 ) {
|
|
2948
|
+
// return Object.keys( obj1 ).reduce( ( diff, key ) => {
|
|
2949
|
+
// if ( !isEqual( obj1[key], obj2[key] ) ) {
|
|
2950
|
+
// diff[key] = { value1: obj1[key], value2: obj2[key] };
|
|
2951
|
+
// }
|
|
2952
|
+
// return diff;
|
|
2953
|
+
// }, {} );
|
|
2954
|
+
// }
|
|
2955
|
+
// if ( getsubmitDetails.length ) {
|
|
2956
|
+
// if ( showEdit && ( ( editSubmit && getsubmitDetails[0].checklistStatus == 'submit' ) || getsubmitDetails[0].checklistStatus == 'inprogress' ) ) {
|
|
2957
|
+
// let modifiedCount = 0;
|
|
2958
|
+
// let questionList = insertdata.questionAnswers;
|
|
2959
|
+
// if ( getsubmitDetails[0].checkListName != getCLconfig.checkListName ) {
|
|
2960
|
+
// getsubmitDetails[0].checkListName = getCLconfig.checkListName;
|
|
2961
|
+
// }
|
|
2962
|
+
// if ( getsubmitDetails[0].checkListDescription != getCLconfig.checkListDescription ) {
|
|
2963
|
+
// getsubmitDetails[0].checkListDescription = getCLconfig.checkListDescription;
|
|
2964
|
+
// }
|
|
2965
|
+
// let sectionList = [];
|
|
2966
|
+
// for ( let [ index, section ] of questionList.entries() ) {
|
|
2967
|
+
// let checkExists = getsubmitDetails[0].questionAnswers.findIndex( ( sec ) => sec.sectionName == section?.sectionOldName || sec.sectionName == section.sectionName );
|
|
2968
|
+
// if ( checkExists != -1 ) {
|
|
2969
|
+
// getsubmitDetails[0].questionAnswers[index].section_id = section.section_id;
|
|
2970
|
+
// getsubmitDetails[0].questionAnswers[index].sectionName = section.sectionName;
|
|
2971
|
+
// let question = [];
|
|
2972
|
+
// section.questions.forEach( ( qns ) => {
|
|
2973
|
+
// let findQuestion = getsubmitDetails[0].questionAnswers[index].questions.findIndex( ( ele ) => ele.qname.trim() == qns?.oldQname?.trim() || ele.qname.trim() == qns.qname.trim() );
|
|
2974
|
+
// if ( findQuestion != -1 ) {
|
|
2975
|
+
// let data = JSON.parse( JSON.stringify( getsubmitDetails[0].questionAnswers[index].questions[findQuestion] ) );
|
|
2976
|
+
// getsubmitDetails[0].questionAnswers[index].questions[findQuestion].qno = qns.qno;
|
|
2977
|
+
// delete data.userAnswer;
|
|
2978
|
+
// delete data.parentanswer;
|
|
2979
|
+
// delete data.remarks;
|
|
2980
|
+
// delete data.linkquestionenabled;
|
|
2981
|
+
// if ( data.descriptivetype == null ) {
|
|
2982
|
+
// delete data.descriptivetype;
|
|
2983
|
+
// }
|
|
2984
|
+
// qns.answers.forEach( ( ans ) => {
|
|
2985
|
+
// delete ans.validationAnswer;
|
|
2986
|
+
// delete ans.answeroptionNumber;
|
|
2987
|
+
// } );
|
|
2988
|
+
// data.answers.forEach( ( ans ) => {
|
|
2989
|
+
// delete ans.index;
|
|
2990
|
+
// delete ans.validationAnswer;
|
|
2991
|
+
// delete ans.answeroptionNumber;
|
|
2992
|
+
// } );
|
|
2993
|
+
// const compare = findDifferences( data, qns );
|
|
2994
|
+
// if ( compare?.answerType || compare?.answers || compare?.linkType ) {
|
|
2995
|
+
// logger.info( 'compare =>', compare );
|
|
2996
|
+
// modifiedCount++;
|
|
2997
|
+
// question.push( qns );
|
|
2998
|
+
// } else {
|
|
2999
|
+
// getsubmitDetails[0].questionAnswers[index].questions[findQuestion].qname = qns.qname;
|
|
3000
|
+
// question.push( getsubmitDetails[0].questionAnswers[index].questions[findQuestion] );
|
|
3001
|
+
// }
|
|
3002
|
+
// } else {
|
|
3003
|
+
// modifiedCount++;
|
|
3004
|
+
// question.push( qns );
|
|
3005
|
+
// }
|
|
3006
|
+
// } );
|
|
3007
|
+
// getsubmitDetails[0].questionAnswers[index].questions = question;
|
|
3008
|
+
// sectionList.push( getsubmitDetails[0].questionAnswers[index] );
|
|
3009
|
+
// } else {
|
|
3010
|
+
// modifiedCount++;
|
|
3011
|
+
// sectionList.push( section );
|
|
3012
|
+
// }
|
|
3013
|
+
// }
|
|
3014
|
+
// getsubmitDetails[0].questionAnswers = sectionList;
|
|
3015
|
+
// if ( modifiedCount ) {
|
|
3016
|
+
// getsubmitDetails[0].checklistStatus = 'inprogress';
|
|
3017
|
+
// getsubmitDetails[0].date_string = dayjs( currentdate ).format( 'YYYY-MM-DD' );
|
|
3018
|
+
// getsubmitDetails[0].date_iso = new Date( date );
|
|
3019
|
+
// getsubmitDetails[0].redoStatus = false;
|
|
3020
|
+
// getsubmitDetails[0].approvalStatus = false;
|
|
3021
|
+
// }
|
|
3022
|
+
// let data = { ...getsubmitDetails[0]._doc };
|
|
3023
|
+
// await processedchecklist.updateOne( { _id: getsubmitDetails[0]._id }, data );
|
|
3024
|
+
// if ( editSubmit && getsubmitDetails[0].checklistStatus == 'submit' ) {
|
|
3025
|
+
// console.log( editSubmit );
|
|
3026
|
+
// let user = {
|
|
3027
|
+
// _id: getsubmitDetails[0].userId,
|
|
3028
|
+
// clientId: getsubmitDetails[0].client_id,
|
|
3029
|
+
// };
|
|
3030
|
+
// updateOpenSearch( user, { processedcheckListId: getsubmitDetails[0]._id, date: getsubmitDetails[0].date_string } );
|
|
3031
|
+
// }
|
|
3032
|
+
// }
|
|
3033
|
+
// if ( getsubmitDetails[0]?.checklistStatus == 'submit' ) {
|
|
3034
|
+
// userIdList.push( element4._id );
|
|
3035
|
+
// }
|
|
3036
|
+
// }
|
|
3037
|
+
// }
|
|
3038
|
+
// delete element4._id;
|
|
3039
|
+
// delete element4.checkFlag;
|
|
3040
|
+
// delete element4.isdeleted;
|
|
3041
|
+
// delete element4.createdAt;
|
|
3042
|
+
// delete element4.updatedAt;
|
|
3043
|
+
// element4.checkListId = updatedchecklist._id;
|
|
3044
|
+
// element4.checkListName = getCLconfig.checkListName;
|
|
3045
|
+
// element4.checkListDescription = getCLconfig.checkListDescription;
|
|
3046
|
+
// element4.date_iso = new Date( date );
|
|
3047
|
+
// element4.date_string = dayjs( currentdate ).format( 'YYYY-MM-DD' );
|
|
3048
|
+
// element4.allowedOverTime = getCLconfig.allowedOverTime;
|
|
3049
|
+
// element4.allowedStoreLocation = getCLconfig.allowedStoreLocation;
|
|
3050
|
+
// element4.scheduleStartTime = getCLconfig.scheduleStartTime;
|
|
3051
|
+
// element4.scheduleStartTime_iso = startTimeIso.format();
|
|
3052
|
+
// element4.scheduleEndTime = getCLconfig.scheduleEndTime;
|
|
3053
|
+
// element4.scheduleEndTime_iso = endTimeIso.format();
|
|
3054
|
+
// element4.createdBy = new ObjectId( getCLconfig.createdBy );
|
|
3055
|
+
// element4.createdByName = getCLconfig.createdByName;
|
|
3056
|
+
// element4.sourceCheckList_id = getCLconfig._id;
|
|
3057
|
+
// element4.checkListType = getCLconfig.checkListType;
|
|
3058
|
+
// element4.storeCount = getCLconfig.storeCount;
|
|
3059
|
+
// element4.questionCount = getCLconfig.questionCount;
|
|
3060
|
+
// element4.publishDate = getCLconfig.publishDate;
|
|
3061
|
+
// element4.locationCount = getCLconfig.locationCount;
|
|
3062
|
+
// element4.scheduleRepeatedType = getCLconfig.scheduleRepeatedType;
|
|
3063
|
+
// element4.approvalEnable = getCLconfig.approver.length ? true : false;
|
|
3064
|
+
// element4.remainder = getCLconfig?.remainder || [];
|
|
3065
|
+
// element4.restrictAttendance = getCLconfig?.restrictAttendance;
|
|
3066
|
+
// assignUserList.push( { ...element4 } );
|
|
3067
|
+
// } ) );
|
|
3068
|
+
|
|
3069
|
+
// if ( userIdList.length ) {
|
|
3070
|
+
// assignUserList = assignUserList.filter( ( item ) => typeof item._id == 'undefined' );
|
|
3071
|
+
// }
|
|
3072
|
+
// if ( assignUserList ) {
|
|
3073
|
+
// if ( getCLconfig?.allowedMultiSubmit || processId ) {
|
|
3074
|
+
// if ( processId ) {
|
|
3075
|
+
// let processedDetails = await processedchecklist.findOne( { _id: processId } );
|
|
3076
|
+
// if ( processedDetails ) {
|
|
3077
|
+
// let submitUser = assignUserList.find( ( item ) => getCLconfig.coverage == 'store' ? item.userId.toString() == processedDetails.userId.toString() && item.store_id == processedDetails.store_id : item.userId.toString() == processedDetails.userId.toString() );
|
|
3078
|
+
// await processedchecklist.insertMany( submitUser );
|
|
3079
|
+
// }
|
|
3080
|
+
// } else {
|
|
3081
|
+
// let deleteInprogressQuery = {
|
|
3082
|
+
// date_string: insertdata.date_string,
|
|
3083
|
+
// date_iso: insertdata.date_iso,
|
|
3084
|
+
// client_id: insertdata.client_id,
|
|
3085
|
+
// checkListId: updatedchecklist._id,
|
|
3086
|
+
// checklistStatus: { $nin: [ 'submit', 'inprogress' ] },
|
|
3087
|
+
// redoStatus: false,
|
|
3088
|
+
// };
|
|
3089
|
+
// await processedchecklist.deleteMany( deleteInprogressQuery );
|
|
3090
|
+
// deleteInprogressQuery.checklistStatus = 'inprogress';
|
|
3091
|
+
// deleteInprogressQuery.redoStatus = false;
|
|
3092
|
+
// let getInprogressData = await processedchecklist.find( deleteInprogressQuery, { userId: 1, store_id: 1 } );
|
|
3093
|
+
// if ( getInprogressData ) {
|
|
3094
|
+
// assignUserList = assignUserList.filter( ( item ) => {
|
|
3095
|
+
// let inprogressData = getInprogressData.find( ( ele ) => getCLconfig.coverage == 'store' ? ele.userId.toString() == item.userId.toString() && ele.store_id == item.store_id : ele.userId.toString() == item.userId.toString() );
|
|
3096
|
+
// if ( !inprogressData ) {
|
|
3097
|
+
// return item;
|
|
3098
|
+
// }
|
|
3099
|
+
// } );
|
|
3100
|
+
// }
|
|
3101
|
+
// if ( assignUserList.length ) {
|
|
3102
|
+
// await processedchecklist.insertMany( assignUserList );
|
|
3103
|
+
// }
|
|
3104
|
+
// }
|
|
3105
|
+
// } else {
|
|
3106
|
+
// let unAssignedList = assignUserList.reduce( ( acc, item ) => {
|
|
3107
|
+
// if ( !acc[item.userEmail] ) {
|
|
3108
|
+
// acc[item.userEmail]=[ item.store_id ];
|
|
3109
|
+
// } else {
|
|
3110
|
+
// acc[item.userEmail].push( item.store_id );
|
|
3111
|
+
// }
|
|
3112
|
+
// return acc;
|
|
3113
|
+
// }, {} );
|
|
3114
|
+
|
|
3115
|
+
// let userList = Object.keys( unAssignedList );
|
|
3116
|
+
|
|
3117
|
+
// await processedchecklist.deleteMany( { userEmail: { $nin: userList }, date_string: insertdata.date_string, date_iso: insertdata.date_iso, client_id: insertdata.client_id, checkListId: updatedchecklist._id, checklistStatus: { $nin: [ 'submit' ] } } );
|
|
3118
|
+
|
|
3119
|
+
// for ( let key in unAssignedList ) {
|
|
3120
|
+
// if ( unAssignedList.hasOwnProperty( key ) ) {
|
|
3121
|
+
// await processedchecklist.deleteMany( { date_string: insertdata.date_string, date_iso: insertdata.date_iso, client_id: insertdata.client_id, checkListId: updatedchecklist._id, $and: [ { userEmail: key }, { store_id: { $nin: unAssignedList[key] } } ], checklistStatus: { $nin: [ 'submit' ] } } );
|
|
3122
|
+
// }
|
|
3123
|
+
// }
|
|
3124
|
+
|
|
3125
|
+
|
|
3126
|
+
// Promise.all( assignUserList.map( async ( ele ) => {
|
|
3127
|
+
// await processedchecklist.updateOne( { date_string: insertdata.date_string, date_iso: insertdata.date_iso, client_id: insertdata.client_id, checkListId: updatedchecklist._id, userEmail: ele.userEmail, store_id: ele.store_id }, ele );
|
|
3128
|
+
// } ) );
|
|
3129
|
+
// }
|
|
3130
|
+
|
|
3131
|
+
// tokenList.forEach( ( item ) => {
|
|
3132
|
+
// const title = `${getCLconfig.checkListName}`;
|
|
3133
|
+
// const description = `Checklist has been updated and re-published!`;
|
|
3134
|
+
// const fcmToken = item;
|
|
3135
|
+
// sendPushNotification( title, description, fcmToken );
|
|
3136
|
+
// } );
|
|
3137
|
+
|
|
3138
|
+
// notifyUserList.forEach( ( item ) => {
|
|
3139
|
+
// const title = `New Checklist Assigned ${item.storeName}`;
|
|
3140
|
+
// const description = `The ${getCLconfig.checkListName} checklist has been assigned to ${item.storeName} for the first time.complete to avoid compliance.`;
|
|
3141
|
+
// const fcmToken = item.token;
|
|
3142
|
+
// sendPushNotification( title, description, fcmToken );
|
|
3143
|
+
// } );
|
|
3144
|
+
|
|
3145
|
+
// let updateUserList = notifyUserList.map( ( ele ) => ele.id );
|
|
3146
|
+
// await assignedService.updateMany( { _id: { $in: updateUserList } }, { sendNotification: true } );
|
|
3147
|
+
// }
|
|
3148
|
+
// }
|
|
3149
|
+
// }
|
|
3150
|
+
|
|
2735
3151
|
async function updateOpenSearch( user, data ) {
|
|
2736
3152
|
let findQuery = [ {
|
|
2737
3153
|
$match: {
|
|
@@ -3029,81 +3445,135 @@ async function assignUsers( data ) {
|
|
|
3029
3445
|
let assignedData;
|
|
3030
3446
|
if ( data.coverage == 'store' ) {
|
|
3031
3447
|
if ( data?.type == 'cluster' ) {
|
|
3032
|
-
let query =
|
|
3033
|
-
|
|
3034
|
-
|
|
3448
|
+
let query = [
|
|
3449
|
+
{
|
|
3450
|
+
$addFields: {
|
|
3451
|
+
cluster: { $toLower: '$clusterName' },
|
|
3452
|
+
},
|
|
3453
|
+
},
|
|
3454
|
+
{
|
|
3455
|
+
$match: {
|
|
3456
|
+
clientId: data.clientId,
|
|
3457
|
+
...( !data?.upload ) ? { _id: new mongoose.Types.ObjectId( data.id ) } : { cluster: data.clusterName.toLowerCase() },
|
|
3458
|
+
},
|
|
3459
|
+
},
|
|
3460
|
+
{
|
|
3461
|
+
$project: {
|
|
3462
|
+
stores: 1,
|
|
3463
|
+
clusterName: 1,
|
|
3464
|
+
},
|
|
3465
|
+
},
|
|
3466
|
+
];
|
|
3467
|
+
let clusterDetails = await clusterServices.aggregate( query );
|
|
3468
|
+
if ( clusterDetails.length ) {
|
|
3035
3469
|
assignedData = {
|
|
3036
3470
|
checkFlag: true,
|
|
3037
3471
|
checkListId: data.checklistId,
|
|
3038
3472
|
checkListName: data.checkListName,
|
|
3039
3473
|
client_id: data?.clientId,
|
|
3040
|
-
clusterName: clusterDetails?.clusterName,
|
|
3041
|
-
assignId: data?.id || clusterDetails?._id,
|
|
3474
|
+
clusterName: clusterDetails?.[0]?.clusterName,
|
|
3475
|
+
assignId: data?.id || clusterDetails?.[0]?._id,
|
|
3042
3476
|
coverage: 'store',
|
|
3043
3477
|
};
|
|
3044
3478
|
}
|
|
3045
3479
|
} else {
|
|
3046
|
-
let query =
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3480
|
+
let query = [
|
|
3481
|
+
{
|
|
3482
|
+
$addFields: {
|
|
3483
|
+
store: { $toLower: '$storeName' },
|
|
3484
|
+
},
|
|
3485
|
+
},
|
|
3486
|
+
{
|
|
3487
|
+
$match: {
|
|
3488
|
+
clientId: data.clientId,
|
|
3489
|
+
...( !data.upload ) ? { _id: new mongoose.Types.ObjectId( data.id ) } : { store: data.storeName.toLowerCase() },
|
|
3490
|
+
},
|
|
3491
|
+
},
|
|
3492
|
+
];
|
|
3493
|
+
let storeDetails = await storeService.aggregate( query );
|
|
3494
|
+
if ( storeDetails.length ) {
|
|
3495
|
+
let email = data?.upload ? data.userEmail : storeDetails?.[0]?.spocDetails?.email;
|
|
3050
3496
|
let userDetails = await userService.findOne( { email: email, clientId: data.clientId } );
|
|
3051
3497
|
if ( !userDetails ) {
|
|
3052
3498
|
let userData = {
|
|
3053
|
-
userName: storeDetails
|
|
3054
|
-
email: storeDetails
|
|
3055
|
-
mobileNumber: storeDetails
|
|
3499
|
+
userName: storeDetails?.[0]?.spocDetails?.[0]?.name,
|
|
3500
|
+
email: storeDetails?.[0]?.spocDetails[0].email,
|
|
3501
|
+
mobileNumber: storeDetails?.[0]?.spocDetails?.[0]?.phone,
|
|
3056
3502
|
clientId: data.clientId,
|
|
3057
3503
|
};
|
|
3058
3504
|
userDetails = createUser( userData );
|
|
3059
3505
|
}
|
|
3060
3506
|
assignedData = {
|
|
3061
|
-
store_id: storeDetails
|
|
3062
|
-
storeName: storeDetails
|
|
3507
|
+
store_id: storeDetails?.[0]?.storeId,
|
|
3508
|
+
storeName: storeDetails?.[0]?.storeName,
|
|
3063
3509
|
userId: userDetails._id,
|
|
3064
3510
|
userName: userDetails.userName,
|
|
3065
3511
|
userEmail: userDetails.email,
|
|
3066
3512
|
userPhone: userDetails?.mobileNumber,
|
|
3067
|
-
city: storeDetails?.storeProfile?.city,
|
|
3068
|
-
country: storeDetails?.storeProfile?.country,
|
|
3513
|
+
city: storeDetails?.[0]?.storeProfile?.city,
|
|
3514
|
+
country: storeDetails?.[0]?.storeProfile?.country,
|
|
3069
3515
|
checkFlag: true,
|
|
3070
3516
|
checkListId: data.checklistId,
|
|
3071
3517
|
checkListName: data.checkListName,
|
|
3072
3518
|
client_id: data.clientId,
|
|
3073
|
-
assignId: data?.id || storeDetails
|
|
3519
|
+
assignId: data?.id || storeDetails?.[0]?._id,
|
|
3074
3520
|
coverage: 'store',
|
|
3075
3521
|
};
|
|
3076
3522
|
}
|
|
3077
3523
|
}
|
|
3078
3524
|
} else {
|
|
3079
3525
|
if ( data.type == 'teams' ) {
|
|
3080
|
-
let query =
|
|
3081
|
-
|
|
3082
|
-
|
|
3526
|
+
let query = [
|
|
3527
|
+
{
|
|
3528
|
+
$addFields: {
|
|
3529
|
+
team: { $toLower: '$teamName' },
|
|
3530
|
+
},
|
|
3531
|
+
},
|
|
3532
|
+
{
|
|
3533
|
+
$match: {
|
|
3534
|
+
clientId: data.clientId,
|
|
3535
|
+
...( !data?.upload ) ? { _id: new mongoose.Types.ObjectId( data.id ) } : { team: data.teamName.toLowerCase() },
|
|
3536
|
+
},
|
|
3537
|
+
},
|
|
3538
|
+
];
|
|
3539
|
+
let teamDetails = await teamsServices.aggregate( query );
|
|
3540
|
+
if ( teamDetails.length ) {
|
|
3083
3541
|
assignedData = {
|
|
3084
3542
|
checkFlag: true,
|
|
3085
3543
|
checkListId: data.checklistId,
|
|
3086
3544
|
checkListName: data.checkListName,
|
|
3087
3545
|
client_id: data.clientId,
|
|
3088
|
-
teamName: teamDetails?.teamName,
|
|
3089
|
-
assignId: data?.id || teamDetails?._id,
|
|
3546
|
+
teamName: teamDetails?.[0]?.teamName,
|
|
3547
|
+
assignId: data?.id || teamDetails?.[0]?._id,
|
|
3090
3548
|
coverage: 'user',
|
|
3091
3549
|
};
|
|
3092
3550
|
}
|
|
3093
3551
|
} else {
|
|
3094
|
-
let query =
|
|
3095
|
-
|
|
3096
|
-
|
|
3552
|
+
let query = [
|
|
3553
|
+
{
|
|
3554
|
+
$addFields: {
|
|
3555
|
+
userEmail: { $toLower: '$email' },
|
|
3556
|
+
},
|
|
3557
|
+
},
|
|
3558
|
+
{
|
|
3559
|
+
$match: {
|
|
3560
|
+
clientId: data.clientId,
|
|
3561
|
+
...( !data?.upload ) ? { _id: new mongoose.Types.ObjectId( data.id ) } : { userEmail: data.email.toLowerCase() },
|
|
3562
|
+
},
|
|
3563
|
+
},
|
|
3564
|
+
];
|
|
3565
|
+
let userDetails = await userService.aggregate( query );
|
|
3566
|
+
if ( userDetails.length ) {
|
|
3097
3567
|
assignedData = {
|
|
3098
|
-
userId: userDetails
|
|
3099
|
-
userName: userDetails
|
|
3100
|
-
userEmail: userDetails
|
|
3101
|
-
userPhone: userDetails?.mobileNumber,
|
|
3568
|
+
userId: userDetails?.[0]?._id,
|
|
3569
|
+
userName: userDetails?.[0]?.userName,
|
|
3570
|
+
userEmail: userDetails?.[0]?.email,
|
|
3571
|
+
userPhone: userDetails?.[0]?.mobileNumber,
|
|
3102
3572
|
checkFlag: true,
|
|
3103
3573
|
checkListId: data.checklistId,
|
|
3104
3574
|
checkListName: data.checkListName,
|
|
3105
3575
|
client_id: data.clientId,
|
|
3106
|
-
assignId: data?.id || userDetails?._id,
|
|
3576
|
+
assignId: data?.id || userDetails?.[0]?._id,
|
|
3107
3577
|
coverage: 'user',
|
|
3108
3578
|
};
|
|
3109
3579
|
}
|
|
@@ -3116,28 +3586,156 @@ async function assignUsers( data ) {
|
|
|
3116
3586
|
|
|
3117
3587
|
export async function checklistAssign( req, res ) {
|
|
3118
3588
|
try {
|
|
3119
|
-
if ( !req.body.coverage ) {
|
|
3120
|
-
return res.sendError( 'coverage is required', 400 );
|
|
3121
|
-
}
|
|
3122
|
-
if ( !req.body.idList ) {
|
|
3123
|
-
return res.sendError( 'Id list is required', 400 );
|
|
3124
|
-
}
|
|
3125
3589
|
if ( !req.body.checklistId ) {
|
|
3126
3590
|
return res.sendError( 'Checklist id is required', 400 );
|
|
3127
3591
|
}
|
|
3128
|
-
if ( !req.body.
|
|
3129
|
-
return res.sendError( '
|
|
3592
|
+
if ( !req.body.coverage ) {
|
|
3593
|
+
return res.sendError( 'Coverage is required', 400 );
|
|
3130
3594
|
}
|
|
3595
|
+
if ( !req.body.idList ) {
|
|
3596
|
+
return res.sendError( 'Id is required', 400 );
|
|
3597
|
+
}
|
|
3598
|
+
|
|
3131
3599
|
let checklistDetails = await checklistService.findOne( { _id: req.body.checklistId } );
|
|
3132
3600
|
if ( !checklistDetails ) {
|
|
3133
3601
|
return res.sendError( 'No data found', 204 );
|
|
3134
3602
|
}
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
await
|
|
3139
|
-
|
|
3140
|
-
|
|
3603
|
+
let idList;
|
|
3604
|
+
let assignList;
|
|
3605
|
+
if ( req.body.coverage == 'store' ) {
|
|
3606
|
+
let clusterDetails = await clusterServices.findcluster( { _id: { $in: req.body.idList } }, { stores: 1, clusterName: 1 } );
|
|
3607
|
+
if ( clusterDetails.length ) {
|
|
3608
|
+
idList = clusterDetails.flatMap( ( item ) => item.stores.map( ( ele ) => ele.store ) );
|
|
3609
|
+
let storeList = clusterDetails.filter( ( ele ) => !req.body.idList.includes( ele._id.toString() ) ).map( ( ele ) => ele._id );
|
|
3610
|
+
idList = [ ...idList, ...storeList ];
|
|
3611
|
+
} else {
|
|
3612
|
+
idList = req.body.idList;
|
|
3613
|
+
}
|
|
3614
|
+
let getStoreDetails = await storeService.find( { _id: { $in: idList } } );
|
|
3615
|
+
if ( !getStoreDetails.length ) {
|
|
3616
|
+
return res.sendError( 'No data found', 204 );
|
|
3617
|
+
}
|
|
3618
|
+
assignList = await Promise.all( getStoreDetails.map( async ( store ) => {
|
|
3619
|
+
let userDetails = await userService.findOne( { userEmail: store?.spocDetails?.email, clientId: store.clientId } );
|
|
3620
|
+
if ( !userDetails ) {
|
|
3621
|
+
let data = {
|
|
3622
|
+
clientId: store.clientId,
|
|
3623
|
+
userName: store.spocDetails?.[0]?.name,
|
|
3624
|
+
mobileNumber: store.spocDetails?.[0]?.phone || '',
|
|
3625
|
+
email: store.spocDetails[0].email,
|
|
3626
|
+
password: '5dqFKAJj29PsV6P+kL+3Dw==',
|
|
3627
|
+
role: 'user',
|
|
3628
|
+
userType: 'client',
|
|
3629
|
+
rolespermission: [
|
|
3630
|
+
{
|
|
3631
|
+
featureName: 'Global',
|
|
3632
|
+
modules: [
|
|
3633
|
+
{
|
|
3634
|
+
name: 'Store',
|
|
3635
|
+
isAdd: false,
|
|
3636
|
+
isEdit: false,
|
|
3637
|
+
|
|
3638
|
+
},
|
|
3639
|
+
{
|
|
3640
|
+
name: 'User',
|
|
3641
|
+
isAdd: false,
|
|
3642
|
+
isEdit: false,
|
|
3643
|
+
|
|
3644
|
+
},
|
|
3645
|
+
{
|
|
3646
|
+
name: 'Camera',
|
|
3647
|
+
isAdd: false,
|
|
3648
|
+
isEdit: false,
|
|
3649
|
+
|
|
3650
|
+
},
|
|
3651
|
+
{
|
|
3652
|
+
name: 'Configuration',
|
|
3653
|
+
isAdd: false,
|
|
3654
|
+
isEdit: false,
|
|
3655
|
+
|
|
3656
|
+
},
|
|
3657
|
+
{
|
|
3658
|
+
name: 'Subscription',
|
|
3659
|
+
isAdd: false,
|
|
3660
|
+
isEdit: false,
|
|
3661
|
+
|
|
3662
|
+
},
|
|
3663
|
+
{
|
|
3664
|
+
name: 'Billing',
|
|
3665
|
+
isAdd: false,
|
|
3666
|
+
isEdit: false,
|
|
3667
|
+
|
|
3668
|
+
},
|
|
3669
|
+
],
|
|
3670
|
+
},
|
|
3671
|
+
{
|
|
3672
|
+
featurName: 'TangoEye',
|
|
3673
|
+
modules: [
|
|
3674
|
+
{
|
|
3675
|
+
name: 'ZoneTag',
|
|
3676
|
+
isAdd: false,
|
|
3677
|
+
isEdit: false,
|
|
3678
|
+
|
|
3679
|
+
},
|
|
3680
|
+
],
|
|
3681
|
+
},
|
|
3682
|
+
{
|
|
3683
|
+
featurName: 'TangoTrax',
|
|
3684
|
+
modules: [
|
|
3685
|
+
{
|
|
3686
|
+
name: 'checklist',
|
|
3687
|
+
isAdd: false,
|
|
3688
|
+
isEdit: false,
|
|
3689
|
+
|
|
3690
|
+
},
|
|
3691
|
+
{
|
|
3692
|
+
name: 'Task',
|
|
3693
|
+
isAdd: false,
|
|
3694
|
+
isEdit: false,
|
|
3695
|
+
|
|
3696
|
+
},
|
|
3697
|
+
],
|
|
3698
|
+
},
|
|
3699
|
+
],
|
|
3700
|
+
};
|
|
3701
|
+
userDetails = await userService.create( data );
|
|
3702
|
+
}
|
|
3703
|
+
let data = {
|
|
3704
|
+
store_id: store.storeId,
|
|
3705
|
+
storeName: store.storeName,
|
|
3706
|
+
userId: userDetails._id,
|
|
3707
|
+
userName: userDetails.userName,
|
|
3708
|
+
userEmail: userDetails.email,
|
|
3709
|
+
userPhone: userDetails?.mobileNumber,
|
|
3710
|
+
clusterName: clusterDetails?.clusterName,
|
|
3711
|
+
};
|
|
3712
|
+
return data;
|
|
3713
|
+
} ) );
|
|
3714
|
+
} else {
|
|
3715
|
+
let teamDetails = await teamsServices.findteams( { _id: { $in: req.body.idList } }, { users: 1, teamName: 1 } );
|
|
3716
|
+
if ( teamDetails.length ) {
|
|
3717
|
+
idList = teamDetails.flatMap( ( item ) => item.users.map( ( ele ) => ele.userId ) );
|
|
3718
|
+
let userList = teamDetails.filter( ( ele ) => !req.body.idList.includes( ele._id.toString() ) );
|
|
3719
|
+
idList = [ ...idList, ...userList ];
|
|
3720
|
+
} else {
|
|
3721
|
+
idList = req.body.idList;
|
|
3722
|
+
}
|
|
3723
|
+
let userDetails = await userService.find( { _id: { $in: idList } } );
|
|
3724
|
+
if ( !userDetails.length ) {
|
|
3725
|
+
return res.sendError( 'No data found', 204 );
|
|
3726
|
+
}
|
|
3727
|
+
assignList = [];
|
|
3728
|
+
userDetails.forEach( ( user ) => {
|
|
3729
|
+
assignList.push( {
|
|
3730
|
+
userId: user._id,
|
|
3731
|
+
userName: user.userName,
|
|
3732
|
+
userEmail: user.email,
|
|
3733
|
+
userPhone: user?.mobileNumber,
|
|
3734
|
+
teamName: teamDetails?.teamName,
|
|
3735
|
+
} );
|
|
3736
|
+
} );
|
|
3737
|
+
}
|
|
3738
|
+
return res.sendSuccess( { count: assignList.length, assignList } );
|
|
3141
3739
|
} catch ( e ) {
|
|
3142
3740
|
logger.error( { functionName: 'checklistAssign', error: e } );
|
|
3143
3741
|
return res.sendError( e, 500 );
|
|
@@ -3156,7 +3754,7 @@ export async function checklistAssign( req, res ) {
|
|
|
3156
3754
|
// if ( !checklistDetails ) {
|
|
3157
3755
|
// return res.sendError( 'No data found', 204 );
|
|
3158
3756
|
// }
|
|
3159
|
-
// await assignedService.
|
|
3757
|
+
// await assignedService.deleteMany( { assignId: { $in: req.body.id } } );
|
|
3160
3758
|
// return res.sendSuccess( 'Details removed successfully' );
|
|
3161
3759
|
// } catch ( e ) {
|
|
3162
3760
|
// logger.error( { functionName: 'removeAssign', error: e } );
|
|
@@ -3164,19 +3762,19 @@ export async function checklistAssign( req, res ) {
|
|
|
3164
3762
|
// }
|
|
3165
3763
|
// }
|
|
3166
3764
|
|
|
3167
|
-
export async function deleteAssignList( req, res ) {
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
}
|
|
3765
|
+
// export async function deleteAssignList( req, res ) {
|
|
3766
|
+
// try {
|
|
3767
|
+
// if ( !req.body.checkListId ) {
|
|
3768
|
+
// return res.sendError( 'Checklist id is required', 400 );
|
|
3769
|
+
// }
|
|
3770
|
+
// let checklistDetails = await checklistService.findOne( { _id: req.body.checkListId, isdeleted: false } );
|
|
3771
|
+
// if ( !checklistDetails ) {
|
|
3772
|
+
// return res.sendError( 'No data found', 204 );
|
|
3773
|
+
// }
|
|
3774
|
+
// await assignedService.updateMany( { checkListId: req.body.checkListId }, { isdeleted: true } );
|
|
3775
|
+
// return res.sendSuccess( 'Assign details removed successfully' );
|
|
3776
|
+
// } catch ( e ) {
|
|
3777
|
+
// logger.error( { functionName: 'deleteAssignList', error: e } );
|
|
3778
|
+
// return res.sendError( e, 500 );
|
|
3779
|
+
// }
|
|
3780
|
+
// }
|
|
@@ -16,6 +16,7 @@ traxRouter
|
|
|
16
16
|
.post( '/validateUser', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ 'isEdit' ] } ] } ), validate( uploadUserValidation ), traxController.validateUser )
|
|
17
17
|
.post( '/validateUserv1', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ 'isEdit' ] } ] } ), validate( uploadUserValidation ), traxController.validateUserv1 )
|
|
18
18
|
.get( '/userDetails/:checklistId', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ ] } ] } ), validate( duplicateValidation ), traxController.assignedUserDetails )
|
|
19
|
+
.get( '/userDetailsv1/:checklistId', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ ] } ] } ), validate( duplicateValidation ), traxController.assignedUserDetailsv1 )
|
|
19
20
|
.post( '/checklistConfigure', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ 'isEdit' ] } ] } ), traxController.updateConfigure )
|
|
20
21
|
.post( '/checklistConfigurev1', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ 'isEdit' ] } ] } ), traxController.updateConfigurev1 )
|
|
21
22
|
.delete( '/deleteChecklist/:checklistId', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ 'isEdit' ] } ] } ), validate( duplicateValidation ), traxController.deleteChecklist )
|
|
@@ -27,7 +28,7 @@ traxRouter
|
|
|
27
28
|
.post( '/selectAssign', validate( selectAssign ), traxController.selectAssign )
|
|
28
29
|
.post( '/assign', isAllowedSessionHandler, traxController.checklistAssign )
|
|
29
30
|
// .post( '/remove', isAllowedSessionHandler, traxController.removeAssign )
|
|
30
|
-
.post( '/removeAssignList', isAllowedSessionHandler, traxController.deleteAssignList )
|
|
31
|
+
// .post( '/removeAssignList', isAllowedSessionHandler, traxController.deleteAssignList )
|
|
31
32
|
.post( '/assignUpload', isAllowedSessionHandler, traxController.assignChecklistUser );
|
|
32
33
|
|
|
33
34
|
// isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ ] } ] } ),
|