Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 11f1022

Browse files
Merge pull request lowcoder-org#1058 from MenamAfzal/addqueryparams
Addqueryparams
2 parents ab27214 + 670e8ba commit 11f1022

File tree

1 file changed

+59
-29
lines changed

1 file changed

+59
-29
lines changed
Lines changed: 59 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,65 @@
1-
import { StringControl } from "comps/controls/codeControl";
2-
import { BoolControl } from "comps/controls/boolControl";
31
import { MultiCompBuilder } from "comps/generators/multi";
2+
import { withDefault } from "comps/generators/simpleGenerators";
43
import { BranchDiv } from "lowcoder-design";
4+
import { KeyValue } from "types/common";
5+
import { BoolControl } from "comps/controls/boolControl";
6+
import { StringControl } from "comps/controls/codeControl";
7+
import { keyValueListControl } from "../keyValueControl";
8+
import { keyValueListToSearchStr } from "../../../util/appUtils";
59
import { trans } from "i18n";
610

7-
export const GoToURLAction = (function () {
8-
const childrenMap = {
9-
url: StringControl,
10-
inNewTab: BoolControl,
11+
const childrenMap = {
12+
url: StringControl,
13+
query: withDefault(keyValueListControl(false, [], "string"), [
14+
{ key: "", value: "" },
15+
]),
16+
hash: withDefault(keyValueListControl(false, [], "string"), [
17+
{ key: "", value: "" },
18+
]),
19+
inNewTab: BoolControl,
20+
};
21+
22+
export const GoToURLAction = new MultiCompBuilder(childrenMap, (props) => {
23+
return () => {
24+
const queryParams = keyValueListToSearchStr(
25+
props.query.map((i) => i.getView() as KeyValue)
26+
);
27+
const hashParams = keyValueListToSearchStr(
28+
props.hash.map((i) => i.getView() as KeyValue)
29+
);
30+
const urlWithParams = `${props.url}${queryParams ? `?${queryParams}` : ""}${hashParams ? `#${hashParams}` : ""}`;
31+
32+
window.open(urlWithParams, props.inNewTab ? "_blank" : "_self");
1133
};
12-
return new MultiCompBuilder(childrenMap, (props) => {
13-
return () => {
14-
window.open(props.url, props.inNewTab ? "_blank" : "_self");
15-
};
34+
})
35+
.setPropertyViewFn((children) => {
36+
return (
37+
<>
38+
<BranchDiv>
39+
{children.url.propertyView({
40+
label: "URL",
41+
layout: "vertical",
42+
})}
43+
</BranchDiv>
44+
<BranchDiv>
45+
{children.query.propertyView({
46+
label: trans("eventHandler.queryParams"),
47+
layout: "vertical",
48+
})}
49+
</BranchDiv>
50+
<BranchDiv>
51+
{children.hash.propertyView({
52+
label: trans("eventHandler.hashParams"),
53+
layout: "vertical",
54+
})}
55+
</BranchDiv>
56+
<BranchDiv $type="switch">
57+
{children.inNewTab.propertyView({
58+
label: trans("eventHandler.openInNewTab"),
59+
layout: "vertical",
60+
})}
61+
</BranchDiv>
62+
</>
63+
);
1664
})
17-
.setPropertyViewFn((children) => {
18-
return (
19-
<>
20-
<BranchDiv>
21-
{children.url.propertyView({
22-
label: "URL",
23-
layout: "vertical",
24-
})}
25-
</BranchDiv>
26-
<BranchDiv $type="switch">
27-
{children.inNewTab.propertyView({
28-
label: trans("eventHandler.openInNewTab"),
29-
})}
30-
</BranchDiv>
31-
</>
32-
);
33-
})
34-
.build();
35-
})();
65+
.build();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /