fix(merge_component): 🐛 fix data lost after applied from merge
Fixing data lost after pressed on apply button in merge modal, WIP selection merge
This commit is contained in:
parent
cd0f67bb44
commit
58746ebdfb
5 changed files with 182 additions and 50 deletions
|
|
@ -34,6 +34,7 @@ import { FormsModule } from '@angular/forms';
|
|||
import { RecipeListComponent } from '../recipes/recipe-details/recipe-list/recipe-list.component';
|
||||
import { ResizeEvent, ResizableModule } from 'angular-resizable-element';
|
||||
import { Debugger } from 'src/app/shared/helpers/debugger';
|
||||
import { convertFromInterProductCode, inRange } from 'src/app/shared/helpers/recipe';
|
||||
|
||||
@Component({
|
||||
selector: 'app-merge',
|
||||
|
|
@ -442,7 +443,12 @@ export class MergeComponent
|
|||
}
|
||||
}
|
||||
|
||||
console.log("fromMachine",this.recipeFromMachine);
|
||||
|
||||
if (Object.keys(this.recipeFromMachine).length > 0) {
|
||||
|
||||
// cat master to target
|
||||
this.concatNoEditKeyToMap(this.recipeFromMachine, this.targetRecipe[this.getCommitAttr(this.selectedCommit, 'contents').productCode]);
|
||||
to_send['appliedMachineRecipe'] = this.recipeFromMachine;
|
||||
}
|
||||
|
||||
|
|
@ -455,6 +461,8 @@ export class MergeComponent
|
|||
|
||||
console.log('sending upgrade', to_send);
|
||||
|
||||
// alert("sending .. ")
|
||||
|
||||
this._recipeService
|
||||
.upgradeRecipe(
|
||||
await this._recipeService.getCurrentCountry(),
|
||||
|
|
@ -508,6 +516,7 @@ export class MergeComponent
|
|||
|
||||
// get current pd
|
||||
let pd = this.getCommitAttr(this.selectedCommit, 'contents').productCode;
|
||||
console.log("check content", compare(this.targetRecipe[pd], this.getCommitAttr(this.selectedCommit, 'contents')));
|
||||
|
||||
if (base != '') {
|
||||
switch (base) {
|
||||
|
|
@ -523,6 +532,11 @@ export class MergeComponent
|
|||
this.getCommitAttr(this.selectedCommit, 'contents').recipes[idx] =
|
||||
diff_recipe.recipes[idx];
|
||||
// TODO: add topping sync, if is topping slot, set topping too!
|
||||
|
||||
if(inRange(8111, 8130, convertFromInterProductCode(diff_recipe.recipes[idx].materialPathId))){
|
||||
let toppingSlot = convertFromInterProductCode(diff_recipe.recipes[idx].materialPathId )- 8110;
|
||||
this.getCommitAttr(this.selectedCommit, 'contents').ToppingSet[toppingSlot] = diff_recipe.ToppingSet[toppingSlot];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -544,6 +558,10 @@ export class MergeComponent
|
|||
updateIdxList.forEach((idx) => {
|
||||
this.anotherTargetRecipe[pd].recipes[idx] = commit_recipe[idx];
|
||||
// TODO: add topping sync, if is topping slot, set topping too!
|
||||
if(inRange(8111, 8130, convertFromInterProductCode(commit_recipe.recipes[idx].materialPathId))){
|
||||
let toppingSlot = convertFromInterProductCode(commit_recipe.recipes[idx].materialPathId )- 8110;
|
||||
this.anotherTargetRecipe[pd].ToppingSet[toppingSlot] = commit_recipe.ToppingSet[toppingSlot];
|
||||
}
|
||||
});
|
||||
}
|
||||
this.recipeFromMachine = this.anotherTargetRecipe[pd];
|
||||
|
|
@ -663,4 +681,12 @@ export class MergeComponent
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
concatNoEditKeyToMap(source: any, target: any) {
|
||||
for (const key of Object.keys(source)) {
|
||||
if (!Object.keys(target).includes(key)) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -221,6 +221,7 @@ export class RecipeDetailsComponent implements OnInit {
|
|||
SubMenu: [...(this.rawRecipe! as any).SubMenu!],
|
||||
ToppingSet: [...(this.rawRecipe as any).ToppingSet],
|
||||
};
|
||||
console.log('pre to_send', to_send);
|
||||
|
||||
this.concatNoEditKeyToMap(this.rawRecipe, to_send);
|
||||
|
||||
|
|
|
|||
|
|
@ -539,12 +539,15 @@ export class RecipesComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||
|
||||
// end of Recipe Version selection
|
||||
|
||||
openJsonTab() {
|
||||
async openJsonTab() {
|
||||
|
||||
let country = await this._recipeService.getCurrentCountry(
|
||||
this.department
|
||||
);
|
||||
|
||||
window.open(
|
||||
environment.api +
|
||||
`/recipes/${this._recipeService.getCurrentCountry(
|
||||
this.department
|
||||
)}/${this._recipeService.getCurrentFile()}/json`,
|
||||
`/recipes/${country}/${this._recipeService.getCurrentFile()}/json`,
|
||||
'_blank'
|
||||
);
|
||||
}
|
||||
|
|
@ -669,7 +672,7 @@ export class RecipesComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||
next: (data: any) => {
|
||||
if(data.status == 'OK'){
|
||||
console.log(data.result);
|
||||
alert("refresh ... ");
|
||||
// alert("refresh ... ");
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue