tango-app-api-store-builder 1.0.0-beta-210 → 1.0.0-beta-212
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
|
@@ -31,16 +31,32 @@ export async function getplanoFeedback( req, res ) {
|
|
|
31
31
|
|
|
32
32
|
let data = await planoTaskService.aggregate( pipeline );
|
|
33
33
|
if ( filterByApprovalStatus && filterByApprovalStatus !== '' ) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
if ( type == 'fixture' ) {
|
|
35
|
+
if ( filterByApprovalStatus == 'pending' ) {
|
|
36
|
+
data = data.filter( ( element ) => {
|
|
37
|
+
return element?.approvalStatus == 'pending';
|
|
38
|
+
} );
|
|
39
|
+
} if ( filterByApprovalStatus == 'agree' ) {
|
|
40
|
+
data = data.filter( ( element ) => {
|
|
41
|
+
return element?.answers?.[0]?.status == 'agree';
|
|
42
|
+
} );
|
|
43
|
+
} if ( filterByApprovalStatus == 'disagree' ) {
|
|
44
|
+
data = data.filter( ( element ) => {
|
|
45
|
+
return element?.answers?.[0]?.status == 'disagree';
|
|
46
|
+
} );
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
data.forEach( ( element ) => {
|
|
50
|
+
element.answers?.forEach( ( ans ) => {
|
|
51
|
+
ans.issues = ans.issues?.filter(
|
|
52
|
+
( issue ) => issue.Details && issue.Details.length > 0,
|
|
53
|
+
);
|
|
54
|
+
} );
|
|
55
|
+
element.answers = element.answers?.filter(
|
|
56
|
+
( ans ) => ans.issues && ans.issues.length > 0,
|
|
38
57
|
);
|
|
39
58
|
} );
|
|
40
|
-
|
|
41
|
-
( ans ) => ans.issues && ans.issues.length > 0,
|
|
42
|
-
);
|
|
43
|
-
} );
|
|
59
|
+
}
|
|
44
60
|
data = data.filter(
|
|
45
61
|
( element ) => element.answers && element.answers.length > 0,
|
|
46
62
|
);
|
|
@@ -960,6 +976,19 @@ export async function updateFixtureStatus( req, res ) {
|
|
|
960
976
|
] );
|
|
961
977
|
|
|
962
978
|
await planoTaskService.updateOne( { _id: req.body._id }, { approvalStatus: 'approved' } );
|
|
979
|
+
let fixtureTask = await planoTaskService.find(
|
|
980
|
+
{
|
|
981
|
+
planoId: new mongoose.Types.ObjectId( req.body.planoId ),
|
|
982
|
+
floorId: new mongoose.Types.ObjectId( req.body.floorId ),
|
|
983
|
+
type: 'fixture',
|
|
984
|
+
},
|
|
985
|
+
);
|
|
986
|
+
if ( fixtureTask.length > 0 ) {
|
|
987
|
+
let allTaskDone = fixtureTask.filter( ( data ) => !data?.answers?.[0]?.status || data?.answers?.[0]?.status == 'disagree' );
|
|
988
|
+
if ( allTaskDone.length === 0 ) {
|
|
989
|
+
await floorService.updateOne( { _id: new mongoose.Types.ObjectId( req.body.floorId ) }, { planoProgress: 100 } );
|
|
990
|
+
}
|
|
991
|
+
}
|
|
963
992
|
} else {
|
|
964
993
|
let updateResponse = await planoTaskService.updateOnefilters(
|
|
965
994
|
{ _id: new mongoose.Types.ObjectId( req.body._id ) },
|
|
@@ -9694,3 +9694,49 @@ function transformProducts( products, shelvesByZone, fixtureData ) {
|
|
|
9694
9694
|
|
|
9695
9695
|
return result;
|
|
9696
9696
|
}
|
|
9697
|
+
|
|
9698
|
+
|
|
9699
|
+
// ---------------------Plano Migrate-------------------------
|
|
9700
|
+
|
|
9701
|
+
export async function getAllPlanoIds(req, res){
|
|
9702
|
+
try {
|
|
9703
|
+
|
|
9704
|
+
if (!req.query?.clientId) {
|
|
9705
|
+
return res.sendError('Client id is required', 400);
|
|
9706
|
+
}
|
|
9707
|
+
const floorsData = await storeBuilderService.aggregate([
|
|
9708
|
+
{
|
|
9709
|
+
'$match': {
|
|
9710
|
+
'clientId': '11'
|
|
9711
|
+
}
|
|
9712
|
+
}, {
|
|
9713
|
+
'$group': {
|
|
9714
|
+
'_id': '$planoId',
|
|
9715
|
+
'storeName': {
|
|
9716
|
+
'$first': '$storeName'
|
|
9717
|
+
},
|
|
9718
|
+
'storeId': {
|
|
9719
|
+
'$first': '$storeId'
|
|
9720
|
+
}
|
|
9721
|
+
}
|
|
9722
|
+
}, {
|
|
9723
|
+
'$project': {
|
|
9724
|
+
'planoId': '$_id',
|
|
9725
|
+
'storeName': 1,
|
|
9726
|
+
'storeId': 1
|
|
9727
|
+
}
|
|
9728
|
+
}, {
|
|
9729
|
+
'$sort': { storeName: 1 }
|
|
9730
|
+
}
|
|
9731
|
+
]);
|
|
9732
|
+
|
|
9733
|
+
if (floorsData) {
|
|
9734
|
+
return res.sendSuccess(floorsData);
|
|
9735
|
+
} else {
|
|
9736
|
+
return res.sendError("No floor data found", 204)
|
|
9737
|
+
}
|
|
9738
|
+
} catch (error) {
|
|
9739
|
+
console.log("@@ ~ getAllPlanoIds [ERR]:", error);
|
|
9740
|
+
return res.sendError(e, 500);
|
|
9741
|
+
}
|
|
9742
|
+
}
|
|
@@ -2811,12 +2811,12 @@ export async function storeFixturesv2( req, res ) {
|
|
|
2811
2811
|
const masterTemplateIds = new Set();
|
|
2812
2812
|
const layoutPolygonWithFixtures = await Promise.all(
|
|
2813
2813
|
floor.layoutPolygon.map( async ( element ) => {
|
|
2814
|
-
|
|
2814
|
+
const fixtures = await storeFixtureService.findAndSort( {
|
|
2815
2815
|
floorId: floor._id,
|
|
2816
2816
|
associatedElementType: element.elementType,
|
|
2817
2817
|
associatedElementNumber: element.elementNumber,
|
|
2818
2818
|
fixtureType: { $ne: 'other' },
|
|
2819
|
-
|
|
2819
|
+
}, { shelfcount: 0 }, { associatedElementFixtureNumber: 1 } );
|
|
2820
2820
|
|
|
2821
2821
|
const fixturesWithStatus = await Promise.all(
|
|
2822
2822
|
fixtures.map( async ( fixture ) => {
|
|
@@ -2917,7 +2917,7 @@ export async function storeFixturesv2( req, res ) {
|
|
|
2917
2917
|
$and: [
|
|
2918
2918
|
{ associatedElementType: { $exists: false } },
|
|
2919
2919
|
{ associatedElementNumber: { $exists: false } },
|
|
2920
|
-
{ fixtureType: { $ne: 'other' } }
|
|
2920
|
+
{ fixtureType: { $ne: 'other' } },
|
|
2921
2921
|
],
|
|
2922
2922
|
}, { shelfcount: 0 }, { associatedElementFixtureNumber: 1 } );
|
|
2923
2923
|
|
|
@@ -3495,7 +3495,7 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3495
3495
|
floorId: floor._id,
|
|
3496
3496
|
associatedElementType: element.elementType,
|
|
3497
3497
|
associatedElementNumber: element.elementNumber,
|
|
3498
|
-
fixtureType: { $ne: 'other' }
|
|
3498
|
+
fixtureType: { $ne: 'other' },
|
|
3499
3499
|
}, { shelfcount: 0 }, { associatedElementFixtureNumber: 1 } );
|
|
3500
3500
|
|
|
3501
3501
|
const fixturesWithStatus = await Promise.all(
|
|
@@ -3598,7 +3598,7 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3598
3598
|
$and: [
|
|
3599
3599
|
{ associatedElementType: { $exists: false } },
|
|
3600
3600
|
{ associatedElementNumber: { $exists: false } },
|
|
3601
|
-
{ fixtureType: { $ne: 'other' } }
|
|
3601
|
+
{ fixtureType: { $ne: 'other' } },
|
|
3602
3602
|
],
|
|
3603
3603
|
}, { shelfcount: 0 }, { associatedElementFixtureNumber: 1 } );
|
|
3604
3604
|
|
|
@@ -4864,6 +4864,7 @@ export async function getTaskDetails( req, res ) {
|
|
|
4864
4864
|
isPlano: true,
|
|
4865
4865
|
date_iso: { $lte: new Date( dayjs().format( 'YYYY-MM-DD' ) ) },
|
|
4866
4866
|
floorId: new mongoose.Types.ObjectId( req.query.floorId ),
|
|
4867
|
+
planoType: { $in: [ 'layout', 'fixture', 'vm' ] },
|
|
4867
4868
|
},
|
|
4868
4869
|
},
|
|
4869
4870
|
{
|
|
@@ -5301,9 +5302,7 @@ export async function getTaskDetails( req, res ) {
|
|
|
5301
5302
|
let taskInfo = await planotaskService.aggregate( query );
|
|
5302
5303
|
let disabledInfo = [];
|
|
5303
5304
|
let floorDetails = await layoutService.findOne( { _id: req.query.floorId }, { isEdited: 1, planoProgress: 1 } );
|
|
5304
|
-
|
|
5305
|
-
disabledInfo = taskInfo?.[0]?.taskStatus?.filter( ( ele ) => ( ( ele.feedbackStatus && ![ 'complete', 'disagree' ].includes( ele.feedbackStatus ) ) || ele.status != 'submit' ) && !ele?.breach );
|
|
5306
|
-
}
|
|
5305
|
+
disabledInfo = taskInfo?.[0]?.taskStatus?.filter( ( ele ) => ( ( ele.feedbackStatus && ![ 'complete', 'disagree' ].includes( ele.feedbackStatus ) ) || ele.status != 'submit' ) && !ele?.breach );
|
|
5307
5306
|
return res.sendSuccess( { taskDetails: taskInfo?.[0]?.taskStatus, disabled: disabledInfo?.length ? true : false, planoProgress: floorDetails?.planoProgress ?? 25 } );
|
|
5308
5307
|
} catch ( e ) {
|
|
5309
5308
|
logger.error( { functionName: 'getTaskDetails', error: e } );
|
|
@@ -694,6 +694,7 @@ export async function updateAnswersv2( req, res ) {
|
|
|
694
694
|
storeName: req.body?.storeName,
|
|
695
695
|
storeId: req.body?.storeId,
|
|
696
696
|
date_string: dayjs().format( 'YYYY-MM-DD' ),
|
|
697
|
+
approvalStatus: 'pending',
|
|
697
698
|
};
|
|
698
699
|
if ( req.body.type === 'layout' ) {
|
|
699
700
|
await planoTaskService.updateOne( { planoId: req.body.planoId, taskType: req.body.taskType, floorId: req.body.floorId, fixtureId: req.body.fixtureId, type: req.body.type, ...( taskDetails?._id ) ? { taskId: taskDetails?._id } : {} }, data );
|
|
@@ -33,4 +33,5 @@ scriptRouter
|
|
|
33
33
|
.post( '/migrateCrest', scriptController.migrateCrestv1 )
|
|
34
34
|
.post( '/updatePlanoMappings', scriptController.updatePlanoMappings )
|
|
35
35
|
.post( '/productMappings', scriptController.productMappings )
|
|
36
|
+
.get( '/getAllPlanoIdsM', scriptController.getAllPlanoIds )
|
|
36
37
|
;
|