mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-09 21:25:45 +08:00
8192a492d9
fix #13512 fix #13255 fix #9743 #### PR Dependency Tree * **PR #14393** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Enhanced Kanban view grouping support for additional property types: checkboxes, select fields, multi-select fields, members, and created-by information. * Improved drag-and-drop visual feedback with more precise drop indicators in Kanban views. * **Bug Fixes** * Refined grouping logic to ensure only compatible properties appear in group-by options. * Enhanced column visibility and ordering consistency when managing Kanban views. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
67 lines
1.8 KiB
TypeScript
67 lines
1.8 KiB
TypeScript
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
|
|
|
import type { GroupBy, GroupProperty } from '../../core/common/types.js';
|
|
import type { FilterGroup } from '../../core/filter/types.js';
|
|
import type { Sort } from '../../core/sort/types.js';
|
|
import { type BasicViewDataType, viewType } from '../../core/view/data-view.js';
|
|
import { resolveKanbanGroupBy } from './group-by-utils.js';
|
|
import { KanbanSingleView } from './kanban-view-manager.js';
|
|
|
|
export const kanbanViewType = viewType('kanban');
|
|
|
|
export type KanbanViewColumn = {
|
|
id: string;
|
|
hide?: boolean;
|
|
};
|
|
|
|
type DataType = {
|
|
columns: KanbanViewColumn[];
|
|
filter: FilterGroup;
|
|
groupBy?: GroupBy;
|
|
sort?: Sort;
|
|
header: {
|
|
titleColumn?: string;
|
|
iconColumn?: string;
|
|
coverColumn?: string;
|
|
};
|
|
groupProperties: GroupProperty[];
|
|
};
|
|
export type KanbanViewData = BasicViewDataType<
|
|
typeof kanbanViewType.type,
|
|
DataType
|
|
>;
|
|
export const kanbanViewModel = kanbanViewType.createModel<KanbanViewData>({
|
|
defaultName: 'Kanban View',
|
|
dataViewManager: KanbanSingleView,
|
|
defaultData: viewManager => {
|
|
const groupBy = resolveKanbanGroupBy(viewManager.dataSource);
|
|
if (!groupBy) {
|
|
throw new BlockSuiteError(
|
|
ErrorCode.DatabaseBlockError,
|
|
'no groupable column found'
|
|
);
|
|
}
|
|
|
|
const columns = viewManager.dataSource.properties$.value;
|
|
|
|
return {
|
|
columns: columns.map(id => ({
|
|
id: id,
|
|
})),
|
|
filter: {
|
|
type: 'group',
|
|
op: 'and',
|
|
conditions: [],
|
|
},
|
|
groupBy,
|
|
header: {
|
|
titleColumn: viewManager.dataSource.properties$.value.find(
|
|
id => viewManager.dataSource.propertyTypeGet(id) === 'title'
|
|
),
|
|
iconColumn: 'type',
|
|
},
|
|
groupProperties: [],
|
|
};
|
|
},
|
|
});
|