Add dual sort modes: manual ordering and by due date
Enhanced task ordering with two sort options:
1. Manual Ordering (default):
- User can drag/drop to reorder tasks
- Order stored in task_order array in .listdata.json
- Only manual changes update the file
2. By Due Date:
- Tasks automatically sorted by due_date field
- Tasks without due dates appear at end
- task_order array ignored when in this mode
Changes:
- Added sort_order field to .listdata.json ("manual" or "by_due_date")
- Added SortOrder enum to TaskList model
- Clarified that Vec<Task> order depends on sort preference
- Added set_sort_order() and get_sort_order() to repository API
- Added CLI sort command to switch between modes
- Removed confusing comment about .listdata.json being "in-memory"
Example .listdata.json:
{
"sort_order": "manual",
"task_order": ["uuid-1", "uuid-2", "uuid-3"]
}
CLI usage:
bevy-tasks sort manual --list "Work"
bevy-tasks sort by-due-date --list "Personal"
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
71619eddf9
commit
eb6bb932f7
29
PLAN.md
29
PLAN.md
|
|
@ -90,10 +90,15 @@ Task {
|
||||||
TaskList {
|
TaskList {
|
||||||
id: Uuid,
|
id: Uuid,
|
||||||
title: String, // Derived from folder name
|
title: String, // Derived from folder name
|
||||||
tasks: Vec<Task>,
|
tasks: Vec<Task>, // Ordered according to sort_order preference
|
||||||
created_at: DateTime,
|
created_at: DateTime,
|
||||||
updated_at: DateTime,
|
updated_at: DateTime,
|
||||||
// Note: task_order stored in .listdata.json, not in memory model
|
sort_order: SortOrder, // How to sort: Manual or ByDueDate
|
||||||
|
}
|
||||||
|
|
||||||
|
enum SortOrder {
|
||||||
|
Manual, // Use task_order from .listdata.json
|
||||||
|
ByDueDate, // Sort by due_date field (tasks without due dates at end)
|
||||||
}
|
}
|
||||||
|
|
||||||
AppConfig {
|
AppConfig {
|
||||||
|
|
@ -134,6 +139,7 @@ AppConfig {
|
||||||
"id": "list-uuid-1",
|
"id": "list-uuid-1",
|
||||||
"created_at": "2025-10-26T10:00:00Z",
|
"created_at": "2025-10-26T10:00:00Z",
|
||||||
"updated_at": "2025-10-27T14:30:00Z",
|
"updated_at": "2025-10-27T14:30:00Z",
|
||||||
|
"sort_order": "manual",
|
||||||
"task_order": [
|
"task_order": [
|
||||||
"task-uuid-1",
|
"task-uuid-1",
|
||||||
"task-uuid-2",
|
"task-uuid-2",
|
||||||
|
|
@ -142,8 +148,15 @@ AppConfig {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Sort Order Options**:
|
||||||
|
- `"manual"` - Tasks ordered by hand (uses `task_order` array)
|
||||||
|
- `"by_due_date"` - Tasks automatically sorted by due date (tasks without due dates appear at end)
|
||||||
|
|
||||||
|
When `sort_order` is `"manual"`, the `task_order` array defines the sequence. When `sort_order` is `"by_due_date"`, tasks are sorted dynamically and `task_order` is ignored.
|
||||||
|
|
||||||
**Benefits**:
|
**Benefits**:
|
||||||
- **Ordering in list metadata**: Reordering tasks only touches `.listdata.json`
|
- **Two sort modes**: Manual ordering or automatic by due date
|
||||||
|
- **Ordering in list metadata**: Changing manual order only touches `.listdata.json`
|
||||||
- **Portable lists**: Copy/move a list folder and its metadata stays with it
|
- **Portable lists**: Copy/move a list folder and its metadata stays with it
|
||||||
- **Clean structure**: No nested hidden folders, just hidden files
|
- **Clean structure**: No nested hidden folders, just hidden files
|
||||||
- **WebDAV-friendly**: Syncing a list syncs its metadata naturally
|
- **WebDAV-friendly**: Syncing a list syncs its metadata naturally
|
||||||
|
|
@ -179,6 +192,10 @@ impl TaskRepository {
|
||||||
// Task ordering (modifies .listdata.json)
|
// Task ordering (modifies .listdata.json)
|
||||||
pub fn reorder_task(&mut self, list_id: Uuid, task_id: Uuid, new_position: usize) -> Result<()>;
|
pub fn reorder_task(&mut self, list_id: Uuid, task_id: Uuid, new_position: usize) -> Result<()>;
|
||||||
pub fn get_task_order(&self, list_id: Uuid) -> Result<Vec<Uuid>>;
|
pub fn get_task_order(&self, list_id: Uuid) -> Result<Vec<Uuid>>;
|
||||||
|
|
||||||
|
// Sort preference (modifies .listdata.json)
|
||||||
|
pub fn set_sort_order(&mut self, list_id: Uuid, sort_order: SortOrder) -> Result<()>;
|
||||||
|
pub fn get_sort_order(&self, list_id: Uuid) -> Result<SortOrder>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Storage {
|
pub trait Storage {
|
||||||
|
|
@ -262,6 +279,8 @@ tokio = { workspace = true }
|
||||||
- [ ] CLI: `complete` command (mark done)
|
- [ ] CLI: `complete` command (mark done)
|
||||||
- [ ] CLI: `delete` command (remove tasks)
|
- [ ] CLI: `delete` command (remove tasks)
|
||||||
- [ ] CLI: `edit` command (modify tasks)
|
- [ ] CLI: `edit` command (modify tasks)
|
||||||
|
- [ ] Two sort modes: manual ordering and by due date
|
||||||
|
- [ ] CLI: `sort` command (switch between manual/by-due-date)
|
||||||
- [ ] Comprehensive unit and integration tests (>80% coverage)
|
- [ ] Comprehensive unit and integration tests (>80% coverage)
|
||||||
|
|
||||||
### CLI Usage Examples
|
### CLI Usage Examples
|
||||||
|
|
@ -283,6 +302,10 @@ bevy-tasks delete <task-id>
|
||||||
|
|
||||||
# Change folder location later
|
# Change folder location later
|
||||||
bevy-tasks config set-folder ~/new/location
|
bevy-tasks config set-folder ~/new/location
|
||||||
|
|
||||||
|
# Sort order
|
||||||
|
bevy-tasks sort manual --list "Work"
|
||||||
|
bevy-tasks sort by-due-date --list "Personal"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Deliverables
|
### Deliverables
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue