tango-app-api-store-builder 1.0.0-beta-82 → 1.0.0-beta-83

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-store-builder",
3
- "version": "1.0.0-beta-82",
3
+ "version": "1.0.0-beta-83",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -3689,6 +3689,10 @@ export async function updatelayout( req, res ) {
3689
3689
  ...( key == 'floor' ) ? { header: '', footer: '' } : {},
3690
3690
  };
3691
3691
  fixtureDetails.splice( fixtureIndex, 1 );
3692
+ let matchFixtureIndex = matchingFixtures.findIndex( ( fix ) => fix._id.toString() == fixture.fixtureId.toString() );
3693
+ if ( matchFixtureIndex != -1 ) {
3694
+ matchingFixtures.splice( matchFixtureIndex, 1 );
3695
+ }
3692
3696
  if ( maxFixtureNumber < parseInt( fixture.position ) ) {
3693
3697
  details.associatedElementFixtureNumber = maxFixtureNumber + 1;
3694
3698
  matchingFixtures.splice( maxFixtureNumber, 0, details );
@@ -3757,7 +3761,10 @@ export async function updatelayout( req, res ) {
3757
3761
  let fixtureDoc = await storeFixtureService.create( fixtureData );
3758
3762
  if ( fixtureDoc ) {
3759
3763
  let productCount = 0;
3760
- fixtureDetails.splice( parseInt( fixture.position ) - 1, 0, JSON.parse( JSON.stringify( fixtureDoc ) ) );
3764
+ matchingFixtures.splice( parseInt( fixture.position ) - 1, 0, JSON.parse( JSON.stringify( fixtureDoc ) ) );
3765
+ let fixIdList = matchingFixtures.map( ( mixFixture ) => mixFixture._id.toString() );
3766
+ fixtureDetails = fixtureDetails.filter( ( fixt ) => !fixIdList.includes( fixt._id.toString() ) );
3767
+ fixtureDetails.push( ...matchingFixtures );
3761
3768
  let shelfDetails = layoutAnswer.shlef[fixtureIndex];
3762
3769
  for ( let i=0; i<shelfDetails.count; i++ ) {
3763
3770
  const insertData = {
@@ -3810,6 +3817,9 @@ export async function updatelayout( req, res ) {
3810
3817
  };
3811
3818
 
3812
3819
  await storeFixtureService.updateOne( { _id: element._id }, data );
3820
+ if ( key == 'floor' ) {
3821
+ await storeFixtureService.removeKeys( { _id: element._id }, { $unset: { header: '', footer: '', associatedElementType: '', associatedElementNumber: '' } } );
3822
+ }
3813
3823
  }
3814
3824
  }
3815
3825
  await updatePlanoFixtureLayout( layout.planoId, layout.floorId );
@@ -41,4 +41,4 @@ export async function upsertOne( query, record ) {
41
41
  record,
42
42
  { upsert: true, new: true },
43
43
  );
44
- }
44
+ }
@@ -51,3 +51,7 @@ export async function upsertOne( query, record ) {
51
51
  { upsert: true, new: true },
52
52
  );
53
53
  }
54
+
55
+ export async function removeKeys( query, data ) {
56
+ return model.storeFixtureModel.updateOne( query, data );
57
+ }