Skip to content

Commit

Permalink
Implement Calculate action
Browse files Browse the repository at this point in the history
  • Loading branch information
electrikmilk committed Nov 16, 2023
1 parent b75c95b commit 49ef108
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Url from "~/actions/url";
import Date from "~/actions/date";
import Count from "~/actions/count";
import ChooseFromMenu from "~/actions/choose-from-menu";
import Math from "~/actions/math";

interface ActionDefinitions {
[key: string]: ActionDefinition
Expand Down Expand Up @@ -49,6 +50,7 @@ export let actions: ActionDefinitions = {
'conditional': IfElse,
'repeat.count': Repeat,
'repeat.each': RepeatWithEach,
'math': Math,
};

export function actionText(text: string): HTMLElement {
Expand Down
21 changes: 21 additions & 0 deletions src/actions/math.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {renderValue} from "~/value";
import {renderActionHeader} from "~/render";
import {actions} from "~/actions";

interface MathParameters {
WFInput: string | object
WFMathOperation: string | object
WFMathOperand: string | object
}

export default {
icon: "plus_slash_minus",
background: "#8e8e93",
render: (container: HTMLElement, params: MathParameters) => {
return renderActionHeader(actions['math'],
renderValue(params['WFInput'], 'Number'),
renderValue(params['WFMathOperation'] ?? '+', 'Operation'),
renderValue(params['WFMathOperand'], 'Number'),
);
}
}

0 comments on commit 49ef108

Please sign in to comment.