Skip to content

Feature pagination #1374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added Category filter.
  • Loading branch information
Imiss-U1025 committed Dec 4, 2024
commit 2bb87ac35855fedd782ea8b9e54c15d111345e20
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useDispatch, useSelector } from "react-redux";
import { useParams } from "react-router-dom";
import { HomeBreadcrumbType, HomeLayout } from "./HomeLayout";
import {useEffect, useState} from "react";
import {ApplicationMeta, FolderMeta} from "../../constants/applicationConstants";
import {ApplicationCategoriesEnum, ApplicationMeta, FolderMeta} from "../../constants/applicationConstants";
import { buildFolderUrl } from "../../constants/routesURL";
import { folderElementsSelector, foldersSelector } from "../../redux/selectors/folderSelector";
import { Helmet } from "react-helmet";
Expand Down Expand Up @@ -46,6 +46,7 @@ export function FolderView() {
const [typeFilter, setTypeFilter] = useState<number>(0);
const [modify, setModify] = useState(true);
const [searchValue, setSearchValue] = useState("");
const [categoryFilter, setCategoryFilter] = useState<ApplicationCategoriesEnum | "All">("All");

const dispatch = useDispatch();

Expand All @@ -68,6 +69,7 @@ export function FolderView() {
pageSize:pageSize,
applicationType: ApplicationPaginationType[typeFilter],
name: searchValues,
category: categoryFilter
}).then(
(data: any) => {
if (data.success) {
Expand All @@ -80,7 +82,7 @@ export function FolderView() {
} catch (error) {
console.error('Failed to fetch data:', error);
}
}, [currentPage, pageSize, searchValues, typeFilter, modify]);
}, [currentPage, pageSize, searchValues, typeFilter, modify, categoryFilter]);

useEffect( () => {
if (searchValues !== "")
Expand Down Expand Up @@ -113,6 +115,7 @@ export function FolderView() {
setTypeFilterPagination={setTypeFilter}
setModify={setModify}
modify={modify}
setCategoryFilterPagination={setCategoryFilter}
/>
</>
);
Expand Down
11 changes: 9 additions & 2 deletions client/packages/lowcoder/src/pages/ApplicationV2/HomeLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ export interface HomeLayoutProps {
searchValue?: string;
setSearchValue?: any;
setTypeFilterPagination?: any;
setCategoryFilterPagination?: any;
setModify?: any;
modify?: boolean;
}
Expand All @@ -334,6 +335,7 @@ export function HomeLayout(props: HomeLayoutProps) {
setSearchValue,
total,
setTypeFilterPagination,
setCategoryFilterPagination,
setModify,
modify

Expand Down Expand Up @@ -551,12 +553,17 @@ export function HomeLayout(props: HomeLayoutProps) {
getPopupContainer={(node: any) => node}
suffixIcon={<ArrowSolidIcon />} />
)}
{mode === "view" &&
{(mode === "view" || mode === "folder") &&
<FilterDropdown
style={{ minWidth: "220px" }}
variant="borderless"
value={categoryFilter}
onChange={(value: any) => setCategoryFilter(value as ApplicationCategoriesEnum)}
onChange={(value: any) => {
setCategoryFilter(value as ApplicationCategoriesEnum)
setCategoryFilterPagination(value as ApplicationCategoriesEnum);
}

}
options={categoryOptions}
// getPopupContainer={(node) => node}
suffixIcon={<ArrowSolidIcon />}
Expand Down
44 changes: 24 additions & 20 deletions client/packages/lowcoder/src/pages/ApplicationV2/HomeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Helmet } from "react-helmet";
import { trans } from "i18n";
import {useState, useEffect } from "react";
import {fetchFolderElements} from "@lowcoder-ee/util/pagination/axios";
import {ApplicationMeta, FolderMeta} from "@lowcoder-ee/constants/applicationConstants";
import {ApplicationCategoriesEnum, ApplicationMeta, FolderMeta} from "@lowcoder-ee/constants/applicationConstants";
import {ApplicationPaginationType} from "@lowcoder-ee/util/pagination/type";

interface ElementsState {
Expand All @@ -21,26 +21,29 @@ export function HomeView() {
const [searchValues, setSearchValues] = useState("");
const [typeFilter, setTypeFilter] = useState<number>(0);
const [modify, setModify] = useState(true);
const [categoryFilter, setCategoryFilter] = useState<ApplicationCategoriesEnum | "All">("All");

useEffect( () => {
try{
fetchFolderElements({
pageNum:currentPage,
pageSize:pageSize,
applicationType: ApplicationPaginationType[typeFilter],
name: searchValues,
}).then(
(data: any) => {
if (data.success) {
setElements({elements: data.data || [], total: data.total || 1})
}
else
console.error("ERROR: fetchFolderElements", data.error)
}
);
} catch (error) {
console.error('Failed to fetch data:', error);
}
}, [currentPage, pageSize, searchValues, typeFilter, modify]
try{
fetchFolderElements({
pageNum:currentPage,
pageSize:pageSize,
applicationType: ApplicationPaginationType[typeFilter],
name: searchValues,
category: categoryFilter
}).then(
(data: any) => {
if (data.success) {
setElements({elements: data.data || [], total: data.total || 1})
}
else
console.error("ERROR: fetchFolderElements", data.error)
}
);
} catch (error) {
console.error('Failed to fetch data:', error);
}
}, [currentPage, pageSize, searchValues, typeFilter, modify, categoryFilter]
);

useEffect( () => {
Expand Down Expand Up @@ -79,6 +82,7 @@ export function HomeView() {
setTypeFilterPagination={setTypeFilter}
setModify={setModify}
modify={modify}
setCategoryFilterPagination={setCategoryFilter}
/>
</>
);
Expand Down
1 change: 1 addition & 0 deletions client/packages/lowcoder/src/util/pagination/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export interface fetchFolderRequestType {
pageSize?: number;
name?: string;
applicationType?: string;
category?: string
}

export interface fetchDBRequestType {
Expand Down