d530920284
Tasks are not part of the knowledge API (backend rejects type=task). When the Tasks tab is selected, fetch from /api/tasks and convert to KnowledgeItem. Also removes per-type counts from tab labels to prevent tabs from awkwardly resizing when counts load. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
70 lines
2.1 KiB
Dart
70 lines
2.1 KiB
Dart
import 'task.dart';
|
|
|
|
class KnowledgeItem {
|
|
final int id;
|
|
final String noteType; // 'note' | 'person' | 'place' | 'list' | 'task'
|
|
final String title;
|
|
final String body;
|
|
final List<String> tags;
|
|
final int? projectId;
|
|
final int? milestoneId;
|
|
final int? parentId;
|
|
// Task-only fields (null for non-tasks)
|
|
final String? status; // 'todo' | 'in_progress' | 'done' | 'cancelled'
|
|
final String? priority; // 'low' | 'normal' | 'high'
|
|
final String? dueDate;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
|
|
const KnowledgeItem({
|
|
required this.id,
|
|
required this.noteType,
|
|
required this.title,
|
|
required this.body,
|
|
required this.tags,
|
|
this.projectId,
|
|
this.milestoneId,
|
|
this.parentId,
|
|
this.status,
|
|
this.priority,
|
|
this.dueDate,
|
|
required this.createdAt,
|
|
required this.updatedAt,
|
|
});
|
|
|
|
factory KnowledgeItem.fromTask(Task task) => KnowledgeItem(
|
|
id: task.id,
|
|
noteType: 'task',
|
|
title: task.title,
|
|
body: task.description ?? '',
|
|
tags: const [],
|
|
projectId: task.projectId,
|
|
milestoneId: task.milestoneId,
|
|
parentId: task.parentId,
|
|
status: task.status.value,
|
|
priority: task.priority.value,
|
|
dueDate: task.dueDate?.toIso8601String(),
|
|
createdAt: task.createdAt,
|
|
updatedAt: task.updatedAt,
|
|
);
|
|
|
|
factory KnowledgeItem.fromJson(Map<String, dynamic> json) => KnowledgeItem(
|
|
id: json['id'] as int,
|
|
noteType: json['note_type'] as String? ?? 'note',
|
|
title: json['title'] as String? ?? '',
|
|
body: json['body'] as String? ?? '',
|
|
tags: (json['tags'] as List<dynamic>?)
|
|
?.map((e) => e as String)
|
|
.toList() ??
|
|
[],
|
|
projectId: json['project_id'] as int?,
|
|
milestoneId: json['milestone_id'] as int?,
|
|
parentId: json['parent_id'] as int?,
|
|
status: json['status'] as String?,
|
|
priority: json['priority'] as String?,
|
|
dueDate: json['due_date'] as String?,
|
|
createdAt: DateTime.parse(json['created_at'] as String),
|
|
updatedAt: DateTime.parse(json['updated_at'] as String),
|
|
);
|
|
}
|