Content-Length: 4896 | pFad | http://github.com/lowcoder-org/lowcoder/pull/1516.diff
thub.com
diff --git a/client/packages/lowcoder/src/comps/controls/actionSelector/executeQueryAction.tsx b/client/packages/lowcoder/src/comps/controls/actionSelector/executeQueryAction.tsx
index 4de200bda..5febe82ff 100644
--- a/client/packages/lowcoder/src/comps/controls/actionSelector/executeQueryAction.tsx
+++ b/client/packages/lowcoder/src/comps/controls/actionSelector/executeQueryAction.tsx
@@ -112,14 +112,12 @@ export class ExecuteQueryAction extends ExecuteQueryTmpAction {
override getView() {
const queryName = this.children.queryName.getView();
// const queryParams = keyValueListToSearchStr(Array.isArray(this?.children?.query) ? (this.children.query as unknown as any[]).map((i: any) => i.getView() as KeyValue) : []);
- const result = Object.values(this.children.queryVariables.children as Record)
- .filter(item => item.children.key.unevaledValue !== "" && item.children.value.unevaledValue !== "")
- .map(item => ({[item.children.key.unevaledValue]: item.children.value.unevaledValue}))
+ const result = this.children.queryVariables.toJsonValue()
+ .filter(item => item.key !== "" && item.value !== "")
+ .map(item => ({[item.key as string]: item.value}))
.reduce((acc, curr) => Object.assign(acc, curr), {});
+
+ result.$queryName = queryName;
if (!queryName) {
return () => Promise.resolve();
}
diff --git a/client/packages/lowcoder/src/comps/queries/queryComp.tsx b/client/packages/lowcoder/src/comps/queries/queryComp.tsx
index 92a33e7b6..066b351fe 100644
--- a/client/packages/lowcoder/src/comps/queries/queryComp.tsx
+++ b/client/packages/lowcoder/src/comps/queries/queryComp.tsx
@@ -364,6 +364,7 @@ QueryCompTmp = class extends QueryCompTmp {
if (action.type === CompActionTypes.EXECUTE_QUERY) {
if (getReduceContext().disableUpdateState) return this;
if(!action.args) action.args = this.children.variables.children.variables.toJsonValue().reduce((acc, curr) => Object.assign(acc, {[curr.key as string]:curr.value}), {});
+ action.args.$queryName = this.children.name.getView();
return this.executeQuery(action);
}
@@ -673,8 +674,8 @@ export const QueryComp = withExposingConfigs(QueryCompTmp, [
return undefined;
}
const newNode = Object.values(input.data)
- .filter((kvNode: any) => kvNode.key.value)
- .map((kvNode: any) => ({[kvNode.key.value]: kvNode.value.value}))
+ .filter((kvNode: any) => kvNode.key)
+ .map((kvNode: any) => ({[kvNode.key]: kvNode.value}))
.reduce((prev, obj) => ({...prev, ...obj}), {});
return newNode;
},
@@ -773,12 +774,24 @@ class QueryListComp extends QueryListTmpComp implements BottomResListComp {
if (!origenQuery) {
return;
}
+
+ const jsonData = origenQuery.toJsonValue();
+ //Regenerate variable header
+ jsonData.variables?.variables?.forEach(kv => {
+ const [prefix, _] = (kv.key as string).split(/(?=\d+$)/);
+ let i=1, newName = "";
+ do {
+ newName = prefix + (i++);
+ } while(editorState.checkRename("", newName));
+ kv.key = newName;
+ })
+
const newQueryName = this.genNewName(editorState);
const id = genQueryId();
this.dispatch(
wrapActionExtraInfo(
this.pushAction({
- ...origenQuery.toJsonValue(),
+ ...jsonData,
id: id,
name: newQueryName,
isNewCreate: true,
@@ -789,7 +802,7 @@ class QueryListComp extends QueryListTmpComp implements BottomResListComp {
{
type: "add",
compName: name,
- compType: origenQuery.children.compType.getView(),
+ compType: jsonData.compType,
},
],
}
diff --git a/client/packages/lowcoder/src/comps/queries/queryCompUtils.tsx b/client/packages/lowcoder/src/comps/queries/queryCompUtils.tsx
index 1203e1cfd..d319689e7 100644
--- a/client/packages/lowcoder/src/comps/queries/queryCompUtils.tsx
+++ b/client/packages/lowcoder/src/comps/queries/queryCompUtils.tsx
@@ -28,9 +28,10 @@ export function toQueryView(params: FunctionProperty[]) {
variables?: any;
timeout: InstanceType;
}): Promise => {
+ console.log("toQueryView props", props, params);
const { applicationId, isViewMode } = getGlobalSettings();
- const mappedVariables = Object.keys(props.variables).map(key => ({key: `query1.variable.${key}`, value: props.variables[key]}));
+ const mappedVariables = Object.keys(props.variables).map(key => ({key: `${props.args?.$queryName}.variables.${key}`, value: props.variables[key]}));
let request: QueryExecuteRequest = {
path: props.applicationPath,
params: [
--- a PPN by Garber Painting Akron. With Image Size Reduction included!Fetched URL: http://github.com/lowcoder-org/lowcoder/pull/1516.diff
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy