Skip to content

Commit

Permalink
Add more actions
Browse files Browse the repository at this point in the history
  • Loading branch information
electrikmilk committed Nov 20, 2023
1 parent 37a46f3 commit 619d905
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ import ChooseFromMenu from "~/actions/choose-from-menu";
import Math from "~/actions/math";
import Stop from "~/actions/stop";
import Wait from "~/actions/wait";
import ChooseFromList from "~/actions/choose-from-list";
import CombineText from "~/actions/combine-text";
import AskForInput from "~/actions/ask-for-input";
import SplitText from "~/actions/split-text";
import GetFromList from "~/actions/get-from-list";

interface ActionDefinitions {
[key: string]: ActionDefinition
Expand All @@ -37,6 +42,10 @@ interface ActionParameterMap {

export let actions: ActionDefinitions = {
'gettext': Text,
'ask': AskForInput,
'text.combine': CombineText,
'text.split': SplitText,
'getitemfromlist': GetFromList,
'comment': Comment,
'setvariable': SetVariable,
'appendvariable': AddToVariable,
Expand All @@ -49,6 +58,7 @@ export let actions: ActionDefinitions = {
'date': Date,
'count': Count,
'choosefrommenu': ChooseFromMenu,
'choosefromlist': ChooseFromList,
'conditional': IfElse,
'repeat.count': Repeat,
'repeat.each': RepeatWithEach,
Expand Down
28 changes: 28 additions & 0 deletions src/actions/ask-for-input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {renderActionHeader, renderParameters} from "~/render";
import {actions, actionText} from "~/actions";
import {renderValue} from "~/value";

interface AskForInputParameters {
WFInputType: string,
WFAskActionPrompt: boolean,
WFAskActionDefaultAnswer: string,
WFAskActionDefaultAnswerNumber: string,
}

export default {
title: "Ask for",
icon: "plus_bubble_fill",
background: '#55bef0',
render: (container: HTMLElement, params: AskForInputParameters) => {
const action = renderActionHeader(actions['ask'],
renderValue(params['WFInputType'], 'Input Type'),
actionText("with"),
renderValue(params['WFAskActionPrompt'], 'Informational message')
);
action.appendChild(renderParameters(actions['ask'], {
'Default Answer': params['WFAskActionDefaultAnswer'] ?? params['WFAskActionDefaultAnswerNumber'],
}));

return action;
}
}
26 changes: 26 additions & 0 deletions src/actions/choose-from-list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {renderActionHeader, renderParameters} from "~/render";
import {actions} from "~/actions";
import {renderValue} from "~/value";

interface ChooseFromListParamteers {
WFInput: string,
WFChooseFromListActionPrompt: string,
WFChooseFromListActionSelectMultiple: boolean,
WFChooseFromListActionSelectAll: boolean,
}

export default {
title: "Choose from",
icon: "square_list_fill",
background: '#55bef0',
render: (container: HTMLElement, params: ChooseFromListParamteers) => {
const action = renderActionHeader(actions['choosefromlist'], renderValue(params['WFInput'], 'Informational message'));
action.appendChild(renderParameters(actions['choosefromlist'], {
'Prompt': params['WFChooseFromListActionPrompt'],
'Select Multiple': params['WFChooseFromListActionSelectMultiple'] ?? true,
'Select All Initially': params['WFChooseFromListActionSelectMultiple'] ?? true
}));

return action;
}
}
24 changes: 24 additions & 0 deletions src/actions/combine-text.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {renderActionHeader} from "~/render";
import {actions, actionText} from "~/actions";
import {renderValue} from "~/value";

interface CombineTextParameters {
text: string
WFTextSeparator: string
WFTextCustomSeparator: string
}

export default {
title: 'Combine',
color: 'white',
background: '#ffc200',
icon: 'icon-text_alignleft',
render: (container: HTMLElement, params: CombineTextParameters) => {
return renderActionHeader(actions['text.combine'],
renderValue(params['text'], 'Text List'),
actionText('with'),
renderValue(params['WFTextSeparator'] ?? null, 'Separator'),
renderValue(params['WFTextCustomSeparator'] ?? null, 'CustomSeparator'),
);
}
}
23 changes: 23 additions & 0 deletions src/actions/get-from-list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {renderActionHeader} from "~/render";
import {actions, actionText} from "~/actions";
import {renderValue} from "~/value";

interface GetFromListParameters {
WFInput: string | object,
WFItemSpecifier: string
}


export default {
title: 'Get',
color: 'white',
background: '#fc880f',
icon: 'list_bullet',
render: (container: HTMLElement, params: GetFromListParameters) => {
return renderActionHeader(actions['getitemfromlist'],
renderValue(params['WFItemSpecifier'], 'Item Specifier'),
actionText('from'),
renderValue(params['WFInput'] ?? null, 'Input'),
);
}
}
24 changes: 24 additions & 0 deletions src/actions/split-text.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {renderActionHeader} from "~/render";
import {actions, actionText} from "~/actions";
import {renderValue} from "~/value";

interface SplitTextParameters {
text: string
WFTextSeparator: string
WFTextCustomSeparator: string
}

export default {
title: 'Split',
color: 'white',
background: '#ffc200',
icon: 'icon-text_alignleft',
render: (container: HTMLElement, params: SplitTextParameters) => {
return renderActionHeader(actions['text.split'],
renderValue(params['text'], 'Text List'),
actionText('by'),
renderValue(params['WFTextSeparator'] ?? null, 'Separator'),
renderValue(params['WFTextCustomSeparator'] ?? null, 'Custom Separator'),
);
}
}

0 comments on commit 619d905

Please sign in to comment.