tango-app-api-trax 3.3.1-beta-17 → 3.3.1-beta-18
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 +1 -1
- package/src/controllers/download.controller.js +38 -14
- package/src/controllers/gallery.controller.js +114 -22
- package/src/controllers/trax.controller.js +73 -671
- package/src/dtos/downloadValidation.dtos.js +2 -0
- package/src/hbs/login-otp.hbs +943 -943
- package/src/routes/gallery.routes.js +5 -1
- package/src/routes/trax.routes.js +1 -2
|
@@ -963,105 +963,6 @@ 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
|
-
|
|
1065
966
|
export const runAIInsert = async ( req, res ) => {
|
|
1066
967
|
try {
|
|
1067
968
|
let requestData = req.body;
|
|
@@ -1570,19 +1471,18 @@ export const updateConfigurev1 =async ( req, res ) => {
|
|
|
1570
1471
|
response = await checklistService.create( configDetails );
|
|
1571
1472
|
id = response._id;
|
|
1572
1473
|
}
|
|
1573
|
-
if ( inputBody.checkListDetails.assignedUsers.length ) {
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
}
|
|
1474
|
+
// if ( inputBody.checkListDetails.assignedUsers.length ) {
|
|
1475
|
+
// await assignedService.deleteMany( { checkListId: inputBody.checkListDetails._id } );
|
|
1476
|
+
// await Promise.all( inputBody.checkListDetails.assignedUsers.map( async ( user ) => {
|
|
1477
|
+
// let data = {
|
|
1478
|
+
// ...user,
|
|
1479
|
+
// clientId: req.body.clientId,
|
|
1480
|
+
// checkListName: checklistDetails.checkListName,
|
|
1481
|
+
// checklistId: checklistDetails._id,
|
|
1482
|
+
// };
|
|
1483
|
+
// await assignUsers( data );
|
|
1484
|
+
// } ) );
|
|
1485
|
+
// }
|
|
1586
1486
|
if ( inputBody.coverage ) {
|
|
1587
1487
|
await assignedService.deleteMany( { coverage: { $ne: inputBody.coverage } } );
|
|
1588
1488
|
}
|
|
@@ -2832,322 +2732,6 @@ async function insertPCBulkV3( getCLconfig, checklistId, currentdate, updatedche
|
|
|
2832
2732
|
}
|
|
2833
2733
|
}
|
|
2834
2734
|
|
|
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
|
-
|
|
3151
2735
|
async function updateOpenSearch( user, data ) {
|
|
3152
2736
|
let findQuery = [ {
|
|
3153
2737
|
$match: {
|
|
@@ -3445,135 +3029,81 @@ async function assignUsers( data ) {
|
|
|
3445
3029
|
let assignedData;
|
|
3446
3030
|
if ( data.coverage == 'store' ) {
|
|
3447
3031
|
if ( data?.type == 'cluster' ) {
|
|
3448
|
-
let query =
|
|
3449
|
-
|
|
3450
|
-
|
|
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 ) {
|
|
3032
|
+
let query = !data?.upload ? { _id: data.id } : { clusterName: data.clusterName, clientId: data.clientId };
|
|
3033
|
+
let clusterDetails = await clusterServices.findOneCluster( query, { stores: 1, clusterName: 1 } );
|
|
3034
|
+
if ( clusterDetails ) {
|
|
3469
3035
|
assignedData = {
|
|
3470
3036
|
checkFlag: true,
|
|
3471
3037
|
checkListId: data.checklistId,
|
|
3472
3038
|
checkListName: data.checkListName,
|
|
3473
3039
|
client_id: data?.clientId,
|
|
3474
|
-
clusterName: clusterDetails?.
|
|
3475
|
-
assignId: data?.id || clusterDetails?.
|
|
3040
|
+
clusterName: clusterDetails?.clusterName,
|
|
3041
|
+
assignId: data?.id || clusterDetails?._id,
|
|
3476
3042
|
coverage: 'store',
|
|
3477
3043
|
};
|
|
3478
3044
|
}
|
|
3479
3045
|
} else {
|
|
3480
|
-
let query =
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
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;
|
|
3046
|
+
let query = !data?.upload ? { _id: data.id } : { storeName: data.storeName };
|
|
3047
|
+
let storeDetails = await storeService.findOne( query );
|
|
3048
|
+
if ( storeDetails ) {
|
|
3049
|
+
let email = data?.upload ? data.userEmail : storeDetails?.spocDetails?.email;
|
|
3496
3050
|
let userDetails = await userService.findOne( { email: email, clientId: data.clientId } );
|
|
3497
3051
|
if ( !userDetails ) {
|
|
3498
3052
|
let userData = {
|
|
3499
|
-
userName: storeDetails
|
|
3500
|
-
email: storeDetails
|
|
3501
|
-
mobileNumber: storeDetails
|
|
3053
|
+
userName: storeDetails.spocDetails?.[0]?.name,
|
|
3054
|
+
email: storeDetails.spocDetails[0].email,
|
|
3055
|
+
mobileNumber: storeDetails.spocDetails?.[0]?.phone,
|
|
3502
3056
|
clientId: data.clientId,
|
|
3503
3057
|
};
|
|
3504
3058
|
userDetails = createUser( userData );
|
|
3505
3059
|
}
|
|
3506
3060
|
assignedData = {
|
|
3507
|
-
store_id: storeDetails
|
|
3508
|
-
storeName: storeDetails
|
|
3061
|
+
store_id: storeDetails.storeId,
|
|
3062
|
+
storeName: storeDetails.storeName,
|
|
3509
3063
|
userId: userDetails._id,
|
|
3510
3064
|
userName: userDetails.userName,
|
|
3511
3065
|
userEmail: userDetails.email,
|
|
3512
3066
|
userPhone: userDetails?.mobileNumber,
|
|
3513
|
-
city: storeDetails?.
|
|
3514
|
-
country: storeDetails?.
|
|
3067
|
+
city: storeDetails?.storeProfile?.city,
|
|
3068
|
+
country: storeDetails?.storeProfile?.country,
|
|
3515
3069
|
checkFlag: true,
|
|
3516
3070
|
checkListId: data.checklistId,
|
|
3517
3071
|
checkListName: data.checkListName,
|
|
3518
3072
|
client_id: data.clientId,
|
|
3519
|
-
assignId: data?.id || storeDetails
|
|
3073
|
+
assignId: data?.id || storeDetails._id,
|
|
3520
3074
|
coverage: 'store',
|
|
3521
3075
|
};
|
|
3522
3076
|
}
|
|
3523
3077
|
}
|
|
3524
3078
|
} else {
|
|
3525
3079
|
if ( data.type == 'teams' ) {
|
|
3526
|
-
let query =
|
|
3527
|
-
|
|
3528
|
-
|
|
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 ) {
|
|
3080
|
+
let query = !data?.upload ? { _id: data.id } : { teamName: data.teamName, clientId: data.clientId };
|
|
3081
|
+
let teamDetails = await teamsServices.findOneTeams( query, { users: 1, teamName: 1 } );
|
|
3082
|
+
if ( teamDetails ) {
|
|
3541
3083
|
assignedData = {
|
|
3542
3084
|
checkFlag: true,
|
|
3543
3085
|
checkListId: data.checklistId,
|
|
3544
3086
|
checkListName: data.checkListName,
|
|
3545
3087
|
client_id: data.clientId,
|
|
3546
|
-
teamName: teamDetails?.
|
|
3547
|
-
assignId: data?.id || teamDetails?.
|
|
3088
|
+
teamName: teamDetails?.teamName,
|
|
3089
|
+
assignId: data?.id || teamDetails?._id,
|
|
3548
3090
|
coverage: 'user',
|
|
3549
3091
|
};
|
|
3550
3092
|
}
|
|
3551
3093
|
} else {
|
|
3552
|
-
let query =
|
|
3553
|
-
|
|
3554
|
-
|
|
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 ) {
|
|
3094
|
+
let query = !data?.upload ? { _id: data.id } : { email: data.email, clientId: data.clientId };
|
|
3095
|
+
let userDetails = await userService.findOne( query );
|
|
3096
|
+
if ( userDetails ) {
|
|
3567
3097
|
assignedData = {
|
|
3568
|
-
userId: userDetails
|
|
3569
|
-
userName: userDetails
|
|
3570
|
-
userEmail: userDetails
|
|
3571
|
-
userPhone: userDetails?.
|
|
3098
|
+
userId: userDetails._id,
|
|
3099
|
+
userName: userDetails.userName,
|
|
3100
|
+
userEmail: userDetails.email,
|
|
3101
|
+
userPhone: userDetails?.mobileNumber,
|
|
3572
3102
|
checkFlag: true,
|
|
3573
3103
|
checkListId: data.checklistId,
|
|
3574
3104
|
checkListName: data.checkListName,
|
|
3575
3105
|
client_id: data.clientId,
|
|
3576
|
-
assignId: data?.id || userDetails?.
|
|
3106
|
+
assignId: data?.id || userDetails?._id,
|
|
3577
3107
|
coverage: 'user',
|
|
3578
3108
|
};
|
|
3579
3109
|
}
|
|
@@ -3586,156 +3116,28 @@ async function assignUsers( data ) {
|
|
|
3586
3116
|
|
|
3587
3117
|
export async function checklistAssign( req, res ) {
|
|
3588
3118
|
try {
|
|
3589
|
-
if ( !req.body.checklistId ) {
|
|
3590
|
-
return res.sendError( 'Checklist id is required', 400 );
|
|
3591
|
-
}
|
|
3592
3119
|
if ( !req.body.coverage ) {
|
|
3593
|
-
return res.sendError( '
|
|
3120
|
+
return res.sendError( 'coverage is required', 400 );
|
|
3594
3121
|
}
|
|
3595
3122
|
if ( !req.body.idList ) {
|
|
3596
|
-
return res.sendError( 'Id is required', 400 );
|
|
3123
|
+
return res.sendError( 'Id list is required', 400 );
|
|
3124
|
+
}
|
|
3125
|
+
if ( !req.body.checklistId ) {
|
|
3126
|
+
return res.sendError( 'Checklist id is required', 400 );
|
|
3127
|
+
}
|
|
3128
|
+
if ( !req.body.clientId ) {
|
|
3129
|
+
return res.sendError( 'Client id is required', 400 );
|
|
3597
3130
|
}
|
|
3598
|
-
|
|
3599
3131
|
let checklistDetails = await checklistService.findOne( { _id: req.body.checklistId } );
|
|
3600
3132
|
if ( !checklistDetails ) {
|
|
3601
3133
|
return res.sendError( 'No data found', 204 );
|
|
3602
3134
|
}
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
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 } );
|
|
3135
|
+
req.body.checkListName = checklistDetails.checkListName;
|
|
3136
|
+
await Promise.all( req.body.idList.map( async ( ele ) => {
|
|
3137
|
+
let storeData = { ...req.body, type: ele.type, id: ele.id };
|
|
3138
|
+
await assignUsers( storeData );
|
|
3139
|
+
} ) );
|
|
3140
|
+
return res.sendSuccess( 'Details updated successfully' );
|
|
3739
3141
|
} catch ( e ) {
|
|
3740
3142
|
logger.error( { functionName: 'checklistAssign', error: e } );
|
|
3741
3143
|
return res.sendError( e, 500 );
|
|
@@ -3754,7 +3156,7 @@ export async function checklistAssign( req, res ) {
|
|
|
3754
3156
|
// if ( !checklistDetails ) {
|
|
3755
3157
|
// return res.sendError( 'No data found', 204 );
|
|
3756
3158
|
// }
|
|
3757
|
-
// await assignedService.
|
|
3159
|
+
// await assignedService.updateMany( { assignId: { $in: req.body.id } }, { isdeleted: true } );
|
|
3758
3160
|
// return res.sendSuccess( 'Details removed successfully' );
|
|
3759
3161
|
// } catch ( e ) {
|
|
3760
3162
|
// logger.error( { functionName: 'removeAssign', error: e } );
|
|
@@ -3762,19 +3164,19 @@ export async function checklistAssign( req, res ) {
|
|
|
3762
3164
|
// }
|
|
3763
3165
|
// }
|
|
3764
3166
|
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3167
|
+
export async function deleteAssignList( req, res ) {
|
|
3168
|
+
try {
|
|
3169
|
+
if ( !req.body.checkListId ) {
|
|
3170
|
+
return res.sendError( 'Checklist id is required', 400 );
|
|
3171
|
+
}
|
|
3172
|
+
let checklistDetails = await checklistService.findOne( { _id: req.body.checkListId, isdeleted: false } );
|
|
3173
|
+
if ( !checklistDetails ) {
|
|
3174
|
+
return res.sendError( 'No data found', 204 );
|
|
3175
|
+
}
|
|
3176
|
+
await assignedService.updateMany( { checkListId: req.body.checkListId }, { isdeleted: true } );
|
|
3177
|
+
return res.sendSuccess( 'Assign details removed successfully' );
|
|
3178
|
+
} catch ( e ) {
|
|
3179
|
+
logger.error( { functionName: 'deleteAssignList', error: e } );
|
|
3180
|
+
return res.sendError( e, 500 );
|
|
3181
|
+
}
|
|
3182
|
+
}
|