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

Commitdf23d09

Browse files
committed
[FEAT]:#1488 Add JS Query in Query Library
1 parent233c56a commitdf23d09

File tree

4 files changed

+34
-16
lines changed

4 files changed

+34
-16
lines changed

‎client/packages/lowcoder/src/components/ResCreatePanel.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { getUser } from "../redux/selectors/usersSelectors";
2525
importDataSourceIconfrom"./DataSourceIcon";
2626
import{genRandomKey}from"comps/utils/idGenerator";
2727
import{isPublicApplication}from"@lowcoder-ee/redux/selectors/applicationSelector";
28+
import{JS_CODE_ID}from"constants/datasourceConstants";
2829

2930
constWrapper=styled.div<{$placement:PageType}>`
3031
width: 100%;
@@ -145,6 +146,7 @@ const ResButton = (props: {
145146
type:BottomResTypeEnum.Query,
146147
extra:{
147148
compType:"js",
149+
dataSourceId:JS_CODE_ID,
148150
},
149151
},
150152
libraryQuery:{
@@ -320,6 +322,17 @@ export function ResCreatePanel(props: ResCreateModalProps) {
320322
</div>
321323
</>
322324
)}
325+
326+
{placement==="queryLibrary"&&(
327+
<>
328+
<divclassName="section-title">{trans("code")}</div>
329+
<divclassName="section">
330+
<DataSourceListWrapper$placement={placement}>
331+
<ResButtonsize={buttonSize}identifier={"js"}onSelect={onSelect}/>
332+
</DataSourceListWrapper>
333+
</div>
334+
</>
335+
)}
323336

324337
<divclassName="section-title">{trans("query.datasource")}</div>
325338
<divclassName="section">

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { isCompWithPropertyView } from "comps/utils/propertyUtils";
55
import{
66
QUICK_GRAPHQL_ID,
77
QUICK_REST_API_ID,
8+
JS_CODE_ID
89
}from"constants/datasourceConstants";
910
import{PageType}from"constants/pageConstants";
1011
import{trans}from"i18n";
@@ -795,7 +796,8 @@ function useDatasourceStatus(datasourceId: string, datasourceType: ResourceType)
795796
datasourceType==="libraryQuery"||
796797
datasourceType==="alasql"||
797798
datasourceId===QUICK_REST_API_ID||
798-
datasourceId===QUICK_GRAPHQL_ID
799+
datasourceId===QUICK_GRAPHQL_ID||
800+
datasourceId===JS_CODE_ID
799801
){
800802
return"";
801803
}

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

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { DatasourceType, ResourceType } from "@lowcoder-ee/constants/queryConsta
1515
import{
1616
QUICK_GRAPHQL_ID,
1717
QUICK_REST_API_ID,
18+
JS_CODE_ID
1819
}from"constants/datasourceConstants";
1920
import{
2021
apiPluginsForQueryLibrary,
@@ -78,7 +79,7 @@ interface ResourceOptionValue {
7879
}
7980

8081
constJSOptionValue:ResourceOptionValue={
81-
id:"",
82+
id:JS_CODE_ID,
8283
type:"js",
8384
};
8485

@@ -156,6 +157,7 @@ export const ResourceDropdown = (props: ResourceDropdownProps) => {
156157
constoptionValue:ResourceOptionValue=JSON.parse(value);
157158
constdatasourceId=optionValue.id;
158159
constdatasourceType=optionValue.type;
160+
159161
if(!datasourceType){
160162
messageInstance.error("datasource invalid");
161163
return;
@@ -293,19 +295,20 @@ export const ResourceDropdown = (props: ResourceDropdownProps) => {
293295
</SelectOptionContains>
294296
</SelectOption>
295297

296-
{context?.placement!=="queryLibrary"&&(
297-
<>
298-
<SelectOption
299-
key={JSON.stringify(JSOptionValue)}
300-
label={trans("query.executeJSCode")}
301-
value={JSON.stringify(JSOptionValue)}
302-
>
303-
<SelectOptionContains>
304-
{getBottomResIcon("js")}
305-
<SelectOptionLabel>{trans("query.executeJSCode")}</SelectOptionLabel>
306-
</SelectOptionContains>
307-
</SelectOption>
298+
{/* Always show JS option regardless of placement */}
299+
<SelectOption
300+
key={JSON.stringify(JSOptionValue)}
301+
label={trans("query.executeJSCode")}
302+
value={JSON.stringify(JSOptionValue)}
303+
>
304+
<SelectOptionContains>
305+
{getBottomResIcon("js")}
306+
<SelectOptionLabel>{trans("query.executeJSCode")}</SelectOptionLabel>
307+
</SelectOptionContains>
308+
</SelectOption>
308309

310+
{/* Only show Library Query option when not in Query Library */}
311+
{context?.placement!=="queryLibrary"&&(
309312
<SelectOption
310313
key={JSON.stringify(LibraryQueryOptionValue)}
311314
label={trans("query.importFromQueryLibrary")}
@@ -316,8 +319,7 @@ export const ResourceDropdown = (props: ResourceDropdownProps) => {
316319
<SelectOptionLabel>{trans("query.importFromQueryLibrary")}</SelectOptionLabel>
317320
</SelectOptionContains>
318321
</SelectOption>
319-
</>
320-
)}
322+
)}
321323
</CustomSelect>
322324
</SelectWrapper>
323325
);

‎client/packages/lowcoder/src/constants/datasourceConstants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ export interface Datasource {
4343

4444
exportconstQUICK_REST_API_ID="#QUICK_REST_API";
4545
exportconstQUICK_GRAPHQL_ID="#QUICK_GRAPHQL";
46+
exportconstJS_CODE_ID="#JS_CODE";
4647
exportconstOLD_LOWCODER_DATASOURCE:Partial<DatasourceType>[]=[];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp