@@ -9,7 +9,7 @@ import { getPromiseAfterDispatch } from "util/promiseUtils";
99import { trans } from "i18n" ;
1010import { withDefault } from "comps/generators" ;
1111import { keyValueListControl } from "comps/controls/keyValueListControl" ;
12- import { useCallback } from "react" ;
12+ import { useCallback , useEffect } from "react" ;
1313
1414const ExecuteQueryPropertyView = ( {
1515 comp,
@@ -19,16 +19,25 @@ const ExecuteQueryPropertyView = ({
1919 placement ?: "query" | "table"
2020} ) => {
2121 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+ } ) ;
2635 return {
27- label : info . name ,
28- value : info . name ,
29- variables : info . data . variables ,
36+ label : name ,
37+ value : name ,
38+ variables : qVariables ,
3039 }
31- } )
40+ } )
3241 . filter (
3342 // Filter out the current query under query
3443 ( option ) => {
@@ -67,7 +76,7 @@ const ExecuteQueryPropertyView = ({
6776 indicatorForAll : true ,
6877 } ) ;
6978 } , [ comp . children . queryVariables . getView ( ) ] )
70-
79+
7180 return (
7281 < >
7382 < BranchDiv $type = { "inline" } >
@@ -114,26 +123,27 @@ const ExecuteQueryTmpAction = (function () {
114123export class ExecuteQueryAction extends ExecuteQueryTmpAction {
115124 override getView ( ) {
116125 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 ;
124126 if ( ! queryName ) {
125127 return ( ) => Promise . resolve ( ) ;
126128 }
127129
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 (
130139 this . dispatch ,
131140 routeByNameAction (
132141 queryName ,
133142 executeQueryAction ( { args : result } )
134143 ) ,
135144 { notHandledError : trans ( "eventHandler.notHandledError" ) }
136145 ) ;
146+ }
137147 }
138148
139149 displayName ( ) {
0 commit comments