Skip to content

Commit 3ce6469

Browse files
committed
Change search method in query library.
1 parent e2c1efc commit 3ce6469

File tree

6 files changed

+47
-23
lines changed

6 files changed

+47
-23
lines changed

client/packages/lowcoder/src/pages/ApplicationV2/FolderView.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useDispatch, useSelector } from "react-redux";
22
import { useParams } from "react-router-dom";
33
import { HomeBreadcrumbType, HomeLayout } from "./HomeLayout";
4-
import { useEffect } from "react";
4+
import {useEffect, useState} from "react";
55
import { fetchFolderElements } from "../../redux/reduxActions/folderActions";
66
import { FolderMeta } from "../../constants/applicationConstants";
77
import { buildFolderUrl } from "../../constants/routesURL";
@@ -34,6 +34,7 @@ export function FolderView() {
3434
const { folderId } = useParams<{ folderId: string }>();
3535

3636
const dispatch = useDispatch();
37+
const [searchValue, setSearchValue] = useState("")
3738

3839
const elements = useSelector(folderElementsSelector);
3940
const allFolders = useSelector(foldersSelector);
@@ -55,7 +56,7 @@ export function FolderView() {
5556
return (
5657
<>
5758
<Helmet>{<title>{trans("home.yourFolders")}</title>}</Helmet>
58-
<HomeLayout elements={elements[folderId]} mode={"folder"} breadcrumb={breadcrumbs} />
59+
<HomeLayout elements={elements[folderId]} mode={"folder"} breadcrumb={breadcrumbs} setSearchValue={setSearchValue} searchValue={searchValue} />
5960
</>
6061
);
6162
}

client/packages/lowcoder/src/pages/ApplicationV2/HomeLayout.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ export interface HomeLayoutProps {
313313
currentPage?: number;
314314
pageSize?: number;
315315
total?: number;
316-
searchValues?: number;
317-
setSearchValues?: any;
316+
searchValue?: string;
317+
setSearchValue?: any;
318318
setTypeFilterPagination?: any;
319319
setModify?: any;
320320
modify?: boolean;
@@ -330,8 +330,8 @@ export function HomeLayout(props: HomeLayoutProps) {
330330
setPageSize,
331331
pageSize,
332332
currentPage,
333-
searchValues,
334-
setSearchValues,
333+
searchValue,
334+
setSearchValue,
335335
total,
336336
setTypeFilterPagination,
337337
setModify,
@@ -363,7 +363,6 @@ export function HomeLayout(props: HomeLayoutProps) {
363363
const isSelfHost = window.location.host !== 'app.lowcoder.cloud';
364364
const [typeFilter, setTypeFilter] = useState<HomeResKey>("All");
365365
const [categoryFilter, setCategoryFilter] = useState<ApplicationCategoriesEnum | "All">("All");
366-
const [searchValue, setSearchValue] = useState("");
367366
const [visibility, setVisibility] = useState(mode === "view" || mode === "trash");
368367
const [layout, setLayout] = useState<HomeLayoutType>(
369368
checkIsMobile(window.innerWidth) ? "card" : getHomeLayout()
@@ -566,9 +565,8 @@ export function HomeLayout(props: HomeLayoutProps) {
566565
<OperationRightWrapper>
567566
<Search
568567
placeholder={trans("search")}
569-
value={searchValue}
568+
value={searchValue || ""}
570569
onChange={(e) => setSearchValue(e.target.value)}
571-
onEnterPress={(value) => setSearchValues(value)}
572570
style={{ width: "192px", height: "32px", margin: "0" }}
573571
/>
574572
{mode !== "trash" && mode !== "marketplace" && user.orgDev && (

client/packages/lowcoder/src/pages/ApplicationV2/HomeView.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export function HomeView() {
1717
const [elements, setElements] = useState<ElementsState>({ elements: [], total: 1 });
1818
const [currentPage, setCurrentPage] = useState(1);
1919
const [pageSize, setPageSize] = useState(10);
20+
const [searchValue, setSearchValue] = useState("");
2021
const [searchValues, setSearchValues] = useState("");
2122
const [typeFilter, setTypeFilter] = useState<number>(0);
2223
const [modify, setModify] = useState(true);
@@ -26,7 +27,7 @@ export function HomeView() {
2627
pageNum:currentPage,
2728
pageSize:pageSize,
2829
applicationType: ApplicationPaginationType[typeFilter],
29-
name: searchValues,
30+
name: searchValue,
3031
}).then(
3132
data => {
3233
if (data.success) {
@@ -42,6 +43,13 @@ export function HomeView() {
4243
}, [currentPage, pageSize, searchValues, typeFilter, modify]
4344
);
4445

46+
useEffect(()=> {
47+
setTimeout(() => {
48+
if (searchValue.length > 2 || searchValue === "")
49+
setSearchValues(searchValue)
50+
}, 500);
51+
})
52+
4553
const user = useSelector(getUser);
4654

4755
if (!user.currentOrgId) {
@@ -59,7 +67,8 @@ export function HomeView() {
5967
pageSize={pageSize}
6068
setPageSize={setPageSize}
6169
total={elements.total}
62-
setSearchValues={setSearchValues}
70+
setSearchValue={setSearchValue}
71+
searchValue={searchValue}
6372
setTypeFilterPagination={setTypeFilter}
6473
setModify={setModify}
6574
modify={modify}

client/packages/lowcoder/src/pages/ApplicationV2/TrashView.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ export function TrashView() {
1515
const [currentPage, setCurrentPage] = useState(1);
1616
const [pageSize, setPageSize] = useState(10);
1717
const [searchValues, setSearchValues] = useState("");
18+
const [searchValue, setSearchValue] = useState("");
1819
const [typeFilter, setTypeFilter] = useState<number>(0);
1920

20-
useEffect( () => {
21+
useEffect( () => {
2122
if (typeFilter === 7) // Application of Navigation is 3 in API.
2223
setTypeFilter(3);
2324
try{
@@ -41,6 +42,13 @@ export function TrashView() {
4142
}, [currentPage, pageSize, searchValues, typeFilter]
4243
);
4344

45+
useEffect(()=> {
46+
setTimeout(() => {
47+
if (searchValue.length > 2 || searchValue === "")
48+
setSearchValues(searchValue)
49+
}, 500);
50+
})
51+
4452
return (
4553
<>
4654
<Helmet>{<title>{trans("home.trash")}</title>}</Helmet>
@@ -53,9 +61,11 @@ export function TrashView() {
5361
pageSize={pageSize}
5462
setPageSize={setPageSize}
5563
total={elements.total}
56-
setSearchValues={setSearchValues}
64+
setSearchValue={setSearchValue}
65+
searchValue={searchValue}
5766
setTypeFilterPagination={setTypeFilter}
5867
/>
5968
</>
6069
);
6170
}
71+

client/packages/lowcoder/src/pages/queryLibrary/LeftNav.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from "react";
1+
import {useEffect, useState} from "react";
22
import styled, { css } from "styled-components";
33
import {
44
BluePlusIcon,
@@ -164,12 +164,21 @@ export const LeftNav = (props: {
164164
currentPage: number;
165165
pageSize: number;
166166
total: number;
167+
setSearchValues: any;
168+
searchValues: string;
167169
}) => {
168-
const {currentPage, setCurrentPage, pageSize, setPageSize, total } = props
170+
const {currentPage, setCurrentPage, pageSize, setPageSize, total , setSearchValues, searchValues} = props
169171
const dispatch = useDispatch();
170172
const [searchValue, setSearchValue] = useState("");
171173
const datasourceTypes = useSelector(getDataSourceTypesMap);
172174

175+
useEffect(()=> {
176+
setTimeout(() => {
177+
if (searchValue.length > 2 || searchValue === "")
178+
setSearchValues(searchValue)
179+
}, 500);
180+
})
181+
173182
return (
174183
<ReadOnlyMask readOnly={!!props.readOnly}>
175184
<Wrapper $readOnly={props.readOnly}>
@@ -196,12 +205,6 @@ export const LeftNav = (props: {
196205
let datasourceTypeName =
197206
datasourceTypes[q.libraryQueryDSL?.query?.compType as DatasourceType]?.name ??
198207
"";
199-
if (searchValue) {
200-
return (
201-
q.name.toLowerCase().includes(searchValue) ||
202-
datasourceTypeName.toLowerCase().includes(searchValue)
203-
);
204-
}
205208
return true;
206209
})
207210
.map((q) => (

client/packages/lowcoder/src/pages/queryLibrary/QueryLibraryEditor.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export const QueryLibraryEditor = () => {
9191
const [queryLibrary, setQueryLibrary] = useState<any>({});
9292
const [currentPage, setCurrentPage] = useState(1);
9393
const [pageSize, setPageSize] = useState(10);
94+
const [searchValues, setSearchValues] = useState("")
9495

9596
const selectedRecords = queryLibraryRecords[selectedQuery] ?? {};
9697
const libraryQuery = queryLibrary[selectedQuery];
@@ -119,7 +120,7 @@ export const QueryLibraryEditor = () => {
119120
try {
120121
fetchQLPaginationByOrg(
121122
{
122-
name: "",
123+
name: searchValues,
123124
pageNum: currentPage,
124125
pageSize: pageSize,
125126
}
@@ -132,7 +133,7 @@ export const QueryLibraryEditor = () => {
132133
} catch (error) {
133134
console.error(error)
134135
}
135-
}, [currentPage, pageSize])
136+
}, [currentPage, pageSize, searchValues, setSearchValues])
136137

137138
useEffect(() => {
138139
if (orgId) {
@@ -231,6 +232,8 @@ export const QueryLibraryEditor = () => {
231232
currentPage={currentPage}
232233
pageSize={pageSize}
233234
total={elements.total}
235+
setSearchValues={setSearchValues}
236+
searchValues={searchValues}
234237
/>
235238
<RightContent>
236239
{!selectedQuery || !comp?.children.query.children.id.getView() ? (

0 commit comments

Comments
 (0)