Uncurry addOrEditVarDeclaration.
parent
1d311f15df
commit
8969da174b
|
@ -170,11 +170,11 @@ export class EditFEForm extends React.Component<EditFEProps, State> {
|
|||
}
|
||||
|
||||
editDeclaration = (declarations: VariableDeclaration[]) =>
|
||||
(declaration: VariableDeclaration) =>
|
||||
this.setState(betterMerge(this.state, {
|
||||
fe: { body: addOrEditVarDeclaration(declarations)(declaration) },
|
||||
specialStatusLocal: SpecialStatus.DIRTY
|
||||
}));
|
||||
(declaration: VariableDeclaration) => {
|
||||
const body = addOrEditVarDeclaration(declarations, declaration);
|
||||
const state = { fe: { body }, specialStatusLocal: SpecialStatus.DIRTY };
|
||||
this.setState(betterMerge(this.state, state));
|
||||
}
|
||||
|
||||
LocalsList = () => <LocalsList
|
||||
declarations={this.declarations}
|
||||
|
@ -307,6 +307,7 @@ export class EditFEForm extends React.Component<EditFEProps, State> {
|
|||
t("Unable to save farm event."));
|
||||
return;
|
||||
}
|
||||
|
||||
this.dispatch(overwrite(this.props.farmEvent, updatedFarmEvent));
|
||||
const EditFEPath = window.location.pathname;
|
||||
this
|
||||
|
@ -410,13 +411,19 @@ export class EditFEForm extends React.Component<EditFEProps, State> {
|
|||
onClick={() => this.commitViewModel()} />
|
||||
<button className="fb-button red" hidden={!this.props.deleteBtn}
|
||||
onClick={() => {
|
||||
this.dispatch(destroy(farmEvent.uuid)).then(() => {
|
||||
history.push("/app/designer/farm_events");
|
||||
success(t("Deleted farm event."), t("Deleted"));
|
||||
});
|
||||
this
|
||||
.dispatch(destroy(farmEvent.uuid))
|
||||
.then(() => {
|
||||
history.push("/app/designer/farm_events");
|
||||
success(t("Deleted farm event."), t("Deleted"));
|
||||
});
|
||||
}}>
|
||||
{t("Delete")}
|
||||
</button>
|
||||
<br />
|
||||
<pre>
|
||||
{JSON.stringify(this.state.fe)}
|
||||
</pre>
|
||||
<TzWarning deviceTimezone={this.props.deviceTimezone} />
|
||||
</DesignerPanelContent>
|
||||
</DesignerPanel>;
|
||||
|
|
|
@ -25,8 +25,9 @@ export const declarationList = (variableData: VariableNameSet | undefined):
|
|||
};
|
||||
|
||||
/** Add a new var declaration or replace an existing one with the same label. */
|
||||
export const addOrEditVarDeclaration = (declarations: VariableDeclaration[]) =>
|
||||
(updatedItem: VariableDeclaration): VariableDeclaration[] => {
|
||||
export const addOrEditVarDeclaration =
|
||||
(declarations: VariableDeclaration[],
|
||||
updatedItem: VariableDeclaration): VariableDeclaration[] => {
|
||||
const items = reduceVarDeclarations(declarations);
|
||||
items[updatedItem.args.label] = updatedItem;
|
||||
return Object.values(items);
|
||||
|
|
|
@ -29,7 +29,7 @@ const assignVariable = (props: ExecBlockParams) =>
|
|||
sequence: currentSequence,
|
||||
index: index,
|
||||
executor(step) {
|
||||
step.body = addOrEditVarDeclaration(declarations)(variable);
|
||||
step.body = addOrEditVarDeclaration(declarations, variable);
|
||||
}
|
||||
}));
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue