Skip to content

Commit 338a8fa

Browse files
committed
Added query variables on Query Dialogue, added parameters on Run a Data Query of Event Handlers.
1 parent c3068a6 commit 338a8fa

File tree

7 files changed

+83
-16
lines changed

7 files changed

+83
-16
lines changed

client/packages/lowcoder/src/comps/controls/actionSelector/executeQueryAction.tsx

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ import { BranchDiv, Dropdown } from "lowcoder-design";
77
import { BottomResTypeEnum } from "types/bottomRes";
88
import { getPromiseAfterDispatch } from "util/promiseUtils";
99
import { trans } from "i18n";
10+
import {keyValueListControl, keyValueListToSearchStr, withDefault} from "lowcoder-sdk";
11+
import {KeyValue} from "@lowcoder-ee/types/common";
1012

1113
const ExecuteQueryTmpAction = (function () {
1214
const childrenMap = {
1315
queryName: SimpleNameComp,
16+
query: withDefault(keyValueListControl(false, [], "string"), [{ key: "", value: "" }])
1417
};
1518
return new MultiCompBuilder(childrenMap, () => {
1619
return () => Promise.resolve(undefined as unknown);
@@ -22,6 +25,8 @@ const ExecuteQueryTmpAction = (function () {
2225
export class ExecuteQueryAction extends ExecuteQueryTmpAction {
2326
override getView() {
2427
const queryName = this.children.queryName.getView();
28+
const queryParams = keyValueListToSearchStr(Array.isArray(this?.children?.query) ? (this.children.query as unknown as any[]).map((i: any) => i.getView() as KeyValue) : []);
29+
console.log(queryParams, queryName);
2530
if (!queryName) {
2631
return () => Promise.resolve();
2732
}
@@ -80,21 +85,29 @@ export class ExecuteQueryAction extends ExecuteQueryTmpAction {
8085
return options;
8186
};
8287
return (
83-
<BranchDiv $type={"inline"}>
84-
<EditorContext.Consumer>
85-
{(editorState) => (
86-
<>
87-
<Dropdown
88-
showSearch={true}
89-
value={this.children.queryName.getView()}
90-
options={getQueryOptions(editorState)}
91-
label={trans("eventHandler.selectQuery")}
92-
onChange={(value) => this.dispatchChangeValueAction({ queryName: value })}
93-
/>
94-
</>
95-
)}
96-
</EditorContext.Consumer>
97-
</BranchDiv>
88+
<>
89+
<BranchDiv $type={"inline"}>
90+
<EditorContext.Consumer>
91+
{(editorState) => (
92+
<>
93+
<Dropdown
94+
showSearch={true}
95+
value={this.children.queryName.getView()}
96+
options={getQueryOptions(editorState)}
97+
label={trans("eventHandler.selectQuery")}
98+
onChange={(value) => this.dispatchChangeValueAction({ queryName: value })}
99+
/>
100+
</>
101+
)}
102+
</EditorContext.Consumer>
103+
</BranchDiv>
104+
<BranchDiv>
105+
{this.children.query.propertyView({
106+
label: trans("eventHandler.queryParams"),
107+
layout: "vertical",
108+
})}
109+
</BranchDiv>
110+
</>
98111
);
99112
}
100113
}

client/packages/lowcoder/src/comps/controls/actionSelector/goToURLAction.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const childrenMap = {
2020
};
2121

2222
export const GoToURLAction = new MultiCompBuilder(childrenMap, (props) => {
23-
return () => {
23+
return () => {
2424
const queryParams = keyValueListToSearchStr(
2525
props.query.map((i) => i.getView() as KeyValue)
2626
);

client/packages/lowcoder/src/comps/queries/queryComp.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ import { QueryNotificationControl } from "./queryComp/queryNotificationControl";
7575
import { QueryPropertyView } from "./queryComp/queryPropertyView";
7676
import { getTriggerType, onlyManualTrigger } from "./queryCompUtils";
7777
import { messageInstance } from "lowcoder-design/src/components/GlobalInstances";
78+
import {VariablesComp} from "@lowcoder-ee/comps/queries/queryComp/variablesCompl";
7879

7980
const latestExecution: Record<string, string> = {};
8081

@@ -153,6 +154,7 @@ const childrenMap = {
153154
defaultValue: 10 * 1000,
154155
}),
155156
confirmationModal: QueryConfirmationModal,
157+
variables: VariablesComp,
156158
periodic: BoolPureControl,
157159
periodicTime: millisecondsControl({
158160
defaultValue: Number.NaN,

client/packages/lowcoder/src/comps/queries/queryComp/queryPropertyView.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,17 @@ export function QueryPropertyView(props: { comp: InstanceType<typeof QueryComp>
171171
</QueryPropertyViewWrapper>
172172
),
173173
},
174+
{
175+
key: "variables",
176+
title: trans("query.variablesTab"),
177+
children: (
178+
<QueryPropertyViewWrapper>
179+
<QuerySectionWrapper>
180+
{children.variables.getPropertyView()}
181+
</QuerySectionWrapper>
182+
</QueryPropertyViewWrapper>
183+
),
184+
},
174185
] as const
175186
}
176187
tabTitle={children.name.getView()}
@@ -501,6 +512,29 @@ export const QueryGeneralPropertyView = (props: {
501512
);
502513
};
503514

515+
export const QueryVariablesPropertyView = (props: {
516+
comp: InstanceType<typeof QueryComp>;
517+
placement?: PageType;
518+
}) => {
519+
const { comp, placement = "editor" } = props;
520+
521+
const children = comp.children;
522+
let datasourceId = children.datasourceId.getView();
523+
524+
console.log(children.datasourceId);
525+
return (
526+
<QueryPropertyViewWrapper>
527+
<QuerySectionWrapper>
528+
{isCompWithPropertyView(children.comp)
529+
? children.comp.propertyView({
530+
datasourceId: datasourceId,
531+
})
532+
: children.comp.getPropertyView()}
533+
</QuerySectionWrapper>
534+
</QueryPropertyViewWrapper>
535+
);
536+
};
537+
504538
function findQueryInNestedStructure(
505539
structure: any,
506540
queryName: string,
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {MultiCompBuilder, withDefault} from "../../generators";
2+
import {keyValueListControl} from "lowcoder-sdk";
3+
4+
export const VariablesComp = new MultiCompBuilder(
5+
{
6+
variables: withDefault(keyValueListControl(), [{ key: "", value: "" }]),
7+
},
8+
(props) =>
9+
props.variables
10+
)
11+
.setPropertyViewFn((children) => (
12+
<>
13+
{children.variables.propertyView({})}
14+
</>
15+
))
16+
.build();

client/packages/lowcoder/src/i18n/locales/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ export const en = {
705705
"newDatasource": "New Data Source",
706706
"generalTab": "General",
707707
"notificationTab": "Notification",
708+
"variablesTab": "Variables",
708709
"advancedTab": "Advanced",
709710
"showFailNotification": "Show Notification on Failure",
710711
"failCondition": "Failure Conditions",

client/packages/lowcoder/src/util/appUtils.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export function openApp(props: {
3232
hashParams?: string;
3333
newTab?: boolean;
3434
}) {
35+
console.log(props.queryParams)
3536
const m = matchPath<AppPathParams>(window.location.pathname, APP_EDITOR_URL);
3637
if (!m || !props.applicationId) {
3738
return;

0 commit comments

Comments
 (0)