@@ -9,7 +9,7 @@ import { getPromiseAfterDispatch } from "util/promiseUtils";
9
9
import { trans } from "i18n" ;
10
10
import { withDefault } from "comps/generators" ;
11
11
import { keyValueListControl } from "comps/controls/keyValueListControl" ;
12
- import { useCallback } from "react" ;
12
+ import { useCallback , useEffect } from "react" ;
13
13
14
14
const ExecuteQueryPropertyView = ( {
15
15
comp,
@@ -19,16 +19,25 @@ const ExecuteQueryPropertyView = ({
19
19
placement ?: "query" | "table"
20
20
} ) => {
21
21
const getQueryOptions = useCallback ( ( editorState ?: EditorState ) => {
22
- const options : { label : string ; value : string ; variables ?: Record < string , string > } [ ] =
23
- editorState
24
- ?. queryCompInfoList ( )
25
- . map ( ( info ) => {
22
+ if ( ! editorState ) return [ ] ;
23
+ const options : {
24
+ label : string ;
25
+ value : string ;
26
+ variables ?: Record < string , string >
27
+ } [ ] = editorState . getQueriesComp ( )
28
+ . getView ( )
29
+ . map ( ( item ) => {
30
+ const name = item . children . name . getView ( ) ;
31
+ const qVariables : Record < string , string > = { } ;
32
+ item . children . variables . toJsonValue ( ) . forEach ( v => {
33
+ qVariables [ v . key ! ] = '' ;
34
+ } ) ;
26
35
return {
27
- label : info . name ,
28
- value : info . name ,
29
- variables : info . data . variables ,
36
+ label : name ,
37
+ value : name ,
38
+ variables : qVariables ,
30
39
}
31
- } )
40
+ } )
32
41
. filter (
33
42
// Filter out the current query under query
34
43
( option ) => {
@@ -67,7 +76,7 @@ const ExecuteQueryPropertyView = ({
67
76
indicatorForAll : true ,
68
77
} ) ;
69
78
} , [ comp . children . queryVariables . getView ( ) ] )
70
-
79
+
71
80
return (
72
81
< >
73
82
< BranchDiv $type = { "inline" } >
@@ -114,26 +123,27 @@ const ExecuteQueryTmpAction = (function () {
114
123
export class ExecuteQueryAction extends ExecuteQueryTmpAction {
115
124
override getView ( ) {
116
125
const queryName = this . children . queryName . getView ( ) ;
117
- // const queryParams = keyValueListToSearchStr(Array.isArray(this?.children?.query) ? (this.children.query as unknown as any[]).map((i: any) => i.getView() as KeyValue) : []);
118
- const result = this . children . queryVariables . toJsonValue ( )
119
- . filter ( item => item . key !== "" && item . value !== "" )
120
- . map ( item => ( { [ item . key as string ] : item . value } ) )
121
- . reduce ( ( acc , curr ) => Object . assign ( acc , curr ) , { } ) ;
122
-
123
- result . $queryName = queryName ;
124
126
if ( ! queryName ) {
125
127
return ( ) => Promise . resolve ( ) ;
126
128
}
127
129
128
- return ( ) =>
129
- getPromiseAfterDispatch (
130
+ let result = Object . values ( this . children . queryVariables . getView ( ) )
131
+ . filter ( ( item ) => item . children . key . getView ( ) !== "" && item . children . value . getView ( ) !== "" )
132
+ . map ( ( item ) => ( { [ item . children . key . getView ( ) as string ] : { value : item . children . value . getView ( ) } } ) )
133
+ . reduce ( ( acc , curr ) => Object . assign ( acc , curr ) , { } ) ;
134
+
135
+ result . $queryName = { value : this . children . queryName . getView ( ) } ;
136
+
137
+ return ( ) => {
138
+ return getPromiseAfterDispatch (
130
139
this . dispatch ,
131
140
routeByNameAction (
132
141
queryName ,
133
142
executeQueryAction ( { args : result } )
134
143
) ,
135
144
{ notHandledError : trans ( "eventHandler.notHandledError" ) }
136
145
) ;
146
+ }
137
147
}
138
148
139
149
displayName ( ) {
0 commit comments