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

Commitfb3a52c

Browse files
added onQueryExecution trigger in query
1 parente71bd32 commitfb3a52c

File tree

2 files changed

+79
-23
lines changed

2 files changed

+79
-23
lines changed

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ import { HttpQuery } from "./httpQuery/httpQuery";
7272
import{StreamQuery}from"./httpQuery/streamQuery";
7373
import{QueryConfirmationModal}from"./queryComp/queryConfirmationModal";
7474
import{QueryNotificationControl}from"./queryComp/queryNotificationControl";
75-
import{QueryPropertyView}from"./queryComp/queryPropertyView";
75+
import{findDependentQueries,QueryPropertyView}from"./queryComp/queryPropertyView";
7676
import{getTriggerType,onlyManualTrigger}from"./queryCompUtils";
7777
import{messageInstance}from"lowcoder-design/src/components/GlobalInstances";
7878

@@ -100,6 +100,7 @@ interface AfterExecuteQueryAction {
100100
exportconstTriggerTypeOptions=[
101101
{label:"On Page Load",value:"onPageLoad"},
102102
{label:"On Input Change",value:"onInputChange"},
103+
{label:"On Query Execution",value:"onQueryExecution"},
103104
{label:trans("query.triggerTypeAuto"),value:"automatic"},
104105
{label:trans("query.triggerTypeManual"),value:"manual"},
105106
]asconst;
@@ -159,6 +160,7 @@ const childrenMap = {
159160
},
160161
}),
161162
cancelPrevious:withDefault(BoolPureControl,false),
163+
depQueryName:SimpleNameComp,
162164
};
163165

164166
letQueryCompTmp=withTypeAndChildren<typeofQueryMap,ToInstanceType<typeofchildrenMap>>(
@@ -639,6 +641,29 @@ export const QueryComp = withExposingConfigs(QueryCompTmp, [
639641
constQueryListTmpComp=list(QueryComp);
640642

641643
classQueryListCompextendsQueryListTmpCompimplementsBottomResListComp{
644+
overridereduce(action:CompAction): this{
645+
if(isCustomAction<AfterExecuteQueryAction>(action,"afterExecQuery")){
646+
if(action.path?.length===1&&!isNaN(parseInt(action.path[0]))){
647+
constqueryIdx=parseInt(action.path[0]);
648+
constqueryComps=this.getView();
649+
constqueryName=queryComps?.[queryIdx]?.children.name.getView();
650+
constdependentQueries=queryComps.filter((query,idx)=>{
651+
if(queryIdx===idx)returnfalse;
652+
if(
653+
getTriggerType(query)==='onQueryExecution'
654+
&&query.children.depQueryName.getView()===queryName
655+
){
656+
returntrue;
657+
}
658+
})
659+
dependentQueries?.forEach((query)=>{
660+
query.dispatch(deferAction(executeQueryAction({})));
661+
})
662+
}
663+
}
664+
returnsuper.reduce(action);
665+
}
666+
642667
nameAndExposingInfo():NameAndExposingInfo{
643668
constresult:NameAndExposingInfo={};
644669
Object.values(this.children).forEach((comp)=>{

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

Lines changed: 53 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import styled from "styled-components";
3737
import{DataSourceButton}from"pages/datasource/pluginPanel";
3838
import{Tooltip,Divider}from"antd";
3939
import{uiCompRegistry}from"comps/uiCompRegistry";
40+
import{InputTypeEnum}from"@lowcoder-ee/comps/comps/moduleContainerComp/ioComp/inputListItemComp";
4041

4142
constWrapper=styled.div`
4243
width: 100%;
@@ -233,6 +234,35 @@ export const QueryGeneralPropertyView = (props: {
233234
returnTriggerTypeOptions;
234235
},[datasourceType]);
235236

237+
constgetQueryOptions=useMemo(()=>{
238+
constoptions:{label:string;value:string}[]=
239+
editorState
240+
?.queryCompInfoList()
241+
.map((info)=>({
242+
label:info.name,
243+
value:info.name,
244+
}))
245+
.filter((option)=>{
246+
// Filter out the current query under query
247+
if(editorState.selectedBottomResType===BottomResTypeEnum.Query){
248+
returnoption.value!==editorState.selectedBottomResName;
249+
}
250+
returntrue;
251+
})||[];
252+
253+
// input queries
254+
editorState
255+
?.getModuleLayoutComp()
256+
?.getInputs()
257+
.forEach((i)=>{
258+
const{ name, type}=i.getView();
259+
if(type===InputTypeEnum.Query){
260+
options.push({label:name,value:name});
261+
}
262+
});
263+
returnoptions;
264+
},[editorState]);
265+
236266
return(
237267
<QueryPropertyViewWrapper>
238268
<QuerySectionWrapper>
@@ -336,28 +366,29 @@ export const QueryGeneralPropertyView = (props: {
336366
</QueryConfigWrapper>
337367

338368
{placement==="editor"&&(
339-
<TriggerTypeStyled>
340-
<Dropdown
341-
placement={"bottom"}
342-
label={trans("query.triggerType")}
343-
options={triggerOptions
344-
// [
345-
// { label: "On Page Load", value: "onPageLoad"},
346-
// { label: "On Input Change", value: "onInputChange"},
347-
// {
348-
// label:
349-
// (children.compType.getView() === "js" || children.compType.getView() === "streamApi")
350-
// ? trans("query.triggerTypePageLoad")
351-
// : trans("query.triggerTypeAuto"),
352-
// value: "automatic",
353-
// },
354-
// { label: trans("query.triggerTypeManual"), value: "manual" },
355-
// ] as const
356-
}
357-
value={children.triggerType.getView()}
358-
onChange={(value)=>children.triggerType.dispatchChangeValueAction(valueasTriggerType)}
359-
/>
360-
</TriggerTypeStyled>
369+
<>
370+
<TriggerTypeStyled>
371+
<Dropdown
372+
placement={"bottom"}
373+
label={trans("query.triggerType")}
374+
options={triggerOptions}
375+
value={children.triggerType.getView()}
376+
onChange={(value)=>children.triggerType.dispatchChangeValueAction(valueasTriggerType)}
377+
/>
378+
</TriggerTypeStyled>
379+
{children.triggerType.getView()==='onQueryExecution'&&(
380+
<TriggerTypeStyled>
381+
<Dropdown
382+
showSearch={true}
383+
placement={"bottom"}
384+
value={children.depQueryName.getView()}
385+
options={getQueryOptions}
386+
label={trans("eventHandler.selectQuery")}
387+
onChange={(value)=>children.depQueryName.dispatchChangeValueAction(value)}
388+
/>
389+
</TriggerTypeStyled>
390+
)}
391+
</>
361392
)}
362393
</QuerySectionWrapper>
363394

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp