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'
|
||||
] as Array<any>;
|
||||
// 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) => {
|
||||
this.getCommitAttr(this.selectedCommit, 'contents').recipes[idx] =
|
||||
diff_recipe.recipes[idx];
|
||||
// TODO: add topping sync, if is topping slot, set topping too!
|
||||
});
|
||||
updateIdxList.forEach((idx) => {
|
||||
this.getCommitAttr(this.selectedCommit, 'contents').recipes[idx] =
|
||||
diff_recipe.recipes[idx];
|
||||
// TODO: add topping sync, if is topping slot, set topping too!
|
||||
});
|
||||
}
|
||||
|
||||
this.recipeFromMachine = this.getCommitAttr(
|
||||
this.selectedCommit,
|
||||
|
|
@ -534,14 +536,16 @@ export class MergeComponent
|
|||
this.selectedCommit + '_commit'
|
||||
] as Array<any>;
|
||||
// get value from the left side
|
||||
let commit_recipe = this.getCommitAttr(
|
||||
this.selectedCommit,
|
||||
'contents'
|
||||
).recipes;
|
||||
updateIdxList.forEach((idx) => {
|
||||
this.anotherTargetRecipe[pd].recipes[idx] = commit_recipe[idx];
|
||||
// TODO: add topping sync, if is topping slot, set topping too!
|
||||
});
|
||||
if(updateIdxList != undefined || updateIdxList != null){
|
||||
let commit_recipe = this.getCommitAttr(
|
||||
this.selectedCommit,
|
||||
'contents'
|
||||
).recipes;
|
||||
updateIdxList.forEach((idx) => {
|
||||
this.anotherTargetRecipe[pd].recipes[idx] = commit_recipe[idx];
|
||||
// TODO: add topping sync, if is topping slot, set topping too!
|
||||
});
|
||||
}
|
||||
this.recipeFromMachine = this.anotherTargetRecipe[pd];
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,45 +5,6 @@
|
|||
<button class="btn w-1/2" (click)="addRow()">Add</button>
|
||||
<button class="btn w-1/2" (click)="removeRow()">Remove</button>
|
||||
</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">
|
||||
<thead>
|
||||
<tr class="bg-gray-200">
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
// <p>Command</p>
|
||||
// </div>
|
||||
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
|
||||
// <!-- <input class="w-56" type="text"> -->
|
||||
// <div class="flex flex-row gap-2">
|
||||
// <code class="">
|
||||
|
|
@ -33,6 +35,7 @@ export class Debugger {
|
|||
"!tb vars - view all stored variables",
|
||||
"!tb var::<name> - get variable value by stored name",
|
||||
"!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",
|
||||
];
|
||||
|
||||
|
|
@ -110,6 +113,12 @@ export class Debugger {
|
|||
case "help":
|
||||
this.output.push(this.commandList.join("\n"));
|
||||
break;
|
||||
case "server_refresh":
|
||||
this.output.push("sending signal to server...");
|
||||
// let client: HttpClient = new HttpClient({
|
||||
// handle:
|
||||
// });
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
|
|
|
|||
|
|
@ -484,7 +484,7 @@ func (d *Data) GetRecipe01ByProductCode(filename, countryID, productCode string)
|
|||
|
||||
func (d *Data) SetValuesToRecipe(base_recipe []models.Recipe01, recipe models.Recipe01) {
|
||||
not_found := false
|
||||
global_idx := 0
|
||||
// global_idx := 0
|
||||
for index, v := range base_recipe {
|
||||
if v.ProductCode == recipe.ProductCode {
|
||||
// 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 {
|
||||
not_found = true
|
||||
global_idx = index
|
||||
// global_idx = index
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
if attr == "Recipe" {
|
||||
|
|
@ -1041,7 +1045,14 @@ func (d *Data) Merge(country string, filename string, attr string, changeKey str
|
|||
if updated == 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue