Skip to content

Added variables to data query #1470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
key to label on event handler popup
  • Loading branch information
Imiss-U1025 committed Jan 27, 2025
commit 845f9c110f78bb06039028af9e79f683c6072166
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export const KeyValueList = (props: {
list: ReactNode[];
onAdd: () => void;
onDelete: (item: ReactNode, index: number) => void;
isStatic?: boolean;
}) => (
<>
{props.list.map((item, index) => (
Expand All @@ -87,9 +88,11 @@ export const KeyValueList = (props: {
/>
</KeyValueListItem>
))}
{!props.isStatic &&
<AddBtn onClick={props.onAdd}>
<AddIcon />
{trans("addItem")}
</AddBtn>
}
</>
);
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,24 @@ export class ExecuteQueryAction extends ExecuteQueryTmpAction {
});
return options;
};
const getVariableOptions = (editorState?: EditorState) => {
const options =
editorState
?.getQueriesComp()
.getView()
.filter(
// Filter out the current query under query
(option) => {
return option.children.name.getView() === this.children.queryName.getView();
}
) || [];
return this.children.query.propertyView({
label: trans("eventHandler.queryParams"),
layout: "vertical",
isStatic: true,
keyFixed: true,
});
}
return (
<>
<BranchDiv $type={"inline"}>
Expand All @@ -107,10 +125,9 @@ export class ExecuteQueryAction extends ExecuteQueryTmpAction {
</EditorContext.Consumer>
</BranchDiv>
<BranchDiv>
{this.children.query.propertyView({
label: trans("eventHandler.queryParams"),
layout: "vertical",
})}
<EditorContext.Consumer>
{(editorState) => getVariableOptions(editorState)}
</EditorContext.Consumer>
</BranchDiv>
</>
);
Expand Down
27 changes: 17 additions & 10 deletions client/packages/lowcoder/src/comps/controls/keyValueControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export type KeyValueControlParams = ControlParams & {
typeTooltip?: ReactNode;
keyFlexBasics?: number;
valueFlexBasics?: number;
isStatic?: boolean;
keyFixed?: boolean;
};

/**
Expand Down Expand Up @@ -82,16 +84,20 @@ function keyValueControl<T extends OptionsType>(
return (
<KeyValueWrapper>
<KeyWrapper $flexBasics={params.keyFlexBasics}>
{this.children.key.propertyView({ placeholder: "key", indentWithTab: false })}
{hasType && params.showType && (
<TypeWrapper>
{this.children.type.propertyView({
placeholder: "key",
indentWithTab: false,
tooltip: params.typeTooltip,
})}
</TypeWrapper>
)}
{params.keyFixed?
<>{this.children.key.getView()}</>
:<>
{this.children.key.propertyView({ placeholder: "key", indentWithTab: false })}
{hasType && params.showType && (
<TypeWrapper>
{this.children.type.propertyView({
placeholder: "key",
indentWithTab: false,
tooltip: params.typeTooltip,
})}
</TypeWrapper>
)}
</>}
</KeyWrapper>
<ValueWrapper $flexBasics={params.valueFlexBasics}>
{this.children.value.propertyView({
Expand Down Expand Up @@ -136,6 +142,7 @@ export function keyValueListControl<T extends OptionsType>(
list={this.getView().map((child) => child.propertyView(params))}
onAdd={() => this.dispatch(this.pushAction({}))}
onDelete={(item, index) => this.dispatch(this.deleteAction(index))}
isStatic={params.isStatic}
/>
</ControlPropertyViewWrapper>
);
Expand Down