Files
AFFiNE-Mirror/blocksuite/affine/data-view/src/view-presets/kanban/mobile/menu.ts
T
zzj3720 a2a90df276 feat(editor): add grouping support for member property of the database block (#12243)
close: BS-3433

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Introduced advanced group-by configurations for database blocks with user membership support.
  - Added a React hook for fetching and displaying user information in member-related components.
  - Enabled dynamic user and membership data types in database properties.

- **Improvements**
  - Replaced context-based service access with a dependency injection system for shared services and state.
  - Enhanced type safety and consistency across group-by UI components and data handling.
  - Centralized group data management with a new Group class and refined group trait logic.

- **Bug Fixes**
  - Improved reliability and consistency in retrieving and rendering user and group information.

- **Style**
  - Removed obsolete member selection styles for cleaner UI code.

- **Chores**
  - Registered external group-by configurations via dependency injection.
  - Refactored internal APIs for data sources, views, and group-by matchers to use service-based patterns.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-13 13:53:37 +00:00

116 lines
2.8 KiB
TypeScript

import {
menu,
popFilterableSimpleMenu,
type PopupTarget,
} from '@blocksuite/affine-components/context-menu';
import {
ArrowRightBigIcon,
DeleteIcon,
ExpandFullIcon,
MoveLeftIcon,
MoveRightIcon,
} from '@blocksuite/icons/lit';
import { html } from 'lit';
import type { DataViewRenderer } from '../../../core/data-view.js';
import { groupTraitKey } from '../../../core/group-by/trait.js';
import type { KanbanSingleView } from '../kanban-view-manager.js';
export const popCardMenu = (
ele: PopupTarget,
view: KanbanSingleView,
groupKey: string,
cardId: string,
dataViewEle: DataViewRenderer
) => {
const groupTrait = view.traitGet(groupTraitKey);
if (!groupTrait) {
return;
}
popFilterableSimpleMenu(ele, [
menu.group({
items: [
menu.action({
name: 'Expand Card',
prefix: ExpandFullIcon(),
select: () => {
dataViewEle.openDetailPanel({
view: view,
rowId: cardId,
});
},
}),
],
}),
menu.group({
items: [
menu.subMenu({
name: 'Move To',
prefix: ArrowRightBigIcon(),
options: {
items:
groupTrait.groupsDataList$.value
?.filter(v => {
return v.key !== groupKey;
})
.map(group => {
return menu.action({
name: group.value != null ? group.name$.value : 'Ungroup',
select: () => {
groupTrait.moveCardTo(
cardId,
groupKey,
group.key,
'start'
);
},
});
}) ?? [],
},
}),
],
}),
menu.group({
name: '',
items: [
menu.action({
name: 'Insert Before',
prefix: html` <div
style="transform: rotate(90deg);display:flex;align-items:center;"
>
${MoveLeftIcon()}
</div>`,
select: () => {
view.addCard({ before: true, id: cardId }, groupKey);
},
}),
menu.action({
name: 'Insert After',
prefix: html` <div
style="transform: rotate(90deg);display:flex;align-items:center;"
>
${MoveRightIcon()}
</div>`,
select: () => {
view.addCard({ before: false, id: cardId }, groupKey);
},
}),
],
}),
menu.group({
items: [
menu.action({
name: 'Delete Card',
class: {
'delete-item': true,
},
prefix: DeleteIcon(),
select: () => {
view.rowsDelete([cardId]);
},
}),
],
}),
]);
};