Skip to content

Commit

Permalink
Add AST changer to util functions
Browse files Browse the repository at this point in the history
  • Loading branch information
joswarmer committed Oct 1, 2024
1 parent 33d8642 commit ff9f830
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {BoxFactory, LimitedControlBox, LimitedDisplay, SelectBox, SelectOption}
import { FreLanguage, FreLanguageProperty } from "../../../language/index.js";
import { UtilCheckers } from "./UtilCheckers.js";
import { RoleProvider } from "../RoleProvider.js";
import { runInAction } from "mobx";
import {FreScoper} from "../../../scoper/index.js";
import {FreEditor} from "../../FreEditor.js";
import {BehaviorExecutionResult} from "../../util/index.js";
Expand Down Expand Up @@ -101,19 +100,18 @@ export class UtilLimitedHelpers {
node,
roleName,
() => (node[propertyName] === null ? [] : [node[propertyName].name]),
(v: string[]) =>
runInAction(() => {
(v: string[]) => {
if (!!v[0]) {
// console.log("========> set property [" + propertyName + "] of " + node["name"] + " := " + v[0]);
runInAction(() => {
AST.changeNamed(`Limited for property ${propertyName} set to ${v[0]}`, () => {
setFunc(v[0]);
});
} else {
runInAction(() => {
AST.changeNamed(`Limited for property ${propertyName} set to null`, () => {
node[propertyName] = null;
});
}
}),
},
possibleValues,
);
result.showAs = LimitedDisplay.RADIO_BUTTON;
Expand Down Expand Up @@ -170,11 +168,11 @@ export class UtilLimitedHelpers {
// L.log("==> SET selected option for property " + propertyName + " of " + element["name"] + " to " + option?.label);
if (!!option) {
// console.log("========> set property [" + propertyName + "] of " + element["name"] + " := " + option.label);
runInAction(() => {
AST.changeNamed(`UtilLimitedHelpers.limitedSelectBox for property ${propertyName} set to ${option.label}`, () => {
setFunc(option.label);
});
} else {
runInAction(() => {
AST.changeNamed(`UtilLimitedHelpers.limitedSelectBox for property ${propertyName} set to null`, () => {
node[propertyName] = null;
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AST } from "../../../change-manager/index.js";
import {
Box,
BoxFactory,
Expand All @@ -16,7 +17,6 @@ import { BoxUtil, FreListInfo } from "../BoxUtil.js";
import { UtilCommon } from "./UtilCommon.js";
import { FreLanguage } from "../../../language/index.js";
import { FreEditor } from "../../FreEditor.js";
import { runInAction } from "mobx";
import { FreUtils } from "../../../util/index.js";

export class UtilRefHelpers {
Expand Down Expand Up @@ -70,11 +70,11 @@ export class UtilRefHelpers {
// L.log("==> SET selected option for property " + propertyName + " of " + element["name"] + " to " + option?.label);
if (!!option) {
// console.log("========> set property [" + propertyName + "] of " + element["name"] + " := " + option.label);
runInAction(() => {
AST.changeNamed(`UtilRefHelpers.referenceBox for property ${propertyName} set to ${option.label}`, () => {
setFunc(option.label);
});
} else {
runInAction(() => {
AST.changeNamed(`UtilRefHelpers.referenceBox for property ${propertyName} set to null`, () => {
node[propertyName] = null;
});
}
Expand Down

0 comments on commit ff9f830

Please sign in to comment.