tango-app-api-trax 3.3.1-beta-52 → 3.3.1-beta-53
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
|
@@ -993,17 +993,7 @@ export const assignedUserDetailsv1 = async ( req, res ) => {
|
|
|
993
993
|
// let page = parseInt( req.query.offset ) || 0;
|
|
994
994
|
// let skip = limit * page;
|
|
995
995
|
|
|
996
|
-
let query = [ { $match: { checkListId: new ObjectId( req.params.checklistId ),
|
|
997
|
-
if ( req.query.search.trim() && req.query.search.trim() != '' ) {
|
|
998
|
-
let searchValue = req.query.search;
|
|
999
|
-
searchValue = searchValue.split( ',' ).map( ( item ) => item.trim().toLowerCase() );
|
|
1000
|
-
if ( searchValue.length > 1 ) {
|
|
1001
|
-
query.push( { $addFields: { storeLower: { $toLower: '$storeName' } } } );
|
|
1002
|
-
query.push( { $match: { storeLower: { $in: searchValue } } } );
|
|
1003
|
-
} else {
|
|
1004
|
-
query.push( { $match: { storeName: { $regex: req.query.search.trim(), $options: 'i' } } } );
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
996
|
+
let query = [ { $match: { checkListId: new ObjectId( req.params.checklistId ), isdeleted: false, store_id: { $exists: true }, store_id: { $ne: '' } } } ];
|
|
1007
997
|
|
|
1008
998
|
query.push( { $sort: { _id: -1 } } );
|
|
1009
999
|
|
|
@@ -1013,70 +1003,22 @@ export const assignedUserDetailsv1 = async ( req, res ) => {
|
|
|
1013
1003
|
}
|
|
1014
1004
|
|
|
1015
1005
|
let userDetails = [];
|
|
1016
|
-
let storeList = [];
|
|
1017
|
-
let userList = [];
|
|
1018
1006
|
await Promise.all( checklistDetails.map( async ( ele ) => {
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
id: ele._id,
|
|
1032
|
-
userName: item.spocDetails?.[0]?.name,
|
|
1033
|
-
userEmail: item.spocDetails?.[0]?.email,
|
|
1034
|
-
store_id: item?.storeId,
|
|
1035
|
-
storeName: item?.storeName,
|
|
1036
|
-
userPhone: item.spocDetails?.[0]?.phone,
|
|
1037
|
-
city: ele?.city,
|
|
1038
|
-
checkFlag: ele.checkFlag,
|
|
1039
|
-
clusterName: ele?.clusterName || '',
|
|
1040
|
-
teamName: ele?.teamName || '',
|
|
1041
|
-
} );
|
|
1042
|
-
} );
|
|
1043
|
-
}
|
|
1044
|
-
} else if ( ele?.teamName ) {
|
|
1045
|
-
let teamDetails = await teamsServices.findOneTeams( { _id: ele.assignId }, { users: 1, teamName: 1 } );
|
|
1046
|
-
if ( teamDetails ) {
|
|
1047
|
-
let teamUserDetails = await userService.find( { _id: { $in: teamDetails.users.map( ( item ) => item.userId ) } } );
|
|
1048
|
-
teamUserDetails.forEach( ( item ) => {
|
|
1049
|
-
userDetails.push( {
|
|
1050
|
-
id: ele._id,
|
|
1051
|
-
userName: item.userName,
|
|
1052
|
-
userEmail: item.email,
|
|
1053
|
-
store_id: ele?.storeId,
|
|
1054
|
-
storeName: ele?.storeName,
|
|
1055
|
-
userPhone: item?.mobileNumber,
|
|
1056
|
-
city: ele?.city,
|
|
1057
|
-
checkFlag: ele.checkFlag,
|
|
1058
|
-
clusterName: ele?.clusterName || '',
|
|
1059
|
-
teamName: ele?.teamName || '',
|
|
1060
|
-
} );
|
|
1061
|
-
} );
|
|
1062
|
-
}
|
|
1063
|
-
} else {
|
|
1064
|
-
userDetails.push( {
|
|
1065
|
-
id: ele._id,
|
|
1066
|
-
userName: ele.userName,
|
|
1067
|
-
userEmail: ele.userEmail,
|
|
1068
|
-
store_id: ele?.store_id,
|
|
1069
|
-
storeName: ele?.storeName,
|
|
1070
|
-
userPhone: ele.userPhone,
|
|
1071
|
-
city: ele.city,
|
|
1072
|
-
checkFlag: ele.checkFlag,
|
|
1073
|
-
clusterName: ele?.clusterName || '',
|
|
1074
|
-
teamName: ele?.teamName || '',
|
|
1075
|
-
} );
|
|
1076
|
-
}
|
|
1007
|
+
userDetails.push( {
|
|
1008
|
+
id: ele._id,
|
|
1009
|
+
userName: ele.userName,
|
|
1010
|
+
userEmail: ele.userEmail,
|
|
1011
|
+
store_id: ele?.store_id,
|
|
1012
|
+
storeName: ele?.storeName,
|
|
1013
|
+
userPhone: ele.userPhone,
|
|
1014
|
+
city: ele.city,
|
|
1015
|
+
checkFlag: ele.checkFlag,
|
|
1016
|
+
clusterName: ele?.clusterName || '',
|
|
1017
|
+
teamName: ele?.teamName || '',
|
|
1018
|
+
} );
|
|
1077
1019
|
} ) );
|
|
1078
1020
|
|
|
1079
|
-
return res.sendSuccess( { count: userDetails.length,
|
|
1021
|
+
return res.sendSuccess( { count: userDetails.length, userDetails } );
|
|
1080
1022
|
} catch ( e ) {
|
|
1081
1023
|
logger.error( 'assignedUserDetails =>', e );
|
|
1082
1024
|
return res.sendError( e, 500 );
|
|
@@ -3568,7 +3510,7 @@ export const selectAssign = async ( req, res ) => {
|
|
|
3568
3510
|
if ( requestData.assignType == 'user' ) {
|
|
3569
3511
|
let userQuery = [
|
|
3570
3512
|
{ $match: { clientId: requestData.clientId } },
|
|
3571
|
-
{ $project: { '
|
|
3513
|
+
{ $project: { 'userEmail': '$email', 'userName': 1, 'type': 'user' } },
|
|
3572
3514
|
];
|
|
3573
3515
|
resuldData = await userService.aggregate( userQuery );
|
|
3574
3516
|
} else {
|
|
@@ -3681,8 +3623,6 @@ export async function updateAssign( req, res ) {
|
|
|
3681
3623
|
await assignedService.deleteMany( { checkListId: req.body.checkListId } );
|
|
3682
3624
|
let assignedUserList = [];
|
|
3683
3625
|
await Promise.all( req.body.assignedList.map( async ( assign ) => {
|
|
3684
|
-
delete assign._id;
|
|
3685
|
-
delete assign.id;
|
|
3686
3626
|
let query = [
|
|
3687
3627
|
{
|
|
3688
3628
|
$addFields: {
|
|
@@ -3716,6 +3656,7 @@ export async function updateAssign( req, res ) {
|
|
|
3716
3656
|
userId: userDetails._id,
|
|
3717
3657
|
checkListName: checklistDetails.checkListName,
|
|
3718
3658
|
};
|
|
3659
|
+
delete data._id;
|
|
3719
3660
|
assignedUserList.push( data );
|
|
3720
3661
|
} ) );
|
|
3721
3662
|
await Promise.all( req.body.assignedGroup.map( async ( assign ) => {
|