fix update recipe
This commit is contained in:
@@ -21,6 +21,7 @@ declare module Recipe {
|
||||
valueAct: number,
|
||||
numDec: number,
|
||||
id: number,
|
||||
checkpointHMI: number;
|
||||
enumVal: { [id: string]: { text: string, anim: string } }
|
||||
}
|
||||
|
||||
|
||||
@@ -27,18 +27,23 @@ export class RecipeService extends baseRestService {
|
||||
async Update(model: { [id: string]: Recipe.IValue }) {
|
||||
|
||||
let payload = {}
|
||||
let needsUpdate = false;
|
||||
|
||||
for (const key in model) {
|
||||
if (model.hasOwnProperty(key)) {
|
||||
if (model.hasOwnProperty(key) && model[key].setpointHMI != model[key].checkpointHMI) {
|
||||
if (typeof model[key]?.setpointHMI === "boolean")
|
||||
payload[key] = model[key]?.setpointHMI ? 1 : 0;
|
||||
else
|
||||
payload[key] = model[key]?.setpointHMI;
|
||||
|
||||
// resetto il checkpoint
|
||||
model[key].checkpointHMI = model[key].setpointHMI;
|
||||
needsUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
let result = await this.Put<any>((await this.BASE_URL()) + "update", payload, true);
|
||||
return result;
|
||||
if (!needsUpdate) return;
|
||||
await this.Put<any>((await this.BASE_URL()) + "update", payload, true);
|
||||
}
|
||||
|
||||
async UpdateChanges(newmodel: { [id: string]: Recipe.IValue }, oldmodel: { [id: string]: Recipe.IValue }) {
|
||||
@@ -60,6 +65,7 @@ export class RecipeService extends baseRestService {
|
||||
|
||||
async Confirm(section: string) {
|
||||
let result = await this.Put<any>((await this.BASE_URL()) + "confirm?section=" + section, null, true);
|
||||
recipeActions.resetCheckPoint(store);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ export interface RecipeActions {
|
||||
setChanged(context, value);
|
||||
setCurrent(context, model: Recipe.IRecipe, avoidSetpointHMI: boolean);
|
||||
setOverview(context, model: Overview.IOverview);
|
||||
resetCheckPoint(context);
|
||||
}
|
||||
|
||||
export interface RecipeGetters {
|
||||
@@ -72,6 +73,8 @@ export const recipeStore = {
|
||||
if (model.avoidSetpoint)
|
||||
m.setpointHMI = v.setpointHMI;
|
||||
Object.assign(v, m);
|
||||
if (!model.avoidSetpoint)
|
||||
v.checkpointHMI = v.setpointHMI;
|
||||
}
|
||||
else {
|
||||
(state._map as Map<number, Recipe.IValue>).set(m.id, m)
|
||||
@@ -81,7 +84,13 @@ export const recipeStore = {
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
ResetCheckpoint(state) {
|
||||
for (const key in state.current)
|
||||
if (state.current.hasOwnProperty(key)) {
|
||||
let m = state.current[key] as Recipe.IValue;
|
||||
m.checkpointHMI = m.setpointHMI;
|
||||
}
|
||||
},
|
||||
SetOverview(state, model: Overview.IOverview) {
|
||||
for (const key in model) {
|
||||
if (model.hasOwnProperty(key)) {
|
||||
@@ -106,6 +115,9 @@ export const recipeStore = {
|
||||
reset(context) {
|
||||
context.commit("Reset")
|
||||
},
|
||||
resetCheckPoint(context) {
|
||||
context.commit("ResetCheckpoint");
|
||||
},
|
||||
async setCurrent(context, model: Recipe.IRecipe, avoidSetpointHMI: boolean = false) {
|
||||
context.commit("SetCurrent", { avoidSetpoint: avoidSetpointHMI, recipe: model });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user