Skip to content

Commit

Permalink
Added onInputChange, onQueryExecution and onTimeout triggers on JS/St…
Browse files Browse the repository at this point in the history
…ream queries
  • Loading branch information
raheeliftikhar5 committed Jan 14, 2025
1 parent ed12206 commit 9ce2172
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
21 changes: 13 additions & 8 deletions client/packages/lowcoder/src/comps/queries/queryComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,21 @@ interface AfterExecuteQueryAction {
result: QueryResult;
}

const CommonTriggerOptions = [
{ label: trans("query.triggerTypeInputChange"), value: "onInputChange"},
{ label: trans("query.triggerTypeQueryExec"), value: "onQueryExecution"},
{ label: trans("query.triggerTypeTimeout"), value: "onTimeout"},
]

export const TriggerTypeOptions = [
{ label: "On Page Load", value: "onPageLoad"},
{ label: "On Input Change", value: "onInputChange"},
{ label: "On Query Execution", value: "onQueryExecution"},
{ label: "On Timeout", value: "onTimeout"},
{ label: trans("query.triggerTypePageLoad"), value: "onPageLoad"},
...CommonTriggerOptions,
{ label: trans("query.triggerTypeAuto"), value: "automatic" },
{ label: trans("query.triggerTypeManual"), value: "manual" },
] as const;

export const JSTriggerTypeOptions = [
...CommonTriggerOptions,
{ label: trans("query.triggerTypePageLoad"), value: "automatic" },
{ label: trans("query.triggerTypeManual"), value: "manual" },
];
Expand Down Expand Up @@ -244,13 +249,13 @@ QueryCompTmp = class extends QueryCompTmp {
const isInputChangeTrigger = getTriggerType(this) === "onInputChange";

if (
action.type === CompActionTypes.UPDATE_NODES_V2 &&
(
action.type === CompActionTypes.UPDATE_NODES_V2
&& (
isAutomatic
|| isInputChangeTrigger
|| (isPageLoadTrigger && notExecuted)
) &&
(!isJsQuery || (isJsQuery && notExecuted)) // query which has deps can be executed on page load(first time)
)
// && (!isJsQuery || (isJsQuery && notExecuted)) // query which has deps can be executed on page load(first time)
) {
const next = super.reduce(action);
const depends = this.children.comp.node()?.dependValues();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,8 @@ export const QueryGeneralPropertyView = (props: {
{children.triggerType.getView() === 'onTimeout' && (
<TriggerTypeStyled>
{children.delayTime.propertyView({
label: trans("query.timeout"),
label: trans("query.delayTime"),
placeholder: "5s",
tooltip: trans("query.timeoutTooltip", { maxSeconds: 3600, defaultSeconds: 5 }),
placement: "bottom",
})}
</TriggerTypeStyled>
Expand Down
4 changes: 4 additions & 0 deletions client/packages/lowcoder/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,10 @@ export const en = {
"triggerTypeAuto": "Inputs Change or On Page Load",
"triggerTypePageLoad": "When the Application (Page) loads",
"triggerTypeManual": "Only when you trigger it manually",
"triggerTypeInputChange": "When Inputs Change",
"triggerTypeQueryExec": "After Query Execution",
"triggerTypeTimeout": "After the Timeout Interval",
"delayTime": "Delay Time",
"chooseDataSource": "Choose Data Source",
"method": "Method",
"updateExceptionDataSourceTitle": "Update Failing Data Source",
Expand Down

0 comments on commit 9ce2172

Please sign in to comment.