Skip to content

Commit

Permalink
creates a record for the current date when a task is completed
Browse files Browse the repository at this point in the history
  • Loading branch information
aapis committed Jan 13, 2023
1 parent 3dac938 commit 3563965
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
8 changes: 6 additions & 2 deletions DLPrototype.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
53C6D09829654F4C00EA6129 /* DetailGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53C6D09729654F4C00EA6129 /* DetailGroup.swift */; };
53DCA3422803BBBF0032FD60 /* CalendarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53DCA3412803BBBF0032FD60 /* CalendarView.swift */; };
53DFF075296F124E0051DA91 /* ManageTasks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53DFF074296F124E0051DA91 /* ManageTasks.swift */; };
53ECD0572971F8F400A09AAB /* CoreDataRecords.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53ECD0562971F8F400A09AAB /* CoreDataRecords.swift */; };
53EDDF9E29634852008D34C7 /* Entry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53EDDF9D29634852008D34C7 /* Entry.swift */; };
53EDDFA02963487A008D34C7 /* CustomPickerItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53EDDF9F2963487A008D34C7 /* CustomPickerItem.swift */; };
53EDDFA22963502A008D34C7 /* LogRowEmpty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53EDDFA12963502A008D34C7 /* LogRowEmpty.swift */; };
Expand Down Expand Up @@ -165,6 +166,7 @@
53C6D09729654F4C00EA6129 /* DetailGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailGroup.swift; sourceTree = "<group>"; };
53DCA3412803BBBF0032FD60 /* CalendarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarView.swift; sourceTree = "<group>"; };
53DFF074296F124E0051DA91 /* ManageTasks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ManageTasks.swift; sourceTree = "<group>"; };
53ECD0562971F8F400A09AAB /* CoreDataRecords.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreDataRecords.swift; sourceTree = "<group>"; };
53EDDF9D29634852008D34C7 /* Entry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Entry.swift; sourceTree = "<group>"; };
53EDDF9F2963487A008D34C7 /* CustomPickerItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomPickerItem.swift; sourceTree = "<group>"; };
53EDDFA12963502A008D34C7 /* LogRowEmpty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogRowEmpty.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -389,6 +391,7 @@
53F10FDF296E77BE0048D040 /* CoreDataJob.swift */,
53521E53296FBDAE002E7F21 /* CoreDataNoteVersions.swift */,
5361DDEC2971E1DF00437064 /* CoreDataNotes.swift */,
53ECD0562971F8F400A09AAB /* CoreDataRecords.swift */,
);
path = CoreData;
sourceTree = "<group>";
Expand Down Expand Up @@ -634,6 +637,7 @@
53EDDF9E29634852008D34C7 /* Entry.swift in Sources */,
53C6D0912965044C00EA6129 /* DetailsColumn.swift in Sources */,
53218D4A24B7F6EB0088ABE9 /* Home.swift in Sources */,
53ECD0572971F8F400A09AAB /* CoreDataRecords.swift in Sources */,
53EFCE7929637F35004E45EC /* GeneralSettings.swift in Sources */,
5335A5B7296D2089000051B1 /* TaskListView.swift in Sources */,
533AB3F0296C9ED100E91A9F /* ManageNotes.swift in Sources */,
Expand Down Expand Up @@ -864,7 +868,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 58;
CURRENT_PROJECT_VERSION = 59;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"DLPrototype/Preview Content\"";
DEVELOPMENT_TEAM = 6DT7L2N5X6;
Expand All @@ -891,7 +895,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 58;
CURRENT_PROJECT_VERSION = 59;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"DLPrototype/Preview Content\"";
DEVELOPMENT_TEAM = 6DT7L2N5X6;
Expand Down
28 changes: 28 additions & 0 deletions DLPrototype/Models/CoreData/CoreDataRecords.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// CoreDataRecords.swift
// DLPrototype
//
// Created by Ryan Priebe on 2023-01-13.
// Copyright © 2023 YegCollective. All rights reserved.
//

import Foundation
import SwiftUI

public class CoreDataRecords {
public var moc: NSManagedObjectContext?

public init(moc: NSManagedObjectContext?) {
self.moc = moc
}

public func createWithJob(job: Job, date: Date, text: String) -> Void {
let record = LogRecord(context: moc!)
record.timestamp = date
record.message = text
record.id = UUID()
record.job = job

PersistenceController.shared.save()
}
}
12 changes: 11 additions & 1 deletion DLPrototype/Views/Tasks/TaskView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,18 @@ struct TaskView: View {

private func complete() -> Void {
CoreDataTasks(moc: moc).complete(task)
// update viewable status indicators

task.lastUpdate = Date()
CoreDataRecords(moc: moc).createWithJob(
job: task.owner!,
date: task.lastUpdate!,
text: "Completed task: \(task.content ?? "Invalid task")"
)

PersistenceController.shared.save()

withAnimation(.easeInOut(duration: 0.2)) {
// update viewable status indicators
completed = true
updater.update()
}
Expand Down

0 comments on commit 3563965

Please sign in to comment.