Movatterモバイル変換


[0]ホーム

URL:


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

Commit5e1cf9e

Browse files
committed
use overwritten variable in query request
1 parent845f9c1 commit5e1cf9e

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

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

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ import { JSONObject, JSONValue } from "../../util/jsonTypes";
6767
import{BoolPureControl}from"../controls/boolControl";
6868
import{millisecondsControl}from"../controls/millisecondControl";
6969
import{paramsMillisecondsControl}from"../controls/paramsControl";
70-
import{NameConfig,withExposingConfigs}from"../generators/withExposing";
70+
import{DepsConfig,NameConfig,withExposingConfigs}from"../generators/withExposing";
7171
import{HttpQuery}from"./httpQuery/httpQuery";
7272
import{StreamQuery}from"./httpQuery/streamQuery";
7373
import{QueryConfirmationModal}from"./queryComp/queryConfirmationModal";
@@ -135,7 +135,6 @@ const childrenMap = {
135135
data:stateComp<JSONValue>(null),
136136
extra:stateComp<JSONValue>({}),
137137
isFetching:stateComp<boolean>(false),
138-
variable:stateComp<JSONObject>({}),
139138
lastQueryStartTime:stateComp<number>(-1),// The last execution time of the query, in order to avoid multiple executions overwriting each other, not persistent
140139
latestEndTime:stateComp<number>(0),// The time when the query was last executed
141140
runTime:stateComp<number>(0),// query run time
@@ -364,14 +363,8 @@ QueryCompTmp = class extends QueryCompTmp {
364363
}
365364
if(action.type===CompActionTypes.EXECUTE_QUERY){
366365
if(getReduceContext().disableUpdateState)returnthis;
367-
letvariableVal={};
368-
if(action.args)variableVal=action.args;
369-
elsevariableVal=this.children.variables.children.variables.toJsonValue().reduce((acc,curr)=>Object.assign(acc,{[curr.keyasstring]:curr.value}),{});
370-
//Update query.variable
371-
constchangeValAction=this.children.variable.changeValueAction(variableVal);
372-
constchangeValAction2=this.changeChildAction("variable",variableVal)
373-
this.dispatch(changeValAction2);
374-
console.log("changed value: ",this.children.variable.toJsonValue());
366+
if(!action.args)action.args=this.children.variables.children.variables.toJsonValue().reduce((acc,curr)=>Object.assign(acc,{[curr.keyasstring]:curr.value}),{});
367+
375368
returnthis.executeQuery(action);
376369
}
377370
if(action.type===CompActionTypes.CHANGE_VALUE){
@@ -486,6 +479,7 @@ QueryCompTmp = class extends QueryCompTmp {
486479
applicationId:applicationId,
487480
applicationPath:parentApplicationPath,
488481
args:action.args,
482+
variables:action.args,
489483
timeout:this.children.timeout,
490484
callback:(result)=>this.processResult(result,action,startTime)
491485
});
@@ -669,7 +663,23 @@ export const QueryComp = withExposingConfigs(QueryCompTmp, [
669663
newNameConfig("isFetching",trans("query.isFetchingExportDesc")),
670664
newNameConfig("runTime",trans("query.runTimeExportDesc")),
671665
newNameConfig("latestEndTime",trans("query.latestEndTimeExportDesc")),
672-
newNameConfig("variable",trans("query.variables")),
666+
newDepsConfig(
667+
"variable",
668+
(children:any)=>{
669+
return{data:children.variables.children.variables.node()};
670+
},
671+
(input)=>{
672+
if(!input.data){
673+
returnundefined;
674+
}
675+
constnewNode=Object.values(input.data)
676+
.filter((kvNode:any)=>kvNode.key.text.value)
677+
.map((kvNode:any)=>({[kvNode.key.text.value]:kvNode.value.text.value}))
678+
.reduce((prev,obj)=>({...prev, ...obj}),{});
679+
returnnewNode;
680+
},
681+
trans("query.variables")
682+
),
673683
newNameConfig("triggerType",trans("query.triggerTypeExportDesc")),
674684
]);
675685

‎client/packages/lowcoder/src/comps/queries/queryCompUtils.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,23 @@ export function toQueryView(params: FunctionProperty[]) {
2525
applicationId:string;
2626
applicationPath:string[];
2727
args?:Record<string,unknown>;
28+
variables?:any;
2829
timeout:InstanceType<ParamsControlType>;
2930
}):Promise<QueryResult>=>{
3031
const{ applicationId, isViewMode}=getGlobalSettings();
3132

33+
constmappedVariables=Object.keys(props.variables).map(key=>({key:`query1.variable.${key}`,value:props.variables[key]}));
3234
letrequest:QueryExecuteRequest={
3335
path:props.applicationPath,
3436
params:[
35-
...params.map(({ key, value})=>({ key,value:value(props.args)})),
37+
...params.filter(param=>{
38+
return!mappedVariables.map(v=>v.key).includes(param.key);
39+
}).map(({ key, value})=>({ key,value:value(props.args)})),
3640
...Object.entries(props.timeout.getView()).map(([key,value])=>({
3741
key,
3842
value:value(props.args),
3943
})),
44+
...mappedVariables,
4045
],
4146
viewMode:!!isViewMode,
4247
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp