|
|
@@ -98,6 +98,7 @@ final class Tag : Codable {
|
|
|
final class Task : Codable {
|
|
|
var name: String
|
|
|
var project: Project?
|
|
|
+ var category: String = ""
|
|
|
@Relationship(deleteRule: .cascade, inverse: \Tag.task)
|
|
|
var tags: [Tag] = []
|
|
|
@Relationship(deleteRule: .cascade, inverse: \SubTask.task)
|
|
|
@@ -108,6 +109,7 @@ final class Task : Codable {
|
|
|
init(name: String, parent: Project? = nil) {
|
|
|
self.name = name
|
|
|
self.project = parent
|
|
|
+ self.category = parent?.category ?? ""
|
|
|
}
|
|
|
|
|
|
func yaml(_ indent: Int = 0) -> String {
|
|
|
@@ -122,11 +124,12 @@ final class Task : Codable {
|
|
|
return rval
|
|
|
}
|
|
|
|
|
|
- enum CodingKeys : CodingKey { case name, tags, subtasks, notes, status }
|
|
|
+ enum CodingKeys : CodingKey { case name, category, tags, subtasks, notes, status }
|
|
|
|
|
|
required init(from decoder: any Decoder) throws {
|
|
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
|
|
name = try container.decode(String.self, forKey: .name)
|
|
|
+ category = try container.decode(String.self, forKey: .category)
|
|
|
tags = try container.decode([Tag].self, forKey: .tags)
|
|
|
subtasks = try container.decode([SubTask].self, forKey: .subtasks)
|
|
|
notes = try container.decode(String.self, forKey: .notes)
|
|
|
@@ -136,6 +139,7 @@ final class Task : Codable {
|
|
|
func encode(to encoder: any Encoder) throws {
|
|
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
|
try container.encode(name, forKey: .name)
|
|
|
+ try container.encode(category, forKey: .category)
|
|
|
try container.encode(tags, forKey: .tags)
|
|
|
try container.encode(subtasks, forKey: .subtasks)
|
|
|
try container.encode(notes, forKey: .notes)
|