|
|
@@ -50,7 +50,7 @@ final class SubTask : Codable {
|
|
|
}
|
|
|
return rval
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
enum CodingKeys : CodingKey { case name, notes, status }
|
|
|
|
|
|
required init(from decoder: any Decoder) throws {
|
|
|
@@ -59,7 +59,7 @@ final class SubTask : Codable {
|
|
|
notes = try container.decode(String.self, forKey: .notes)
|
|
|
status = try container.decode(Status.self, forKey: .status)
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
func encode(to encoder: any Encoder) throws {
|
|
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
|
try container.encode(name, forKey: .name)
|
|
|
@@ -68,19 +68,34 @@ final class SubTask : Codable {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-struct Tag : Codable, Identifiable {
|
|
|
+@Model
|
|
|
+final class Tag : Codable {
|
|
|
var id: String
|
|
|
-
|
|
|
+
|
|
|
+ init(id: String) {
|
|
|
+ self.id = id
|
|
|
+ }
|
|
|
+
|
|
|
func like(_ str: String) -> Bool {
|
|
|
return id.caseInsensitiveCompare(str) == .orderedSame
|
|
|
}
|
|
|
+
|
|
|
+ required init(from decoder: any Decoder) throws {
|
|
|
+ id = try decoder.singleValueContainer().decode(String.self)
|
|
|
+ }
|
|
|
+
|
|
|
+ func encode(to encoder: any Encoder) throws {
|
|
|
+ var single = encoder.singleValueContainer()
|
|
|
+ try single.encode(id)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Model
|
|
|
final class Task : Codable {
|
|
|
var name: String
|
|
|
+ @Relationship(deleteRule: .cascade)
|
|
|
var tags: [Tag] = []
|
|
|
- @Relationship(deleteRule: .nullify)
|
|
|
+ @Relationship(deleteRule: .cascade)
|
|
|
var subtasks: [SubTask] = []
|
|
|
var notes: String = ""
|
|
|
var status: Status = Status.Todo
|