tango-app-api-task 1.0.0-alpha.23 → 1.0.0-alpha.25
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
|
@@ -148,7 +148,7 @@ async function insertData( requestData ) {
|
|
|
148
148
|
insertdata.date_string = currentdate;
|
|
149
149
|
insertdata.sourceCheckList_id = getCLconfig._id;
|
|
150
150
|
insertdata.checkListName = getCLconfig.checkListName;
|
|
151
|
-
insertdata.checkListDescription = getCLconfig.
|
|
151
|
+
insertdata.checkListDescription = getCLconfig.checkListDescription;
|
|
152
152
|
insertdata.publish = getCLconfig.publish;
|
|
153
153
|
insertdata.scheduleStartTime = startTimeIso.format();
|
|
154
154
|
insertdata.scheduleStartTime_iso = startTimeIso.format();
|
|
@@ -210,7 +210,7 @@ async function insertData( requestData ) {
|
|
|
210
210
|
checkListId: element2,
|
|
211
211
|
checkFlag: true,
|
|
212
212
|
isdeleted: false,
|
|
213
|
-
...( getCLconfig?.reinitiate ) ? { reinitiate: true } : {},
|
|
213
|
+
// ...( getCLconfig?.reinitiate ) ? { reinitiate: true } : {},
|
|
214
214
|
},
|
|
215
215
|
} );
|
|
216
216
|
let allQuestion = await taskAssignService.aggregate( getquestionQuery );
|
|
@@ -164,6 +164,7 @@ export async function createUpdateTask( req, res ) {
|
|
|
164
164
|
|
|
165
165
|
if ( req.body._id ) {
|
|
166
166
|
await taskQuestionService.deleteMany( { checkListId: checkListId } );
|
|
167
|
+
await taskAssignService.updateMany( { checkListId: req.body._id }, { checkListName: inputBody.checklistName } );
|
|
167
168
|
}
|
|
168
169
|
await taskQuestionService.insertMany( sectionList );
|
|
169
170
|
let message = req.body?._id ? 'Task Updated Successfully' : 'Task Created Successfully';
|
|
@@ -858,10 +859,11 @@ async function insertPCBulkV3( getCLconfig, checklistId, currentdate, updatedche
|
|
|
858
859
|
checkListId: new ObjectId( checklistId ),
|
|
859
860
|
checkFlag: true,
|
|
860
861
|
isdeleted: false,
|
|
861
|
-
...( getCLconfig?.reinitiate ) ? { reinitiate: true } : {},
|
|
862
|
+
// ...( getCLconfig?.reinitiate ) ? { reinitiate: true } : {},
|
|
862
863
|
},
|
|
863
864
|
} );
|
|
864
865
|
let allQuestion = await taskAssignService.aggregate( getquestionQuery );
|
|
866
|
+
|
|
865
867
|
if ( allQuestion ) {
|
|
866
868
|
let userIdList = [];
|
|
867
869
|
for ( let element4 of allQuestion ) {
|
|
@@ -1741,3 +1743,78 @@ export const updatePublish = async ( req, res ) => {
|
|
|
1741
1743
|
return res.sendError( e, 500 );
|
|
1742
1744
|
}
|
|
1743
1745
|
};
|
|
1746
|
+
|
|
1747
|
+
export const duplicateChecklist = async ( req, res ) => {
|
|
1748
|
+
try {
|
|
1749
|
+
if ( !req.params.checklistId ) {
|
|
1750
|
+
return res.sendError( { message: 'Task id is required' }, 400 );
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
let checkDetails = await taskService.findOne( { _id: req.params.checklistId, client_id: req.query.clientId, checkListType: 'task', isdeleted: false } );
|
|
1754
|
+
|
|
1755
|
+
if ( !checkDetails ) {
|
|
1756
|
+
return res.sendError( 'No data found', 204 );
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
let dupDetails = { ...checkDetails._doc };
|
|
1760
|
+
let name = `^${dupDetails.checkListName.split( '(' )[0]}\\(.*\\)$`;
|
|
1761
|
+
let checkListNameDetails = await taskService.find( { checkListName: { $regex: name }, client_id: req.query.clientId, checkListType: 'task', isdeleted: false } );
|
|
1762
|
+
if ( checkListNameDetails.length ) {
|
|
1763
|
+
let nameLength = checkListNameDetails.length + 1;
|
|
1764
|
+
dupDetails.checkListName = dupDetails.checkListName.split( '(' )[0] + '(' + nameLength +')';
|
|
1765
|
+
} else {
|
|
1766
|
+
dupDetails.checkListName = dupDetails.checkListName + '(1)';
|
|
1767
|
+
}
|
|
1768
|
+
dupDetails.publish = false;
|
|
1769
|
+
dupDetails.reinitiate = false;
|
|
1770
|
+
dupDetails.createdAt = new Date();
|
|
1771
|
+
dupDetails.updatedAt = new Date();
|
|
1772
|
+
dupDetails.publishDate = '';
|
|
1773
|
+
delete dupDetails._id;
|
|
1774
|
+
let logInsertData = {
|
|
1775
|
+
action: 'duplicateTask',
|
|
1776
|
+
checklistId: req.params.checklistId,
|
|
1777
|
+
checkListName: checkDetails.checkListName,
|
|
1778
|
+
createdBy: req.user._id,
|
|
1779
|
+
createdByName: req.user.userName,
|
|
1780
|
+
client_id: req.query.clientId,
|
|
1781
|
+
};
|
|
1782
|
+
await checklistLogs.create( logInsertData );
|
|
1783
|
+
taskService.create( dupDetails ).then( async ( data ) => {
|
|
1784
|
+
let userList = await taskAssignService.find( { checkListId: checkDetails._id, client_id: req.query.clientId } );
|
|
1785
|
+
if ( userList.length ) {
|
|
1786
|
+
let users = [];
|
|
1787
|
+
for ( let i = 0; i < userList.length; i++ ) {
|
|
1788
|
+
let userDetails = { ...userList[i]._doc };
|
|
1789
|
+
userDetails.checkListId = data._id;
|
|
1790
|
+
userDetails.checkListName = data.checkListName;
|
|
1791
|
+
delete userDetails['_id'];
|
|
1792
|
+
users.push( userDetails );
|
|
1793
|
+
}
|
|
1794
|
+
await taskAssignService.insertMany( users );
|
|
1795
|
+
}
|
|
1796
|
+
let sectionList = await taskQuestionService.find( { checkListId: checkDetails._id, client_id: req.query.clientId, isdeleted: false } );
|
|
1797
|
+
if ( sectionList.length ) {
|
|
1798
|
+
let sections= [];
|
|
1799
|
+
for ( let i = 0; i < sectionList.length; i++ ) {
|
|
1800
|
+
let sectionDetails = { ...sectionList[i]._doc };
|
|
1801
|
+
sectionDetails.checkListId = data._id;
|
|
1802
|
+
sectionDetails.checkList = dupDetails.checkListName;
|
|
1803
|
+
sectionDetails.createdAt = new Date();
|
|
1804
|
+
sectionDetails.updatedAt = new Date();
|
|
1805
|
+
delete sectionDetails['_id'];
|
|
1806
|
+
sections.push( sectionDetails );
|
|
1807
|
+
}
|
|
1808
|
+
await taskQuestionService.insertMany( sections );
|
|
1809
|
+
return res.sendSuccess( { message: 'Task Duplicated Successfully' } );
|
|
1810
|
+
} else {
|
|
1811
|
+
return res.sendSuccess( { message: 'Duplicated Successfully' } );
|
|
1812
|
+
}
|
|
1813
|
+
} ).catch( ( e ) => {
|
|
1814
|
+
return res.sendError( e, 500 );
|
|
1815
|
+
} );
|
|
1816
|
+
} catch ( e ) {
|
|
1817
|
+
logger.error( 'duplicateTask =>', e );
|
|
1818
|
+
return res.sendError( e, 500 );
|
|
1819
|
+
}
|
|
1820
|
+
};
|
|
@@ -1000,7 +1000,7 @@ export async function taskDetails( req, res ) {
|
|
|
1000
1000
|
const exportResult = [];
|
|
1001
1001
|
for ( let task of taskDetails[0].data ) {
|
|
1002
1002
|
exportResult.push( {
|
|
1003
|
-
'
|
|
1003
|
+
'Task Name': task?.checkListName ||'',
|
|
1004
1004
|
'Created by': task?.createdByName ||'--',
|
|
1005
1005
|
'Created On': dayjs.utc( task?.publishDate ).format( 'DD MMM, YYYY' ) || '',
|
|
1006
1006
|
'Priority': task?.priorityType || '--',
|
|
@@ -23,6 +23,7 @@ taskRouter
|
|
|
23
23
|
.post( '/getAnswerCount', isAllowedSessionHandler, taskController.getAnswerCount )
|
|
24
24
|
.post( '/approvalstatus', isAllowedSessionHandler, taskController.approvalstatus )
|
|
25
25
|
.get( '/task-list', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ ] } ] } ), taskController.taskList )
|
|
26
|
-
.put( '/publish', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.updatePublish )
|
|
26
|
+
.put( '/publish', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.updatePublish )
|
|
27
|
+
.get( '/duplicateTask/:checklistId', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.duplicateChecklist );
|
|
27
28
|
|
|
28
29
|
|