Adding lecturer to lecture plan item detail view

This commit is contained in:
Patrick Müller 2021-02-10 21:27:26 +01:00 committed by Patrick Müller
parent b689a7bbf1
commit ba0d4da657
4 changed files with 22 additions and 2 deletions

View File

@ -11,6 +11,7 @@ import CoreData
@objc(Lecturer)
public class Lecturer: NSManagedObject {
// MARK: Access methods
@nonobjc public class func getAll() -> [Lecturer] {
let managedContext =
PersistenceController.shared.context
@ -41,4 +42,13 @@ public class Lecturer: NSManagedObject {
return []
}
}
// MARK: Wrappers
public var wrappedName: String {
name ?? ""
}
public var wrappedEmail: String {
email ?? ""
}
}

View File

@ -11,6 +11,8 @@ import CoreData
@objc(RaPlaEvent)
public class RaPlaEvent: NSManagedObject {
// MARK: Access methods
@nonobjc public class func getAll() -> [RaPlaEvent] {
let managedContext =
PersistenceController.shared.context
@ -41,4 +43,12 @@ public class RaPlaEvent: NSManagedObject {
return []
}
}
// MARK: Wrappers
public var lecturerList: [Lecturer] {
let set = lecturers as? Set<Lecturer> ?? []
return set.sorted {
$0.wrappedName < $1.wrappedName
}
}
}

View File

@ -47,7 +47,7 @@ struct ContentView: View {
}
.onAppear{
// Called upon the opening of the app
RaPlaFetcher.getRaplaFileAndSaveToCoreData(from: "https://rapla.dhbw-karlsruhe.de/rapla?page=ical&user=eisenbiegler&file=TINF20B4")
RaPlaFetcher.getRaplaFileAndSaveToCoreData(from: "https://rapla.dhbw-karlsruhe.de/rapla?page=ical&user=eisenbiegler&file=TINF19B4")
}
}
}

View File

@ -37,7 +37,7 @@ struct LecturePlanItem: View {
.bold()
Text(event.location!)
.bold()
Text("WIP")
Text(!event.lecturerList.isEmpty ? event.lecturerList[0].wrappedName : "")
.bold()
}.frame(maxWidth: .infinity, alignment: .leading)
}