Skip to content

feat(category): subcategory grid supports drag-to-reorder#294

Open
Syz87 wants to merge 2 commits into
TNT-Likely:mainfrom
Syz87:feat/subcategory-drag-reorder
Open

feat(category): subcategory grid supports drag-to-reorder#294
Syz87 wants to merge 2 commits into
TNT-Likely:mainfrom
Syz87:feat/subcategory-drag-reorder

Conversation

@Syz87
Copy link
Copy Markdown

@Syz87 Syz87 commented May 28, 2026

功能

子分类弹窗中的网格支持长按拖拽排序。

改动

GridView.builder 替换为 ReorderableGridView.builder,新增 onReorder 回调。

实现细节

  • 长按子类卡片即可拖拽排序
  • 先乐观更新本地列表,再批量写 sort_order 到数据库
  • 弹窗底部的「添加」和「编辑」按钮不参与拖拽
  • 复用已有 updateCategorySortOrders() API,后端零改动
  • 1 个文件,+24 / -5 行

Developer added 2 commits May 28, 2026 15:59
Prevents expense categories from being silently mapped to
income categories with the same name during CSV import.

Root cause: upsertCategory() WHERE clause only filtered by name,
ignoring the kind parameter. When a category name existed in both
expense and income (e.g. 'transfer'/'转账'), the function returned
the first match regardless of kind.

Fix: add c.kind.equals(kind) to the WHERE clause, ensuring
upsert matches both name and kind before reusing an existing
category.
Replace GridView.builder with ReorderableGridView.builder in the
subcategory dialog, allowing users to long-press and drag subcategory
cards to reorder them.

- onReorder applies optimistic local update then persists to DB via
  existing updateCategorySortOrders()
- Add/edit action buttons at end of grid excluded from drag
- ValueKey added to DialogSubCategoryCard for stable identity
@TNT-Likely
Copy link
Copy Markdown
Owner

@Syz87 icon不要这么写死进去,而且这个有点丑,可以打包为图片集,但要注意版权问题。这里如果是支持二级分类拖拽就不要包含其他内容,其他内容单开。

@Syz87 Syz87 force-pushed the feat/subcategory-drag-reorder branch from 15c27b2 to 13529ec Compare May 29, 2026 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants