mirror of
https://github.com/docmost/docmost.git
synced 2026-07-24 12:13:06 +10:00
feat(bases): surface group-by picker in toolbar for kanban views
This commit is contained in:
@@ -21,6 +21,8 @@ import { ViewTabs } from "@/features/base/components/views/view-tabs";
|
|||||||
import { ViewSortConfigPopover } from "@/features/base/components/views/view-sort-config";
|
import { ViewSortConfigPopover } from "@/features/base/components/views/view-sort-config";
|
||||||
import { ViewFilterConfigPopover } from "@/features/base/components/views/view-filter-config";
|
import { ViewFilterConfigPopover } from "@/features/base/components/views/view-filter-config";
|
||||||
import { ViewFieldVisibility } from "@/features/base/components/views/view-field-visibility";
|
import { ViewFieldVisibility } from "@/features/base/components/views/view-field-visibility";
|
||||||
|
import { KanbanGroupByPicker } from "@/features/base/components/views/kanban/kanban-group-by-picker";
|
||||||
|
import { useUpdateViewMutation } from "@/features/base/queries/base-view-query";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import classes from "@/features/base/styles/grid.module.css";
|
import classes from "@/features/base/styles/grid.module.css";
|
||||||
|
|
||||||
@@ -136,6 +138,21 @@ export function BaseToolbar({
|
|||||||
return cols.filter((col) => col.getCanHide() && !col.getIsVisible()).length;
|
return cols.filter((col) => col.getCanHide() && !col.getIsVisible()).length;
|
||||||
}, [table, table.getState().columnVisibility]);
|
}, [table, table.getState().columnVisibility]);
|
||||||
|
|
||||||
|
const updateViewMutation = useUpdateViewMutation();
|
||||||
|
const isKanban = activeView?.type === "kanban";
|
||||||
|
|
||||||
|
const handleGroupByChange = useCallback(
|
||||||
|
(propertyId: string) => {
|
||||||
|
if (!activeView) return;
|
||||||
|
updateViewMutation.mutate({
|
||||||
|
viewId: activeView.id,
|
||||||
|
pageId: base.id,
|
||||||
|
config: { ...activeView.config, groupByPropertyId: propertyId },
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[activeView, base.id, updateViewMutation],
|
||||||
|
);
|
||||||
|
|
||||||
const handleSortsChange = useCallback(
|
const handleSortsChange = useCallback(
|
||||||
(newSorts: ViewSortConfig[]) => {
|
(newSorts: ViewSortConfig[]) => {
|
||||||
// Normalize empty to undefined so the draft hook can drop the `sorts`
|
// Normalize empty to undefined so the draft hook can drop the `sorts`
|
||||||
@@ -168,6 +185,15 @@ export function BaseToolbar({
|
|||||||
onAddView={onAddView}
|
onAddView={onAddView}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{isKanban && (
|
||||||
|
<KanbanGroupByPicker
|
||||||
|
properties={base.properties}
|
||||||
|
value={activeView?.config?.groupByPropertyId ?? null}
|
||||||
|
onChange={handleGroupByChange}
|
||||||
|
size="xs"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className={classes.toolbarRight} ref={toolbarRightRef}>
|
<div className={classes.toolbarRight} ref={toolbarRightRef}>
|
||||||
<Tooltip label={t("Export CSV")}>
|
<Tooltip label={t("Export CSV")}>
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
@@ -257,43 +283,45 @@ export function BaseToolbar({
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
</ViewSortConfigPopover>
|
</ViewSortConfigPopover>
|
||||||
|
|
||||||
<ViewFieldVisibility
|
{!isKanban && (
|
||||||
opened={fieldsOpened}
|
<ViewFieldVisibility
|
||||||
onClose={() => setFieldsOpened(false)}
|
opened={fieldsOpened}
|
||||||
table={table}
|
onClose={() => setFieldsOpened(false)}
|
||||||
properties={base.properties}
|
table={table}
|
||||||
onPersist={onPersistViewConfig}
|
properties={base.properties}
|
||||||
>
|
onPersist={onPersistViewConfig}
|
||||||
<Tooltip label={t("Hide fields")}>
|
>
|
||||||
<ActionIcon
|
<Tooltip label={t("Hide fields")}>
|
||||||
variant="subtle"
|
<ActionIcon
|
||||||
size="sm"
|
variant="subtle"
|
||||||
color={hiddenFieldCount > 0 ? "blue" : "gray"}
|
size="sm"
|
||||||
onClick={() => openToolbar("fields")}
|
color={hiddenFieldCount > 0 ? "blue" : "gray"}
|
||||||
>
|
onClick={() => openToolbar("fields")}
|
||||||
<IconEye size={16} />
|
>
|
||||||
{hiddenFieldCount > 0 && (
|
<IconEye size={16} />
|
||||||
<Badge
|
{hiddenFieldCount > 0 && (
|
||||||
size="xs"
|
<Badge
|
||||||
circle
|
size="xs"
|
||||||
color="blue"
|
circle
|
||||||
style={{
|
color="blue"
|
||||||
position: "absolute",
|
style={{
|
||||||
top: -2,
|
position: "absolute",
|
||||||
right: -2,
|
top: -2,
|
||||||
padding: 0,
|
right: -2,
|
||||||
width: 14,
|
padding: 0,
|
||||||
height: 14,
|
width: 14,
|
||||||
minWidth: 14,
|
height: 14,
|
||||||
fontSize: 9,
|
minWidth: 14,
|
||||||
}}
|
fontSize: 9,
|
||||||
>
|
}}
|
||||||
{hiddenFieldCount}
|
>
|
||||||
</Badge>
|
{hiddenFieldCount}
|
||||||
)}
|
</Badge>
|
||||||
</ActionIcon>
|
)}
|
||||||
</Tooltip>
|
</ActionIcon>
|
||||||
</ViewFieldVisibility>
|
</Tooltip>
|
||||||
|
</ViewFieldVisibility>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user