Skip to content

Commit edcf8b1

Browse files
committed
Added Category filter.
1 parent 692d6fd commit edcf8b1

File tree

4 files changed

+39
-24
lines changed

4 files changed

+39
-24
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useDispatch, useSelector } from "react-redux";
22
import { useParams } from "react-router-dom";
33
import { HomeBreadcrumbType, HomeLayout } from "./HomeLayout";
44
import {useEffect, useState} from "react";
5-
import {ApplicationMeta, FolderMeta} from "../../constants/applicationConstants";
5+
import {ApplicationCategoriesEnum, ApplicationMeta, FolderMeta} from "../../constants/applicationConstants";
66
import { buildFolderUrl } from "../../constants/routesURL";
77
import { folderElementsSelector, foldersSelector } from "../../redux/selectors/folderSelector";
88
import { Helmet } from "react-helmet";
@@ -46,6 +46,7 @@ export function FolderView() {
4646
const [typeFilter, setTypeFilter] = useState<number>(0);
4747
const [modify, setModify] = useState(true);
4848
const [searchValue, setSearchValue] = useState("");
49+
const [categoryFilter, setCategoryFilter] = useState<ApplicationCategoriesEnum | "All">("All");
4950

5051
const dispatch = useDispatch();
5152

@@ -68,6 +69,7 @@ export function FolderView() {
6869
pageSize:pageSize,
6970
applicationType: ApplicationPaginationType[typeFilter],
7071
name: searchValues,
72+
category: categoryFilter
7173
}).then(
7274
(data: any) => {
7375
if (data.success) {
@@ -80,7 +82,7 @@ export function FolderView() {
8082
} catch (error) {
8183
console.error('Failed to fetch data:', error);
8284
}
83-
}, [currentPage, pageSize, searchValues, typeFilter, modify]);
85+
}, [currentPage, pageSize, searchValues, typeFilter, modify, categoryFilter]);
8486

8587
useEffect( () => {
8688
if (searchValues !== "")
@@ -113,6 +115,7 @@ export function FolderView() {
113115
setTypeFilterPagination={setTypeFilter}
114116
setModify={setModify}
115117
modify={modify}
118+
setCategoryFilterPagination={setCategoryFilter}
116119
/>
117120
</>
118121
);

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ export interface HomeLayoutProps {
316316
searchValue?: string;
317317
setSearchValue?: any;
318318
setTypeFilterPagination?: any;
319+
setCategoryFilterPagination?: any;
319320
setModify?: any;
320321
modify?: boolean;
321322
}
@@ -334,6 +335,7 @@ export function HomeLayout(props: HomeLayoutProps) {
334335
setSearchValue,
335336
total,
336337
setTypeFilterPagination,
338+
setCategoryFilterPagination,
337339
setModify,
338340
modify
339341

@@ -551,12 +553,17 @@ export function HomeLayout(props: HomeLayoutProps) {
551553
getPopupContainer={(node: any) => node}
552554
suffixIcon={<ArrowSolidIcon />} />
553555
)}
554-
{mode === "view" &&
556+
{(mode === "view" || mode === "folder") &&
555557
<FilterDropdown
556558
style={{ minWidth: "220px" }}
557559
variant="borderless"
558560
value={categoryFilter}
559-
onChange={(value: any) => setCategoryFilter(value as ApplicationCategoriesEnum)}
561+
onChange={(value: any) => {
562+
setCategoryFilter(value as ApplicationCategoriesEnum)
563+
setCategoryFilterPagination(value as ApplicationCategoriesEnum);
564+
}
565+
566+
}
560567
options={categoryOptions}
561568
// getPopupContainer={(node) => node}
562569
suffixIcon={<ArrowSolidIcon />}

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

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Helmet } from "react-helmet";
55
import { trans } from "i18n";
66
import {useState, useEffect } from "react";
77
import {fetchFolderElements} from "@lowcoder-ee/util/pagination/axios";
8-
import {ApplicationMeta, FolderMeta} from "@lowcoder-ee/constants/applicationConstants";
8+
import {ApplicationCategoriesEnum, ApplicationMeta, FolderMeta} from "@lowcoder-ee/constants/applicationConstants";
99
import {ApplicationPaginationType} from "@lowcoder-ee/util/pagination/type";
1010

1111
interface ElementsState {
@@ -21,26 +21,29 @@ export function HomeView() {
2121
const [searchValues, setSearchValues] = useState("");
2222
const [typeFilter, setTypeFilter] = useState<number>(0);
2323
const [modify, setModify] = useState(true);
24+
const [categoryFilter, setCategoryFilter] = useState<ApplicationCategoriesEnum | "All">("All");
25+
2426
useEffect( () => {
25-
try{
26-
fetchFolderElements({
27-
pageNum:currentPage,
28-
pageSize:pageSize,
29-
applicationType: ApplicationPaginationType[typeFilter],
30-
name: searchValues,
31-
}).then(
32-
(data: any) => {
33-
if (data.success) {
34-
setElements({elements: data.data || [], total: data.total || 1})
35-
}
36-
else
37-
console.error("ERROR: fetchFolderElements", data.error)
38-
}
39-
);
40-
} catch (error) {
41-
console.error('Failed to fetch data:', error);
42-
}
43-
}, [currentPage, pageSize, searchValues, typeFilter, modify]
27+
try{
28+
fetchFolderElements({
29+
pageNum:currentPage,
30+
pageSize:pageSize,
31+
applicationType: ApplicationPaginationType[typeFilter],
32+
name: searchValues,
33+
category: categoryFilter
34+
}).then(
35+
(data: any) => {
36+
if (data.success) {
37+
setElements({elements: data.data || [], total: data.total || 1})
38+
}
39+
else
40+
console.error("ERROR: fetchFolderElements", data.error)
41+
}
42+
);
43+
} catch (error) {
44+
console.error('Failed to fetch data:', error);
45+
}
46+
}, [currentPage, pageSize, searchValues, typeFilter, modify, categoryFilter]
4447
);
4548

4649
useEffect( () => {
@@ -79,6 +82,7 @@ export function HomeView() {
7982
setTypeFilterPagination={setTypeFilter}
8083
setModify={setModify}
8184
modify={modify}
85+
setCategoryFilterPagination={setCategoryFilter}
8286
/>
8387
</>
8488
);

client/packages/lowcoder/src/util/pagination/type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export interface fetchFolderRequestType {
6161
pageSize?: number;
6262
name?: string;
6363
applicationType?: string;
64+
category?: string
6465
}
6566

6667
export interface fetchDBRequestType {

0 commit comments

Comments
 (0)