-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/column-visibility-selection'
- Loading branch information
Showing
19 changed files
with
821 additions
and
212 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { Button } from "@/components/ui/button"; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuLabel, | ||
DropdownMenuSeparator, | ||
DropdownMenuCheckboxItem, | ||
DropdownMenuTrigger, | ||
} from "@/components/ui/dropdown-menu"; | ||
import { Settings2 } from "lucide-react"; | ||
import { ColumnProfile, TableColumn } from "../search.d"; | ||
import { isEqual } from "moderndash"; | ||
|
||
interface ColumnSelectorProps { | ||
columns: TableColumn[]; | ||
onToggleColumn: (column: TableColumn) => void; | ||
profiles: Record<ColumnProfile, TableColumn[]>; | ||
setProfile: (profile: ColumnProfile) => void; | ||
} | ||
|
||
export function ColumnSelector({ | ||
columns, | ||
onToggleColumn, | ||
profiles, | ||
setProfile, | ||
}: ColumnSelectorProps) { | ||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button variant="ghost" size="sm"> | ||
<Settings2 className="h-4 w-4" /> | ||
<span className="sr-only">Column Settings</span> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent align="end" className="w-[200px]"> | ||
<DropdownMenuLabel>Toggle Columns</DropdownMenuLabel> | ||
<DropdownMenuSeparator /> | ||
{columns.map((column) => ( | ||
<DropdownMenuCheckboxItem | ||
key={`column-selector-${column.code}${column.type === "Adaptable" ? "-" + column.stat_code : ""}`} | ||
checked={column.type == "Always" ? true : column.visible} | ||
onCheckedChange={() => onToggleColumn(column)} | ||
disabled={column.type == "Always" ? true : false} | ||
> | ||
{column.label} | ||
</DropdownMenuCheckboxItem> | ||
))} | ||
<DropdownMenuSeparator /> | ||
<DropdownMenuLabel>Profiles</DropdownMenuLabel> | ||
<DropdownMenuCheckboxItem | ||
checked={profiles && isEqual(columns, profiles["Brief"])} | ||
onCheckedChange={() => setProfile("Brief")} | ||
> | ||
Brief | ||
</DropdownMenuCheckboxItem> | ||
<DropdownMenuCheckboxItem | ||
checked={profiles && isEqual(columns, profiles["Regular"])} | ||
onCheckedChange={() => setProfile("Regular")} | ||
> | ||
Regular | ||
</DropdownMenuCheckboxItem> | ||
<DropdownMenuCheckboxItem | ||
checked={profiles && isEqual(columns, profiles["Detailed"])} | ||
onCheckedChange={() => setProfile("Detailed")} | ||
> | ||
Detailed | ||
</DropdownMenuCheckboxItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"use client"; | ||
|
||
import { useTableColumns } from "../table-columns"; | ||
import { TableColumn } from "../search"; | ||
|
||
interface FilterWrapperProps { | ||
columnCode: TableColumn["code"]; | ||
statCode?: string | null; | ||
children: React.ReactNode; | ||
} | ||
|
||
export function FilterWrapper({ columnCode, statCode = null, children }: FilterWrapperProps) { | ||
const { visibleColumns } = useTableColumns(); | ||
|
||
// Check if this column is visible | ||
const isVisible = visibleColumns.some(column => { | ||
if (column.code !== columnCode) return false; | ||
if (columnCode === 'statistic' && column.type === 'Adaptable') { | ||
return column.stat_code === statCode; | ||
} | ||
return true; | ||
}); | ||
|
||
if (!isVisible) return null; | ||
|
||
return <>{children}</>; | ||
} |
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
Oops, something went wrong.