tango-app-api-task 3.2.1-beta-19 → 3.2.1-beta-20
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-task",
|
|
3
|
-
"version": "3.2.1-beta-
|
|
3
|
+
"version": "3.2.1-beta-20",
|
|
4
4
|
"description": "Task",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"mongodb": "^6.10.0",
|
|
25
25
|
"nodemon": "^3.1.7",
|
|
26
26
|
"npm": "^10.9.2",
|
|
27
|
-
"tango-api-schema": "^2.2.
|
|
28
|
-
"tango-app-api-middleware": "^3.1.
|
|
27
|
+
"tango-api-schema": "^2.2.49",
|
|
28
|
+
"tango-app-api-middleware": "^3.1.55",
|
|
29
29
|
"winston": "^3.17.0",
|
|
30
30
|
"winston-daily-rotate-file": "^5.0.0"
|
|
31
31
|
},
|
|
@@ -1361,16 +1361,17 @@ export async function createChecklistTask( req, res ) {
|
|
|
1361
1361
|
client_id: inputBody.clientId,
|
|
1362
1362
|
};
|
|
1363
1363
|
await taskQuestionService.create( question );
|
|
1364
|
-
let storeDetails
|
|
1365
|
-
if (
|
|
1366
|
-
|
|
1364
|
+
let storeDetails;
|
|
1365
|
+
if ( inputBody?.storeName ) {
|
|
1366
|
+
storeDetails = await storeService.findOne( { storeName: inputBody.storeName, status: 'active' }, { storeId: 1, storeProfile: 1 } );
|
|
1367
1367
|
}
|
|
1368
|
+
|
|
1368
1369
|
let userDetails = {
|
|
1369
1370
|
userName: inputBody.userName,
|
|
1370
1371
|
userEmail: inputBody.userEmail,
|
|
1371
|
-
store_id: storeDetails.storeId,
|
|
1372
|
-
storeName: inputBody
|
|
1373
|
-
city: storeDetails?.storeProfile?.city,
|
|
1372
|
+
store_id: storeDetails?.storeId?storeDetails.storeId:'',
|
|
1373
|
+
storeName: inputBody?.storeName?inputBody?.storeName:'',
|
|
1374
|
+
city: storeDetails?.storeProfile?.city?storeDetails?.storeProfile?.city:'',
|
|
1374
1375
|
checkFlag: true,
|
|
1375
1376
|
checkListId: response?._id,
|
|
1376
1377
|
checkListName: data.checkListName,
|
|
@@ -1403,6 +1404,7 @@ export async function createChecklistTask( req, res ) {
|
|
|
1403
1404
|
_id: inputBody.processedChecklistId,
|
|
1404
1405
|
section_id: inputBody.sectionId,
|
|
1405
1406
|
qno: inputBody.qno,
|
|
1407
|
+
parentQuestion: inputBody.parentQuestion,
|
|
1406
1408
|
},
|
|
1407
1409
|
'upsert': {
|
|
1408
1410
|
taskId: String( response?._id ),
|
|
@@ -1539,6 +1541,7 @@ export async function redoTask( req, res ) {
|
|
|
1539
1541
|
};
|
|
1540
1542
|
|
|
1541
1543
|
let response = await taskProcessedService.updateOne( { _id: req.body.payload._id }, updateData );
|
|
1544
|
+
console.log( response );
|
|
1542
1545
|
if ( response.modifiedCount || response.matchedCount ) {
|
|
1543
1546
|
let storeTimeZone = await storeService.findOne( { storeName: taskDetails.storeName }, { 'storeProfile.timeZone': 1 } );
|
|
1544
1547
|
let currentDateTime;
|
|
@@ -1555,8 +1558,8 @@ export async function redoTask( req, res ) {
|
|
|
1555
1558
|
sectionName: question[sectionIndex].sectionName,
|
|
1556
1559
|
questionName: question[sectionIndex].questions[req.body.payload.qno - 1].qname,
|
|
1557
1560
|
action: 'redo',
|
|
1558
|
-
store_id: taskDetails
|
|
1559
|
-
storeName: taskDetails.storeName,
|
|
1561
|
+
store_id: taskDetails?.store_id?taskDetails?.store_id:'',
|
|
1562
|
+
storeName: taskDetails.storeName?taskDetails.storeName:'',
|
|
1560
1563
|
client_id: taskDetails.client_id,
|
|
1561
1564
|
processedChecklistId: taskDetails._id,
|
|
1562
1565
|
type: taskDetails.checkListType,
|
|
@@ -1578,6 +1581,7 @@ export async function redoTask( req, res ) {
|
|
|
1578
1581
|
};
|
|
1579
1582
|
let url = JSON.parse( process.env.LAMBDAURL );
|
|
1580
1583
|
let searchResponse = await fetch( url.redoTask, requestOptions );
|
|
1584
|
+
console.log( searchResponse.ok );
|
|
1581
1585
|
if ( searchResponse.ok ) {
|
|
1582
1586
|
return res.sendSuccess( 'Question redo successfully' );
|
|
1583
1587
|
} else {
|
|
@@ -1674,6 +1678,7 @@ export const taskDropdown = async ( req, res ) => {
|
|
|
1674
1678
|
scheduleRepeatedType: 1,
|
|
1675
1679
|
scheduleStartTime: 1,
|
|
1676
1680
|
scheduleEndTime: 1,
|
|
1681
|
+
coverage: 1,
|
|
1677
1682
|
},
|
|
1678
1683
|
} );
|
|
1679
1684
|
|
|
@@ -1688,6 +1693,7 @@ export const taskDropdown = async ( req, res ) => {
|
|
|
1688
1693
|
scheduleRepeatedType: { $last: '$scheduleRepeatedType' },
|
|
1689
1694
|
scheduleStartTime: { $last: '$scheduleStartTime' },
|
|
1690
1695
|
scheduleEndTime: { $last: '$scheduleEndTime' },
|
|
1696
|
+
coverage: { $last: '$coverage' },
|
|
1691
1697
|
},
|
|
1692
1698
|
} );
|
|
1693
1699
|
|
|
@@ -1726,6 +1732,7 @@ export const taskDropdown = async ( req, res ) => {
|
|
|
1726
1732
|
scheduleRepeatedType: 1,
|
|
1727
1733
|
scheduleStartTime: 1,
|
|
1728
1734
|
scheduleEndTime: 1,
|
|
1735
|
+
coverage: 1,
|
|
1729
1736
|
checkListDescription: '$checklistconfigs.checkListDescription',
|
|
1730
1737
|
publish: '$checklistconfigs.publish',
|
|
1731
1738
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as traxApprover from '../service/approver.service.js';
|
|
2
2
|
import * as processedTask from '../service/processedTaskList.service.js';
|
|
3
|
-
import { logger } from 'tango-app-api-middleware';
|
|
3
|
+
import { logger, getChecklistUsers } from 'tango-app-api-middleware';
|
|
4
4
|
import * as processedChecklist from '../service/processedChecklist.service.js';
|
|
5
5
|
import * as checklistLog from '../service/checklistLog.service.js';
|
|
6
6
|
import mongoose from 'mongoose';
|
|
@@ -46,14 +46,21 @@ export const overallCardsV1 = async ( req, res ) => {
|
|
|
46
46
|
},
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
+
let requestData = req.body;
|
|
50
|
+
// Get User Based Checklist //
|
|
51
|
+
let loginUser = { clientId: requestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
|
|
52
|
+
let getUserEmails = await getChecklistUsers( loginUser );
|
|
53
|
+
// End: Get User Based Checklist////
|
|
54
|
+
|
|
49
55
|
let taskQuery = [
|
|
50
56
|
{
|
|
51
57
|
$match: {
|
|
52
58
|
date_iso: { $gte: new Date( req.body.fromDate ), $lte: toDate },
|
|
53
59
|
sourceCheckList_id: { $in: taskIdList },
|
|
54
60
|
checklistStatus: 'submit',
|
|
55
|
-
...( req.body?.storeId?.length ) ? { store_id: { $in: req.body.storeId } } :{},
|
|
56
61
|
approvalStatus: false,
|
|
62
|
+
// ...( req.body?.storeId?.length ) ? { store_id: { $in: req.body.storeId } } :{},
|
|
63
|
+
$or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ],
|
|
57
64
|
},
|
|
58
65
|
},
|
|
59
66
|
{ ...groupQuery },
|
|
@@ -65,8 +72,9 @@ export const overallCardsV1 = async ( req, res ) => {
|
|
|
65
72
|
date_iso: { $gte: new Date( req.body.fromDate ), $lte: toDate },
|
|
66
73
|
sourceCheckList_id: { $in: checklistIdList },
|
|
67
74
|
checklistStatus: 'submit',
|
|
68
|
-
...( req.body?.storeId?.length ) ? { store_id: { $in: req.body.storeId } } :{},
|
|
69
75
|
approvalStatus: false,
|
|
76
|
+
// ...( req.body?.storeId?.length ) ? { store_id: { $in: req.body.storeId } } :{},
|
|
77
|
+
$or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ],
|
|
70
78
|
},
|
|
71
79
|
},
|
|
72
80
|
{ ...groupQuery },
|
|
@@ -180,13 +188,20 @@ export const approvalTableV1 = async ( req, res ) => {
|
|
|
180
188
|
|
|
181
189
|
const promises = [];
|
|
182
190
|
|
|
191
|
+
let requestData = req.body;
|
|
192
|
+
// Get User Based Checklist //
|
|
193
|
+
let loginUser = { clientId: requestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
|
|
194
|
+
let getUserEmails = await getChecklistUsers( loginUser );
|
|
195
|
+
// End: Get User Based Checklist////
|
|
196
|
+
|
|
183
197
|
if ( [ 'task', 'all' ].includes( req.body.type ) ) {
|
|
184
198
|
query = [
|
|
185
199
|
{
|
|
186
200
|
$match: {
|
|
187
201
|
date_iso: { $gte: new Date( req.body.fromDate ), $lte: toDate },
|
|
188
202
|
sourceCheckList_id: { $in: taskIdList },
|
|
189
|
-
...( req.body?.storeId?.length ) ? { store_id: { $in: req.body.storeId } } :{},
|
|
203
|
+
// ...( req.body?.storeId?.length ) ? { store_id: { $in: req.body.storeId } } :{},
|
|
204
|
+
$or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ],
|
|
190
205
|
},
|
|
191
206
|
},
|
|
192
207
|
...groupQuery,
|
|
@@ -217,7 +232,8 @@ export const approvalTableV1 = async ( req, res ) => {
|
|
|
217
232
|
$match: {
|
|
218
233
|
date_iso: { $gte: new Date( req.body.fromDate ), $lte: toDate },
|
|
219
234
|
sourceCheckList_id: { $in: checklistIdList },
|
|
220
|
-
...( req.body?.storeId?.length ) ? { store_id: { $in: req.body.storeId } } : {},
|
|
235
|
+
// ...( req.body?.storeId?.length ) ? { store_id: { $in: req.body.storeId } } : {},
|
|
236
|
+
$or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ],
|
|
221
237
|
},
|
|
222
238
|
},
|
|
223
239
|
...groupQuery,
|
|
@@ -281,11 +297,16 @@ export const activityLogV1 = async ( req, res ) => {
|
|
|
281
297
|
let findQuery = [];
|
|
282
298
|
let findAndQuery = [];
|
|
283
299
|
|
|
300
|
+
// Get User Based Checklist //
|
|
301
|
+
let loginUser = { clientId: requestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
|
|
302
|
+
let getUserEmails = await getChecklistUsers( loginUser );
|
|
303
|
+
// End: Get User Based Checklist////
|
|
284
304
|
|
|
285
305
|
findAndQuery.push(
|
|
286
306
|
{ client_id: requestData.clientId },
|
|
287
|
-
{ store_id: { $in: requestData.storeId } },
|
|
288
307
|
{ action: { $in: [ 'submitted', 'started' ] } },
|
|
308
|
+
// { store_id: { $in: requestData.storeId } },
|
|
309
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
289
310
|
);
|
|
290
311
|
|
|
291
312
|
|
|
@@ -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';
|
|
3
|
+
import { logger, download, getChecklistUsers } from 'tango-app-api-middleware';
|
|
4
4
|
import dayjs from 'dayjs';
|
|
5
5
|
import mongoose from 'mongoose';
|
|
6
6
|
// const ObjectId = mongoose.Types.ObjectId;
|
|
@@ -57,10 +57,16 @@ export const overallCardsV1 = async ( req, res ) => {
|
|
|
57
57
|
let findQuery = [];
|
|
58
58
|
let findAndQuery = [];
|
|
59
59
|
|
|
60
|
+
// Get User Based Checklist //
|
|
61
|
+
let loginUser = { clientId: requestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
|
|
62
|
+
let getUserEmails = await getChecklistUsers( loginUser );
|
|
63
|
+
// End: Get User Based Checklist////
|
|
64
|
+
|
|
60
65
|
findAndQuery.push(
|
|
61
66
|
{ date_iso: { $gte: fromDate, $lte: toDate } },
|
|
62
67
|
{ client_id: requestData.clientId },
|
|
63
|
-
{ store_id: { $in: requestData.storeId } },
|
|
68
|
+
// { store_id: { $in: requestData.storeId } },
|
|
69
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
64
70
|
);
|
|
65
71
|
|
|
66
72
|
findQuery.push( { $match: { $and: findAndQuery } } );
|
|
@@ -228,11 +234,17 @@ export const taskInfoTableV1 = async ( req, res ) => {
|
|
|
228
234
|
let findQuery = [];
|
|
229
235
|
let findAndQuery = [];
|
|
230
236
|
|
|
237
|
+
// Get User Based Checklist //
|
|
238
|
+
let loginUser = { clientId: requestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
|
|
239
|
+
let getUserEmails = await getChecklistUsers( loginUser );
|
|
240
|
+
// End: Get User Based Checklist////
|
|
241
|
+
|
|
231
242
|
findAndQuery.push(
|
|
232
243
|
{ date_iso: { $lte: new Date( dayjs().format( 'YYYY-MM-DD' ) ) } },
|
|
233
244
|
{ client_id: requestData.clientId },
|
|
234
|
-
{ store_id: { $in: requestData.storeId } },
|
|
235
245
|
{ sourceCheckList_id: new mongoose.Types.ObjectId( requestData.taskId ) },
|
|
246
|
+
// { store_id: { $in: requestData.storeId } },
|
|
247
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
236
248
|
);
|
|
237
249
|
if ( requestData.checklistStatus && requestData.checklistStatus != 'All' ) {
|
|
238
250
|
if ( requestData.checklistStatus == 'redo' ) {
|
|
@@ -966,6 +978,12 @@ export async function taskDetails( req, res ) {
|
|
|
966
978
|
return res.sendError( 'clientId is required', 400 );
|
|
967
979
|
}
|
|
968
980
|
|
|
981
|
+
let requestData = req.body;
|
|
982
|
+
// Get User Based Checklist //
|
|
983
|
+
let loginUser = { clientId: requestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
|
|
984
|
+
let getUserEmails = await getChecklistUsers( loginUser );
|
|
985
|
+
// End: Get User Based Checklist////
|
|
986
|
+
|
|
969
987
|
let toDate = new Date( req.body.toDate );
|
|
970
988
|
let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
|
|
971
989
|
toDate = new Date( toDate.getTime() - userTimezoneOffset );
|
|
@@ -990,23 +1008,33 @@ export async function taskDetails( req, res ) {
|
|
|
990
1008
|
$match: {
|
|
991
1009
|
date_iso: { $gte: new Date( req.body.fromDate ), $lte: toDate },
|
|
992
1010
|
client_id: req.body.clientId,
|
|
993
|
-
store_id: { $in: req.body.storeId },
|
|
994
1011
|
...( idList.length ) ? { sourceCheckList_id: { $in: idList } } : {},
|
|
1012
|
+
// store_id: { $in: req.body.storeId },
|
|
1013
|
+
$or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ],
|
|
995
1014
|
},
|
|
996
1015
|
},
|
|
997
1016
|
{ $sort: { date_iso: -1 } },
|
|
998
1017
|
{
|
|
999
1018
|
$group: {
|
|
1000
|
-
_id: '$sourceCheckList_id',
|
|
1001
|
-
checkListName: { $first: '$checkListName' },
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1019
|
+
'_id': '$sourceCheckList_id',
|
|
1020
|
+
'checkListName': { $first: '$checkListName' },
|
|
1021
|
+
'coverage': {
|
|
1022
|
+
'$first': {
|
|
1023
|
+
'$cond': {
|
|
1024
|
+
'if': { '$gt': [ { '$ifNull': [ '$referenceCheckListId', '' ] }, '' ] },
|
|
1025
|
+
'then': 'checklist',
|
|
1026
|
+
'else': '$coverage',
|
|
1027
|
+
},
|
|
1028
|
+
},
|
|
1029
|
+
},
|
|
1030
|
+
'publishDate': { $first: '$publishDate' },
|
|
1031
|
+
'priorityType': { $first: '$priorityType' },
|
|
1032
|
+
// storeCount: { $first: '$storeCount' },
|
|
1033
|
+
'storeCount': { $sum: 1 },
|
|
1034
|
+
'submitCount': { $sum: { $cond: [ { $eq: [ '$checklistStatus', 'submit' ] }, 1, 0 ] } },
|
|
1035
|
+
'redoCount': { $sum: { $cond: [ { $and: [ { $eq: [ '$redoStatus', true ] }, { $ne: [ '$checklistStatus', 'submit' ] } ] }, 1, 0 ] } },
|
|
1036
|
+
'scheduleEndTime_iso': { $first: '$scheduleEndTime_iso' },
|
|
1037
|
+
'checkListChar': { $first: { $toUpper: { $substr: [ '$createdByName', 0, 2 ] } } },
|
|
1010
1038
|
},
|
|
1011
1039
|
},
|
|
1012
1040
|
];
|
|
@@ -8,14 +8,14 @@ import {
|
|
|
8
8
|
|
|
9
9
|
taskDashboardRouter
|
|
10
10
|
.post( '/overallcards', isAllowedSessionHandler, overallCards )
|
|
11
|
-
.post( '/overallcardsV1', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [] } ] } ), overallCardsV1 )
|
|
12
11
|
.post( '/taskTable', isAllowedSessionHandler, taskTable )
|
|
13
12
|
.post( '/taskTableV1', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [] } ] } ), taskTableV1 )
|
|
14
13
|
.post( '/taskInfoTable', isAllowedSessionHandler, taskInfoTable )
|
|
15
|
-
.post( '/taskInfoTableV1', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [] } ] } ), taskInfoTableV1 )
|
|
16
14
|
.post( '/taskDropdownList', isAllowedSessionHandler, taskDropdownList )
|
|
17
|
-
.post( '/taskDropdownListV1', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [] } ] } ), taskDropdownListV1 )
|
|
18
15
|
.post( '/taskDeleteV1', isAllowedSessionHandler, taskDeleteV1 )
|
|
19
|
-
.post( '/
|
|
16
|
+
.post( '/taskDropdownListV1', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [] } ] } ), taskDropdownListV1 )
|
|
17
|
+
.post( '/overallcardsV1', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [] } ] } ), overallCardsV1 )
|
|
18
|
+
.post( '/taskDetails', isAllowedSessionHandler, taskDetails )
|
|
19
|
+
.post( '/taskInfoTableV1', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [] } ] } ), taskInfoTableV1 );
|
|
20
20
|
|
|
21
21
|
export default taskDashboardRouter;
|