Skip to content

Commit 845f9c1

Browse files
committed
key to label on event handler popup
1 parent 8564f79 commit 845f9c1

File tree

3 files changed

+41
-14
lines changed

3 files changed

+41
-14
lines changed

client/packages/lowcoder-design/src/components/keyValueList.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export const KeyValueList = (props: {
7676
list: ReactNode[];
7777
onAdd: () => void;
7878
onDelete: (item: ReactNode, index: number) => void;
79+
isStatic?: boolean;
7980
}) => (
8081
<>
8182
{props.list.map((item, index) => (
@@ -87,9 +88,11 @@ export const KeyValueList = (props: {
8788
/>
8889
</KeyValueListItem>
8990
))}
91+
{!props.isStatic &&
9092
<AddBtn onClick={props.onAdd}>
9193
<AddIcon />
9294
{trans("addItem")}
9395
</AddBtn>
96+
}
9497
</>
9598
);

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

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,24 @@ export class ExecuteQueryAction extends ExecuteQueryTmpAction {
8989
});
9090
return options;
9191
};
92+
const getVariableOptions = (editorState?: EditorState) => {
93+
const options =
94+
editorState
95+
?.getQueriesComp()
96+
.getView()
97+
.filter(
98+
// Filter out the current query under query
99+
(option) => {
100+
return option.children.name.getView() === this.children.queryName.getView();
101+
}
102+
) || [];
103+
return this.children.query.propertyView({
104+
label: trans("eventHandler.queryParams"),
105+
layout: "vertical",
106+
isStatic: true,
107+
keyFixed: true,
108+
});
109+
}
92110
return (
93111
<>
94112
<BranchDiv $type={"inline"}>
@@ -107,10 +125,9 @@ export class ExecuteQueryAction extends ExecuteQueryTmpAction {
107125
</EditorContext.Consumer>
108126
</BranchDiv>
109127
<BranchDiv>
110-
{this.children.query.propertyView({
111-
label: trans("eventHandler.queryParams"),
112-
layout: "vertical",
113-
})}
128+
<EditorContext.Consumer>
129+
{(editorState) => getVariableOptions(editorState)}
130+
</EditorContext.Consumer>
114131
</BranchDiv>
115132
</>
116133
);

client/packages/lowcoder/src/comps/controls/keyValueControl.tsx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ export type KeyValueControlParams = ControlParams & {
4747
typeTooltip?: ReactNode;
4848
keyFlexBasics?: number;
4949
valueFlexBasics?: number;
50+
isStatic?: boolean;
51+
keyFixed?: boolean;
5052
};
5153

5254
/**
@@ -82,16 +84,20 @@ function keyValueControl<T extends OptionsType>(
8284
return (
8385
<KeyValueWrapper>
8486
<KeyWrapper $flexBasics={params.keyFlexBasics}>
85-
{this.children.key.propertyView({ placeholder: "key", indentWithTab: false })}
86-
{hasType && params.showType && (
87-
<TypeWrapper>
88-
{this.children.type.propertyView({
89-
placeholder: "key",
90-
indentWithTab: false,
91-
tooltip: params.typeTooltip,
92-
})}
93-
</TypeWrapper>
94-
)}
87+
{params.keyFixed?
88+
<>{this.children.key.getView()}</>
89+
:<>
90+
{this.children.key.propertyView({ placeholder: "key", indentWithTab: false })}
91+
{hasType && params.showType && (
92+
<TypeWrapper>
93+
{this.children.type.propertyView({
94+
placeholder: "key",
95+
indentWithTab: false,
96+
tooltip: params.typeTooltip,
97+
})}
98+
</TypeWrapper>
99+
)}
100+
</>}
95101
</KeyWrapper>
96102
<ValueWrapper $flexBasics={params.valueFlexBasics}>
97103
{this.children.value.propertyView({
@@ -136,6 +142,7 @@ export function keyValueListControl<T extends OptionsType>(
136142
list={this.getView().map((child) => child.propertyView(params))}
137143
onAdd={() => this.dispatch(this.pushAction({}))}
138144
onDelete={(item, index) => this.dispatch(this.deleteAction(index))}
145+
isStatic={params.isStatic}
139146
/>
140147
</ControlPropertyViewWrapper>
141148
);

0 commit comments

Comments
 (0)