fix(merge_component): 🐛 fix unsavable after accept
This commit is contained in:
parent
2afdc1e10d
commit
ef9cf48fc1
4 changed files with 42 additions and 57 deletions
|
|
@ -516,13 +516,15 @@ export class MergeComponent
|
||||||
this.selectedCommit + '_diff3'
|
this.selectedCommit + '_diff3'
|
||||||
] as Array<any>;
|
] as Array<any>;
|
||||||
// get value from the right side
|
// get value from the right side
|
||||||
let diff_recipe = this.anotherTargetRecipe[pd];
|
if(updateIdxList != undefined || updateIdxList != null){
|
||||||
|
let diff_recipe = this.anotherTargetRecipe[pd];
|
||||||
|
|
||||||
updateIdxList.forEach((idx) => {
|
updateIdxList.forEach((idx) => {
|
||||||
this.getCommitAttr(this.selectedCommit, 'contents').recipes[idx] =
|
this.getCommitAttr(this.selectedCommit, 'contents').recipes[idx] =
|
||||||
diff_recipe.recipes[idx];
|
diff_recipe.recipes[idx];
|
||||||
// TODO: add topping sync, if is topping slot, set topping too!
|
// TODO: add topping sync, if is topping slot, set topping too!
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.recipeFromMachine = this.getCommitAttr(
|
this.recipeFromMachine = this.getCommitAttr(
|
||||||
this.selectedCommit,
|
this.selectedCommit,
|
||||||
|
|
@ -534,14 +536,16 @@ export class MergeComponent
|
||||||
this.selectedCommit + '_commit'
|
this.selectedCommit + '_commit'
|
||||||
] as Array<any>;
|
] as Array<any>;
|
||||||
// get value from the left side
|
// get value from the left side
|
||||||
let commit_recipe = this.getCommitAttr(
|
if(updateIdxList != undefined || updateIdxList != null){
|
||||||
this.selectedCommit,
|
let commit_recipe = this.getCommitAttr(
|
||||||
'contents'
|
this.selectedCommit,
|
||||||
).recipes;
|
'contents'
|
||||||
updateIdxList.forEach((idx) => {
|
).recipes;
|
||||||
this.anotherTargetRecipe[pd].recipes[idx] = commit_recipe[idx];
|
updateIdxList.forEach((idx) => {
|
||||||
// TODO: add topping sync, if is topping slot, set topping too!
|
this.anotherTargetRecipe[pd].recipes[idx] = commit_recipe[idx];
|
||||||
});
|
// TODO: add topping sync, if is topping slot, set topping too!
|
||||||
|
});
|
||||||
|
}
|
||||||
this.recipeFromMachine = this.anotherTargetRecipe[pd];
|
this.recipeFromMachine = this.anotherTargetRecipe[pd];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,45 +5,6 @@
|
||||||
<button class="btn w-1/2" (click)="addRow()">Add</button>
|
<button class="btn w-1/2" (click)="addRow()">Add</button>
|
||||||
<button class="btn w-1/2" (click)="removeRow()">Remove</button>
|
<button class="btn w-1/2" (click)="removeRow()">Remove</button>
|
||||||
</div>
|
</div>
|
||||||
<details class="hidden">
|
|
||||||
<summary>Console</summary>
|
|
||||||
<div class="m-2 p-2 !rounded-md bg-gray-400">
|
|
||||||
<!-- other -->
|
|
||||||
<div class="p-2 bg-gray-200 space-x-2" id="command">
|
|
||||||
<div class="flex flex-row p-2 space-x-2">
|
|
||||||
<input type="checkbox" id="command-enable" />
|
|
||||||
<p>Command</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- <input class="w-56" type="text"> -->
|
|
||||||
<div class="flex flex-row">
|
|
||||||
<div class="mockup-code">
|
|
||||||
<code class="">
|
|
||||||
<textarea
|
|
||||||
class="p-2 resize-none bg-black text-white text-sm textarea-xs"
|
|
||||||
id="command-code"
|
|
||||||
cols="100"
|
|
||||||
rows="10"
|
|
||||||
>
|
|
||||||
//"!tb help" for more info.</textarea
|
|
||||||
>
|
|
||||||
<div class="divider divider-vertical"></div>
|
|
||||||
<textarea
|
|
||||||
class="p-2 bg-black text-green-600 text-sm textarea-xs resize-none"
|
|
||||||
id="command-output"
|
|
||||||
cols="100"
|
|
||||||
rows="10"
|
|
||||||
disabled
|
|
||||||
></textarea>
|
|
||||||
</code>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="flex justify-end">
|
|
||||||
<button class="m-2 btn btn-warning right-2" (click)="eval()">OK</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</details>
|
|
||||||
<table class="table table-xs" [formGroup]="recipeListForm">
|
<table class="table table-xs" [formGroup]="recipeListForm">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="bg-gray-200">
|
<tr class="bg-gray-200">
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
// <p>Command</p>
|
// <p>Command</p>
|
||||||
// </div>
|
// </div>
|
||||||
|
|
||||||
|
import { HttpClient } from "@angular/common/http";
|
||||||
|
|
||||||
// <!-- <input class="w-56" type="text"> -->
|
// <!-- <input class="w-56" type="text"> -->
|
||||||
// <div class="flex flex-row gap-2">
|
// <div class="flex flex-row gap-2">
|
||||||
// <code class="">
|
// <code class="">
|
||||||
|
|
@ -33,6 +35,7 @@ export class Debugger {
|
||||||
"!tb vars - view all stored variables",
|
"!tb vars - view all stored variables",
|
||||||
"!tb var::<name> - get variable value by stored name",
|
"!tb var::<name> - get variable value by stored name",
|
||||||
"!tb get::<name> - get value of variable in angular",
|
"!tb get::<name> - get value of variable in angular",
|
||||||
|
"!tb get::<name> -> <var_name> - get value in angular and immidiately apply to new varible",
|
||||||
"!tb fn::<name> <...args> - execute the function with args",
|
"!tb fn::<name> <...args> - execute the function with args",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -110,6 +113,12 @@ export class Debugger {
|
||||||
case "help":
|
case "help":
|
||||||
this.output.push(this.commandList.join("\n"));
|
this.output.push(this.commandList.join("\n"));
|
||||||
break;
|
break;
|
||||||
|
case "server_refresh":
|
||||||
|
this.output.push("sending signal to server...");
|
||||||
|
// let client: HttpClient = new HttpClient({
|
||||||
|
// handle:
|
||||||
|
// });
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -484,7 +484,7 @@ func (d *Data) GetRecipe01ByProductCode(filename, countryID, productCode string)
|
||||||
|
|
||||||
func (d *Data) SetValuesToRecipe(base_recipe []models.Recipe01, recipe models.Recipe01) {
|
func (d *Data) SetValuesToRecipe(base_recipe []models.Recipe01, recipe models.Recipe01) {
|
||||||
not_found := false
|
not_found := false
|
||||||
global_idx := 0
|
// global_idx := 0
|
||||||
for index, v := range base_recipe {
|
for index, v := range base_recipe {
|
||||||
if v.ProductCode == recipe.ProductCode {
|
if v.ProductCode == recipe.ProductCode {
|
||||||
// Log.Debug("SetValuesToRecipe", zap.Any("old", v), zap.Any("new", recipe))
|
// Log.Debug("SetValuesToRecipe", zap.Any("old", v), zap.Any("new", recipe))
|
||||||
|
|
@ -529,12 +529,13 @@ func (d *Data) SetValuesToRecipe(base_recipe []models.Recipe01, recipe models.Re
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
not_found = true
|
not_found = true
|
||||||
global_idx = index
|
// global_idx = index
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if not_found {
|
if not_found {
|
||||||
base_recipe[global_idx+1] = recipe
|
// base_recipe[global_idx+1] = recipe
|
||||||
|
base_recipe = append(base_recipe, recipe)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1033,6 +1034,9 @@ func (d *Data) SortRecipe(countryID, filename string, sort_by string) (error, []
|
||||||
// merge
|
// merge
|
||||||
|
|
||||||
func (d *Data) Merge(country string, filename string, attr string, changeKey string, updated interface{}) (string, error) {
|
func (d *Data) Merge(country string, filename string, attr string, changeKey string, updated interface{}) (string, error) {
|
||||||
|
d.taoLogger.Log.Debug("check on merge request", zap.Any("args", []string{
|
||||||
|
country, filename, attr, changeKey,
|
||||||
|
}))
|
||||||
|
|
||||||
// change this to switch case
|
// change this to switch case
|
||||||
if attr == "Recipe" {
|
if attr == "Recipe" {
|
||||||
|
|
@ -1041,7 +1045,14 @@ func (d *Data) Merge(country string, filename string, attr string, changeKey str
|
||||||
if updated == nil {
|
if updated == nil {
|
||||||
return "UpdatedValueError", fmt.Errorf("updated value is nil")
|
return "UpdatedValueError", fmt.Errorf("updated value is nil")
|
||||||
}
|
}
|
||||||
return d.MergeRecipeNoCache(country, filename, updated.(models.Recipe01))
|
|
||||||
|
// type assertion
|
||||||
|
updatedModel, ok := updated.(models.Recipe01)
|
||||||
|
d.taoLogger.Log.Debug("check on update model", zap.Any("appliedFromClient", updatedModel))
|
||||||
|
if !ok {
|
||||||
|
return d.MergeRecipeNoCache(country, filename, updatedModel)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return "NotKnownAttr", nil
|
return "NotKnownAttr", nil
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue