tango-app-api-task 3.4.0-beta-0 → 3.4.0-beta-1
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
|
@@ -191,8 +191,8 @@ export async function createUpdateTask( req, res ) {
|
|
|
191
191
|
delete ans.answeroptionNumber;
|
|
192
192
|
} );
|
|
193
193
|
let compare = findDifferences( qn, question );
|
|
194
|
-
if ( Object.keys( compare ).length && ( compare?.answerType || compare?.answers || compare?.linkType || compare?.qname) ) {
|
|
195
|
-
questionList.questionEdit.push( { sectionName: ele.section, questions: [ { previous: qn
|
|
194
|
+
if ( Object.keys( compare ).length && ( compare?.answerType || compare?.answers || compare?.linkType || compare?.qname ) ) {
|
|
195
|
+
questionList.questionEdit.push( { sectionName: ele.section, questions: [ { previous: qn, new: question } ] } );
|
|
196
196
|
}
|
|
197
197
|
} else {
|
|
198
198
|
let sectionIndex = questionList.questionDelete.findIndex( ( sec ) => sec.sectionName === ele.section );
|
|
@@ -659,14 +659,14 @@ export const validateUserv1 = async ( req, res ) => {
|
|
|
659
659
|
{
|
|
660
660
|
$project: {
|
|
661
661
|
newEmail: { $toLower: '$email' },
|
|
662
|
-
isActive: 1,
|
|
662
|
+
// isActive: 1,
|
|
663
663
|
clientId: 1,
|
|
664
664
|
},
|
|
665
665
|
},
|
|
666
666
|
{
|
|
667
667
|
$match: {
|
|
668
668
|
newEmail: { $in: userEmailList },
|
|
669
|
-
isActive: true,
|
|
669
|
+
// isActive: true,
|
|
670
670
|
clientId: { $ne: req.body.clientId },
|
|
671
671
|
},
|
|
672
672
|
},
|
|
@@ -1095,7 +1095,7 @@ export async function taskConfig( req, res ) {
|
|
|
1095
1095
|
checkListName: checklistDetails.checkListName,
|
|
1096
1096
|
fromCheckListName: '',
|
|
1097
1097
|
type: 'task',
|
|
1098
|
-
action: 'updated',
|
|
1098
|
+
action: inputBody.publish ? 'updated' : 'draft',
|
|
1099
1099
|
storeName: '',
|
|
1100
1100
|
store_id: '',
|
|
1101
1101
|
createdByEmail: req.user.email,
|
|
@@ -2190,7 +2190,7 @@ export async function approveTask( req, res ) {
|
|
|
2190
2190
|
if ( req.body?.storeId?.length ) {
|
|
2191
2191
|
query['store_id'] = { $in: req.body.storeId };
|
|
2192
2192
|
}
|
|
2193
|
-
let taskDetails = await taskProcessedService.find( query, { _id: 1, checklistStatus: 1, storeName: 1, store_id: 1, userEmail: 1,client_id: 1, coverage: 1
|
|
2193
|
+
let taskDetails = await taskProcessedService.find( query, { _id: 1, checklistStatus: 1, storeName: 1, store_id: 1, userEmail: 1, client_id: 1, coverage: 1 } );
|
|
2194
2194
|
if ( !taskDetails.length ) {
|
|
2195
2195
|
return res.sendError( 'No data found', 204 );
|
|
2196
2196
|
}
|
|
@@ -2199,7 +2199,7 @@ export async function approveTask( req, res ) {
|
|
|
2199
2199
|
let updateResponse = await taskProcessedService.updateMany( { _id: { $in: idList } }, { approvalStatus: true } );
|
|
2200
2200
|
if ( updateResponse.modifiedCount || updateResponse.matchedCount ) {
|
|
2201
2201
|
let inputstores = taskDetails.filter( ( data ) => data.checklistStatus == 'submit' );
|
|
2202
|
-
let storeNames =
|
|
2202
|
+
let storeNames = inputstores.map( ( data ) => data.storeName );
|
|
2203
2203
|
let params = {
|
|
2204
2204
|
'payload': {
|
|
2205
2205
|
sourceCheckList_id: req.body.sourceCheckList_id,
|
|
@@ -2212,7 +2212,6 @@ export async function approveTask( req, res ) {
|
|
|
2212
2212
|
approvalStatus: true,
|
|
2213
2213
|
},
|
|
2214
2214
|
};
|
|
2215
|
-
|
|
2216
2215
|
const requestOptions = {
|
|
2217
2216
|
method: 'POST',
|
|
2218
2217
|
headers: {
|
|
@@ -2237,7 +2236,7 @@ export async function approveTask( req, res ) {
|
|
|
2237
2236
|
'createdBy': req.user._id,
|
|
2238
2237
|
'coverage': taskDetails[0].coverage,
|
|
2239
2238
|
'logDetails': {
|
|
2240
|
-
'approved': storeNames
|
|
2239
|
+
'approved': storeNames,
|
|
2241
2240
|
},
|
|
2242
2241
|
};
|
|
2243
2242
|
let urlopensearch = JSON.parse( process.env.OPENSEARCH );
|
|
@@ -2990,6 +2989,22 @@ export const duplicateChecklist = async ( req, res ) => {
|
|
|
2990
2989
|
sections.push( sectionDetails );
|
|
2991
2990
|
}
|
|
2992
2991
|
await taskQuestionService.insertMany( sections );
|
|
2992
|
+
let logObj = {
|
|
2993
|
+
client_id: checkDetails.client_id,
|
|
2994
|
+
createAt: new Date(),
|
|
2995
|
+
sourceCheckList_id: checkDetails._id,
|
|
2996
|
+
checkListName: checkDetails.checkListName,
|
|
2997
|
+
fromCheckListName: '',
|
|
2998
|
+
type: 'task',
|
|
2999
|
+
action: 'duplicated',
|
|
3000
|
+
storeName: '',
|
|
3001
|
+
store_id: '',
|
|
3002
|
+
createdByEmail: req.user.email,
|
|
3003
|
+
createdBy: req.user.userName,
|
|
3004
|
+
coverage: checkDetails.coverage,
|
|
3005
|
+
logDetails: {},
|
|
3006
|
+
};
|
|
3007
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).traxActivityLog, logObj );
|
|
2993
3008
|
return res.sendSuccess( { message: 'Task Duplicated Successfully' } );
|
|
2994
3009
|
} else {
|
|
2995
3010
|
return res.sendSuccess( { message: 'Duplicated Successfully' } );
|
|
@@ -4368,7 +4383,7 @@ export async function updateAssign( req, res ) {
|
|
|
4368
4383
|
},
|
|
4369
4384
|
];
|
|
4370
4385
|
let assignUserDetails = await userService.aggregate( query );
|
|
4371
|
-
|
|
4386
|
+
for ( let assign of req.body.assignedList ) {
|
|
4372
4387
|
let userDetails = assignUserDetails.find( ( ele ) => ele.email.toLowerCase() == assign.userEmail.toLowerCase() );
|
|
4373
4388
|
if ( !userDetails ) {
|
|
4374
4389
|
let userData = {
|
|
@@ -4378,6 +4393,7 @@ export async function updateAssign( req, res ) {
|
|
|
4378
4393
|
clientId: req.body.clientId,
|
|
4379
4394
|
};
|
|
4380
4395
|
userDetails = await createUser( userData );
|
|
4396
|
+
assignUserDetails.push( userDetails );
|
|
4381
4397
|
}
|
|
4382
4398
|
let data = {
|
|
4383
4399
|
...assign,
|
|
@@ -4391,7 +4407,7 @@ export async function updateAssign( req, res ) {
|
|
|
4391
4407
|
};
|
|
4392
4408
|
delete data._id;
|
|
4393
4409
|
assignedUserList.push( data );
|
|
4394
|
-
}
|
|
4410
|
+
}
|
|
4395
4411
|
let assignGroupDetails = [];
|
|
4396
4412
|
if ( req.body.coverage == 'store' ) {
|
|
4397
4413
|
assignGroupDetails = await clusterServices.findcluster( { _id: { $in: req.body.assignedGroup } } );
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as taskService from '../service/task.service.js';
|
|
2
2
|
import * as processedTaskService from '../service/processedTaskList.service.js';
|
|
3
|
-
import { logger, download } from 'tango-app-api-middleware'; // getChecklistUsers
|
|
3
|
+
import { logger, download, insertOpenSearchData } from 'tango-app-api-middleware'; // getChecklistUsers
|
|
4
4
|
import dayjs from 'dayjs';
|
|
5
5
|
import mongoose from 'mongoose';
|
|
6
6
|
// const ObjectId = mongoose.Types.ObjectId;
|
|
@@ -961,7 +961,7 @@ export const taskDeleteV1 = async ( req, res ) => {
|
|
|
961
961
|
return res.sendError( 'Missing taskId in request body', 400 );
|
|
962
962
|
}
|
|
963
963
|
|
|
964
|
-
const taskConfig = await taskService.findOne( { _id: new mongoose.Types.ObjectId( requestData.taskId ) }
|
|
964
|
+
const taskConfig = await taskService.findOne( { _id: new mongoose.Types.ObjectId( requestData.taskId ) } );
|
|
965
965
|
if ( !taskConfig ) {
|
|
966
966
|
// console.log( 'Task found:', taskConfig );
|
|
967
967
|
return res.sendError( 'Task not found', 404 );
|
|
@@ -973,12 +973,29 @@ export const taskDeleteV1 = async ( req, res ) => {
|
|
|
973
973
|
);
|
|
974
974
|
|
|
975
975
|
if ( resultData ) {
|
|
976
|
+
let logObj = {
|
|
977
|
+
client_id: taskConfig.client_id,
|
|
978
|
+
createAt: new Date(),
|
|
979
|
+
sourceCheckList_id: taskConfig._id,
|
|
980
|
+
checkListName: taskConfig.checkListName,
|
|
981
|
+
fromCheckListName: '',
|
|
982
|
+
type: 'task',
|
|
983
|
+
action: 'deleted',
|
|
984
|
+
storeName: '',
|
|
985
|
+
store_id: '',
|
|
986
|
+
createdByEmail: req.user.email,
|
|
987
|
+
createdBy: req.user.userName,
|
|
988
|
+
coverage: taskConfig.coverage,
|
|
989
|
+
logDetails: {},
|
|
990
|
+
};
|
|
991
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).traxActivityLog, logObj );
|
|
976
992
|
// console.log( 'Update result:', resultData );
|
|
977
993
|
return res.sendSuccess( { message: 'Task deleted successfully' } );
|
|
978
994
|
} else {
|
|
979
995
|
return res.sendError( 'Something went wrong please try again', 500 );
|
|
980
996
|
}
|
|
981
997
|
} catch ( e ) {
|
|
998
|
+
// console.log( 'e', e );
|
|
982
999
|
logger.error( 'taskDeleteV1 =>', e );
|
|
983
1000
|
return res.sendError( e, 500 );
|
|
984
1001
|
}
|