-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bed6172
commit a71411e
Showing
3 changed files
with
154 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,140 @@ | ||
import { filterBy } from "@progress/kendo-data-query"; | ||
import { Button } from "@progress/kendo-react-buttons"; | ||
import { GridFilterChangeEvent, GridItemChangeEvent, Grid, GridToolbar, GridSearchBox, GridColumn } from "@progress/kendo-react-grid"; | ||
import { BreadcrumbLinkMouseEvent, Breadcrumb } from "@progress/kendo-react-layout"; | ||
import { exportIcon, homeIcon, printIcon } from "@progress/kendo-svg-icons"; | ||
import React from "react"; | ||
import { CSVLink } from "react-csv"; | ||
import { useNavigate } from "react-router-dom"; | ||
import { tasksData } from "./data"; | ||
import { SvgIcon } from "@progress/kendo-react-common"; | ||
|
||
interface DataModel { | ||
id: string; | ||
text?: string; | ||
icon?: React.ReactNode; | ||
} | ||
|
||
const breadcrumbItems: DataModel[] = [ | ||
{ id: "home", icon: <SvgIcon icon={homeIcon} /> }, | ||
{ id: "tasks", text: "Tasks" }, | ||
]; | ||
|
||
export default function Tasks() { | ||
const navigate = useNavigate(); | ||
|
||
const [data, setData] = React.useState<any>(tasksData); | ||
const [filter, setFilter] = React.useState<any>(); | ||
|
||
const handleItemSelect = (e: BreadcrumbLinkMouseEvent) => { | ||
if (e.id === "home") { | ||
navigate("/"); | ||
} | ||
}; | ||
|
||
const filterChange = (event: GridFilterChangeEvent) => { | ||
setFilter(event.filter); | ||
|
||
setData(filterBy(tasksData, event.filter)); | ||
}; | ||
|
||
const itemChange = (event: GridItemChangeEvent) => { | ||
const newData = data.map((item: any) => | ||
item.taskId === event.dataItem.taskId | ||
? { | ||
...item, | ||
[event.field || '']: event.value | ||
} | ||
: item | ||
); | ||
|
||
setData(newData); | ||
}; | ||
|
||
return ( | ||
<> | ||
Tasks | ||
</> | ||
) | ||
} | ||
<div | ||
style={{ minHeight: "calc(100vh - 106px)" }} | ||
className="flex flex-col p-10 gap-6" | ||
> | ||
<Breadcrumb | ||
data={breadcrumbItems} | ||
onItemSelect={handleItemSelect} | ||
className="!bg-app-surface" | ||
/> | ||
|
||
<div className="flex flex-wrap items-center"> | ||
<h1 className="text-4xl">Tasks</h1> | ||
</div> | ||
|
||
<Grid | ||
className="k-grid-no-scrollbar" | ||
data={data} | ||
autoProcessData={{ | ||
filter: false, | ||
search: true, | ||
page: true, | ||
}} | ||
// FILTER | ||
filter={filter} | ||
filterable={true} | ||
onFilterChange={filterChange} | ||
// PAGER | ||
pageable={ | ||
{ | ||
buttonCount: 6, | ||
pageSizes: [5, 10, 15, 'All'], | ||
|
||
} | ||
} | ||
onItemChange={itemChange} | ||
defaultTake={10} | ||
defaultSkip={0} | ||
|
||
// EDITING | ||
dataItemKey={"ProjectID"} | ||
editable={true} | ||
|
||
> | ||
<GridToolbar> | ||
<GridSearchBox /> | ||
<span className="k-toolbar-spacer" /> | ||
|
||
<Button svgIcon={exportIcon} fillMode="flat"> | ||
<CSVLink data={data}>Export to CSV</CSVLink> | ||
</Button> | ||
<Button svgIcon={printIcon} fillMode="flat" onClick={print}> | ||
</Button> | ||
</GridToolbar> | ||
<GridColumn field="taskName" title="Task Name" width={350} /> | ||
<GridColumn | ||
field="assignedTo" | ||
title="Assigned To" | ||
width={195} | ||
/> | ||
<GridColumn | ||
field="dueDate" | ||
title="Due Date" | ||
width={195} | ||
format="{0:d}" | ||
filter="date" | ||
/> | ||
<GridColumn | ||
field="priority" | ||
title="Priority" | ||
width={195} | ||
/> | ||
<GridColumn | ||
field="status" | ||
title="Status" | ||
width={200} | ||
/> | ||
<GridColumn | ||
field="tags" | ||
title="Tags" | ||
width={270} | ||
/> | ||
</Grid> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters