Skip to content

Commit

Permalink
fixes bug where a note can only be associated with one job. note.job
Browse files Browse the repository at this point in the history
prop will be removed in the next version
  • Loading branch information
aapis committed Feb 12, 2023
1 parent b9d9ff1 commit 0bc8a1b
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 31 deletions.
4 changes: 2 additions & 2 deletions DLPrototype.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 75;
CURRENT_PROJECT_VERSION = 76;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"DLPrototype/Preview Content\"";
DEVELOPMENT_TEAM = 6DT7L2N5X6;
Expand Down Expand Up @@ -988,7 +988,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 75;
CURRENT_PROJECT_VERSION = 76;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"DLPrototype/Preview Content\"";
DEVELOPMENT_TEAM = 6DT7L2N5X6;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<attribute name="id" optional="YES" attributeType="UUID" usesScalarValueType="NO"/>
<attribute name="jid" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="YES"/>
<attribute name="uri" optional="YES" attributeType="URI"/>
<relationship name="mNotes" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Note" inverseName="mJob" inverseEntity="Note"/>
<relationship name="notes" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Note" inverseName="job" inverseEntity="Note"/>
<relationship name="project" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Project" inverseName="jobs" inverseEntity="Project"/>
<relationship name="records" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="LogRecord" inverseName="job" inverseEntity="LogRecord"/>
Expand Down Expand Up @@ -40,6 +41,7 @@
<attribute name="starred" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="title" optional="YES" attributeType="String"/>
<relationship name="job" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Job" inverseName="notes" inverseEntity="Job"/>
<relationship name="mJob" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Job" inverseName="mNotes" inverseEntity="Job"/>
<relationship name="versions" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="NoteVersion" inverseName="note" inverseEntity="NoteVersion"/>
</entity>
<entity name="NoteVersion" representedClassName="NoteVersion" syncable="YES" codeGenerationType="class">
Expand Down
3 changes: 2 additions & 1 deletion DLPrototype/Views/Notes/NoteCreate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ struct NoteCreate: View {
note.body = content
note.postedDate = Date()
note.id = UUID()
note.job = selectedJob
note.job = selectedJob // TODO: DEPRECATED
note.mJob = selectedJob
note.alive = true

let version = NoteVersion(context: moc)
Expand Down
22 changes: 11 additions & 11 deletions DLPrototype/Views/Notes/NoteRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ struct NoteRow: View {
Group {
HStack(spacing: 0) {
ZStack(alignment: .leading) {
if note.job != nil {
Color.fromStored(note.job!.project!.colour ?? Theme.rowColourAsDouble)
if note.mJob != nil {
Color.fromStored(note.mJob!.project!.colour ?? Theme.rowColourAsDouble)
} else {
Theme.rowColour
}
Expand All @@ -42,30 +42,30 @@ struct NoteRow: View {
@ViewBuilder private func nNote(_ note: Note) -> some View {
Group {
ZStack(alignment: .leading) {
if note.job != nil {
Color.fromStored(note.job!.colour ?? Theme.rowColourAsDouble)
if note.mJob != nil {
Color.fromStored(note.mJob!.colour ?? Theme.rowColourAsDouble)
} else {
Theme.rowColour
}

FancyTextLink(text: note.title!, destination: AnyView(NoteView(note: note)), fgColour: (note.job != nil ? (Color.fromStored(note.job!.colour ?? Theme.rowColourAsDouble).isBright() ? Color.black : Color.white) : Color.white))
FancyTextLink(text: note.title!, destination: AnyView(NoteView(note: note)), fgColour: (note.mJob != nil ? (Color.fromStored(note.mJob!.colour ?? Theme.rowColourAsDouble).isBright() ? Color.black : Color.white) : Color.white))
}
}
}

@ViewBuilder private func nStar(_ note: Note) -> some View {
Group {
ZStack {
if note.job != nil {
Color.fromStored(note.job!.colour ?? Theme.rowColourAsDouble)
if note.mJob != nil {
Color.fromStored(note.mJob!.colour ?? Theme.rowColourAsDouble)
} else {
Theme.rowColour
}

if note.starred {
Image(systemName: "star.fill")
.padding()
.foregroundColor(note.job != nil ? (Color.fromStored(note.job!.colour ?? Theme.rowColourAsDouble).isBright() ? Color.black : Color.white) : Color.white)
.foregroundColor(note.mJob != nil ? (Color.fromStored(note.mJob!.colour ?? Theme.rowColourAsDouble).isBright() ? Color.black : Color.white) : Color.white)
}
}
}
Expand All @@ -75,15 +75,15 @@ struct NoteRow: View {
@ViewBuilder private func nVersions(_ note: Note) -> some View {
Group {
ZStack {
if note.job != nil {
Color.fromStored(note.job!.colour ?? Theme.rowColourAsDouble)
if note.mJob != nil {
Color.fromStored(note.mJob!.colour ?? Theme.rowColourAsDouble)
} else {
Theme.rowColour
}

Text("\(note.versions!.count)")
.padding()
.foregroundColor(note.job != nil ? (Color.fromStored(note.job!.colour ?? Theme.rowColourAsDouble).isBright() ? Color.black : Color.white) : Color.white)
.foregroundColor(note.mJob != nil ? (Color.fromStored(note.mJob!.colour ?? Theme.rowColourAsDouble).isBright() ? Color.black : Color.white) : Color.white)
}
}
.frame(width: 100)
Expand Down
7 changes: 2 additions & 5 deletions DLPrototype/Views/Notes/NoteView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ struct NoteView: View {
CoreDataNoteVersions(moc: moc).by(id: note.id!)
}

// private var currentVersion: NoteVersion {
// versions.last!
// }

var body: some View {
VStack {
if isShowingEditor {
Expand Down Expand Up @@ -197,6 +193,7 @@ struct NoteView: View {
note.lastUpdate = Date()
lastUpdate = note.lastUpdate
note.job = selectedJob // TODO: REMOVE
note.mJob = selectedJob
note.alive = true

CoreDataNoteVersions(moc: moc).from(note)
Expand Down Expand Up @@ -226,7 +223,7 @@ struct NoteView: View {
private func createBindings(note: Note) -> Void {
title = note.title!
content = note.body!
selectedJob = note.job ?? nil
selectedJob = note.mJob ?? nil
lastUpdate = note.lastUpdate ?? nil
isShowingEditor = true
noteVersions = CoreDataNoteVersions(moc: moc).by(id: note.id!)
Expand Down
2 changes: 1 addition & 1 deletion DLPrototype/Views/Projects/ProjectRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ struct ProjectRow: View {
(project.alive ? Theme.rowStatusGreen : Color.red.opacity(0.2))
}
}
.frame(width: 100)
.frame(width: 5)
}
}
8 changes: 7 additions & 1 deletion DLPrototype/Views/Projects/ProjectView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct ProjectView: View {

@State private var name: String = ""
@State private var colour: String = ""
@State private var colourChanged: Bool = false
@State private var created: Date?
@State private var lastUpdate: Date?
@State private var alive: Bool = true
Expand Down Expand Up @@ -339,6 +340,7 @@ struct ProjectView: View {
let rndColour = Color.randomStorable()
colour = Color.fromStored(rndColour).description.debugDescription
project.colour = rndColour
colourChanged = true

PersistenceController.shared.save()
updater.update()
Expand Down Expand Up @@ -367,7 +369,11 @@ struct ProjectView: View {
project.jobs = []
project.alive = alive
project.lastUpdate = Date()
project.colour = Color.randomStorable()

if colourChanged {
project.colour = Color.randomStorable()
}

lastUpdate = project.lastUpdate!

saveSelectedJobs()
Expand Down
9 changes: 0 additions & 9 deletions DLPrototype/Views/Projects/ProjectsDashboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,6 @@ struct ProjectsDashboard: View {
}
}
.frame(width: 100)

Group {
ZStack(alignment: .leading) {
Theme.headerColour
Text("Alive")
.padding()
}
}
.frame(width: 100)
}
}
.frame(height: 46)
Expand Down
2 changes: 1 addition & 1 deletion DLPrototype/Views/Today/LogTable/LogTableDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ struct LogTableDetails: View {
StatisticWithView(
key: note.title!,
value: note.id!.debugDescription,
colour: Color.fromStored(note.job?.colour ?? Theme.rowColourAsDouble),
colour: Color.fromStored(note.mJob?.colour ?? Theme.rowColourAsDouble),
group: .notes,
view: AnyView(
NavigationLink {
Expand Down

0 comments on commit 0bc8a1b

Please sign in to comment.