Skip to content

Commit

Permalink
Merge pull request #40 from aapis/feature/taxonomy-terms
Browse files Browse the repository at this point in the history
New feature: taxonomy terms
  • Loading branch information
aapis authored Aug 17, 2024
2 parents 8bb7b94 + c40eadf commit b525914
Show file tree
Hide file tree
Showing 16 changed files with 504 additions and 78 deletions.
24 changes: 18 additions & 6 deletions KlockWork-iOS/KlockWork-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
5387AE892C0143D100EEC581 /* SearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5387AE882C0143D100EEC581 /* SearchBar.swift */; };
538A10312C30FB600028B785 /* ViewMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538A10302C30FB5E0028B785 /* ViewMode.swift */; };
538A10332C31C7D70028B785 /* RowAddButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538A10322C31C7CC0028B785 /* RowAddButton.swift */; };
538A534C2C6FE8DA00711639 /* TermFilter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538A534B2C6FE8D600711639 /* TermFilter.swift */; };
538A53502C6FEA6600711639 /* CoreDataTaxonomyTerms.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538A534F2C6FEA6600711639 /* CoreDataTaxonomyTerms.swift */; };
538A53522C6FF1C400711639 /* TermDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538A53512C6FF1C200711639 /* TermDetail.swift */; };
538A53562C7026B500711639 /* CoreDataTaxonomyTermDefinitions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538A53552C7026B500711639 /* CoreDataTaxonomyTermDefinitions.swift */; };
53911FC52C19E87300B77DAB /* ActivityWeight.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53911FC42C19E87300B77DAB /* ActivityWeight.swift */; };
539134EA2C0269B600B48494 /* PageConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539134E92C0269B600B48494 /* PageConfiguration.swift */; };
539134EC2C02883000B48494 /* PersonDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539134EB2C02883000B48494 /* PersonDetail.swift */; };
Expand All @@ -62,7 +66,6 @@
53D4CB7E2BFE93B000AFEDEA /* Planning.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D4CB6D2BFE93B000AFEDEA /* Planning.swift */; };
53D4CB7F2BFE93B000AFEDEA /* Today.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D4CB6E2BFE93B000AFEDEA /* Today.swift */; };
53D4CB802BFE93B000AFEDEA /* CompanyDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D4CB702BFE93B000AFEDEA /* CompanyDetail.swift */; };
53D4CB812BFE93B000AFEDEA /* Item.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D4CB712BFE93B000AFEDEA /* Item.swift */; };
53D4CB822BFE93B000AFEDEA /* JobDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D4CB722BFE93B000AFEDEA /* JobDetail.swift */; };
53D4CB832BFE93B000AFEDEA /* NoteDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D4CB732BFE93B000AFEDEA /* NoteDetail.swift */; };
53D4CB842BFE93B000AFEDEA /* TaskDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D4CB742BFE93B000AFEDEA /* TaskDetail.swift */; };
Expand Down Expand Up @@ -148,6 +151,10 @@
5387AE882C0143D100EEC581 /* SearchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchBar.swift; sourceTree = "<group>"; };
538A10302C30FB5E0028B785 /* ViewMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewMode.swift; sourceTree = "<group>"; };
538A10322C31C7CC0028B785 /* RowAddButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RowAddButton.swift; sourceTree = "<group>"; };
538A534B2C6FE8D600711639 /* TermFilter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TermFilter.swift; sourceTree = "<group>"; };
538A534F2C6FEA6600711639 /* CoreDataTaxonomyTerms.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = CoreDataTaxonomyTerms.swift; path = ../../DLPrototype/DLPrototype/Models/CoreData/CoreDataTaxonomyTerms.swift; sourceTree = "<group>"; };
538A53512C6FF1C200711639 /* TermDetail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TermDetail.swift; sourceTree = "<group>"; };
538A53552C7026B500711639 /* CoreDataTaxonomyTermDefinitions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = CoreDataTaxonomyTermDefinitions.swift; path = ../../DLPrototype/DLPrototype/Models/CoreData/CoreDataTaxonomyTermDefinitions.swift; sourceTree = "<group>"; };
53911FC42C19E87300B77DAB /* ActivityWeight.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ActivityWeight.swift; path = ../../DLPrototype/DLPrototype/Enums/ActivityWeight.swift; sourceTree = "<group>"; };
539134E92C0269B600B48494 /* PageConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageConfiguration.swift; sourceTree = "<group>"; };
539134EB2C02883000B48494 /* PersonDetail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersonDetail.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -176,7 +183,6 @@
53D4CB6D2BFE93B000AFEDEA /* Planning.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Planning.swift; sourceTree = "<group>"; };
53D4CB6E2BFE93B000AFEDEA /* Today.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Today.swift; sourceTree = "<group>"; };
53D4CB702BFE93B000AFEDEA /* CompanyDetail.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CompanyDetail.swift; sourceTree = "<group>"; };
53D4CB712BFE93B000AFEDEA /* Item.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Item.swift; sourceTree = "<group>"; };
53D4CB722BFE93B000AFEDEA /* JobDetail.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JobDetail.swift; sourceTree = "<group>"; };
53D4CB732BFE93B000AFEDEA /* NoteDetail.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoteDetail.swift; sourceTree = "<group>"; };
53D4CB742BFE93B000AFEDEA /* TaskDetail.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TaskDetail.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -335,6 +341,7 @@
53C059B92C33BCB20066111C /* Filter */ = {
isa = PBXGroup;
children = (
538A534B2C6FE8D600711639 /* TermFilter.swift */,
53C059B72C33BCAA0066111C /* RecordFilter.swift */,
);
path = Filter;
Expand All @@ -343,6 +350,8 @@
53D4CB4A2BFE930100AFEDEA = {
isa = PBXGroup;
children = (
538A53552C7026B500711639 /* CoreDataTaxonomyTermDefinitions.swift */,
538A534F2C6FEA6600711639 /* CoreDataTaxonomyTerms.swift */,
53911FC42C19E87300B77DAB /* ActivityWeight.swift */,
5311F4052C17C66900FB3071 /* CDAssessmentThreshold.swift */,
53E3A26A2C098A50004A85C3 /* CDAssessmentFactor.swift */,
Expand Down Expand Up @@ -432,8 +441,8 @@
53D4CB752BFE93B000AFEDEA /* Detail */ = {
isa = PBXGroup;
children = (
538A53512C6FF1C200711639 /* TermDetail.swift */,
53D4CB702BFE93B000AFEDEA /* CompanyDetail.swift */,
53D4CB712BFE93B000AFEDEA /* Item.swift */,
53D4CB722BFE93B000AFEDEA /* JobDetail.swift */,
53D4CB732BFE93B000AFEDEA /* NoteDetail.swift */,
53D4CB742BFE93B000AFEDEA /* TaskDetail.swift */,
Expand Down Expand Up @@ -583,6 +592,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
538A53562C7026B500711639 /* CoreDataTaxonomyTermDefinitions.swift in Sources */,
538A53502C6FEA6600711639 /* CoreDataTaxonomyTerms.swift in Sources */,
53911FC52C19E87300B77DAB /* ActivityWeight.swift in Sources */,
5311F4062C17C66900FB3071 /* CDAssessmentThreshold.swift in Sources */,
53E3A26B2C098A50004A85C3 /* CDAssessmentFactor.swift in Sources */,
Expand Down Expand Up @@ -612,6 +623,7 @@
53F926322BFEA00E00948076 /* String.swift in Sources */,
53F926062BFE9BF300948076 /* CoreDataCalendarEvent.swift in Sources */,
53F926072BFE9BF300948076 /* CoreDataCompanies.swift in Sources */,
538A53522C6FF1C400711639 /* TermDetail.swift in Sources */,
539134EC2C02883000B48494 /* PersonDetail.swift in Sources */,
53F926082BFE9BF300948076 /* CoreDataJob.swift in Sources */,
532441662C04428700659F14 /* Titlebar.swift in Sources */,
Expand Down Expand Up @@ -673,11 +685,11 @@
53D4CB842BFE93B000AFEDEA /* TaskDetail.swift in Sources */,
53E50C172C0E619C00A85FDC /* OverviewWidget.swift in Sources */,
53D4CB862BFE93B000AFEDEA /* Jobs.swift in Sources */,
53D4CB812BFE93B000AFEDEA /* Item.swift in Sources */,
53D4CB7D2BFE93B000AFEDEA /* Explore.swift in Sources */,
53E50C192C0E61DB00A85FDC /* Legend.swift in Sources */,
539134EE2C028F6900B48494 /* ProjectDetail.swift in Sources */,
539134F82C039F3100B48494 /* Records.swift in Sources */,
538A534C2C6FE8DA00711639 /* TermFilter.swift in Sources */,
53E6974C2C23ABA7005A7375 /* CompanySelector.swift in Sources */,
537582CC2BFFD70D00CB528C /* RecordDetail.swift in Sources */,
5311F3F92C1794FD00FB3071 /* PageActionBar.Planning.swift in Sources */,
Expand Down Expand Up @@ -817,7 +829,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "KlockWork-iOS/KlockWork_iOS.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 17;
CURRENT_PROJECT_VERSION = 18;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"KlockWork-iOS/Preview Content\"";
DEVELOPMENT_TEAM = 6DT7L2N5X6;
Expand Down Expand Up @@ -859,7 +871,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "KlockWork-iOS/KlockWork_iOS.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 17;
CURRENT_PROJECT_VERSION = 18;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"KlockWork-iOS/Preview Content\"";
DEVELOPMENT_TEAM = 6DT7L2N5X6;
Expand Down
20 changes: 1 addition & 19 deletions KlockWork-iOS/KlockWork-iOS/Entities/Companies.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ struct Companies: View {
Text(item.name!)
}
}
.onDelete(perform: deleteItems)
.listRowBackground(Theme.textBackground)
} else {
Button(action: addItem) {
Button(action: {}) {
Text("No companies found. Create one!")
}
.listRowBackground(Theme.textBackground)
Expand All @@ -64,20 +63,3 @@ struct Companies: View {
}
}
}

extension Companies {
private func addItem() {
withAnimation {
let newItem = Item(timestamp: Date())
// modelContext.insert(newItem)
}
}

private func deleteItems(offsets: IndexSet) {
withAnimation {
for index in offsets {
// modelContext.delete(items[index])
}
}
}
}
19 changes: 0 additions & 19 deletions KlockWork-iOS/KlockWork-iOS/Entities/Detail/Item.swift

This file was deleted.

150 changes: 150 additions & 0 deletions KlockWork-iOS/KlockWork-iOS/Entities/Detail/TermDetail.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
//
// TermDetail.swift
// KlockWork-iOS
//
// Created by Ryan Priebe on 2024-08-16.
//

import SwiftUI

struct TermDetail: View {
typealias DefinitionLink = Tabs.Content.Individual.SingleJobLink

@EnvironmentObject private var state: AppState
@Environment(\.dismiss) private var dismiss
public var term: TaxonomyTerm?
@State private var created: Date = Date()
@State private var name: String = ""
@State private var definitions: [TaxonomyTermDefinitions] = []
@State private var alive: Bool = false
@State private var isSaveAlertPresented: Bool = false
@State private var isDeleteAlertPresented: Bool = false
public var page: PageConfiguration.AppPage = .create

var body: some View {
VStack {
List {
Section("Term") {
TextField("Name", text: $name, axis: .vertical)
}
.listRowBackground(Theme.textBackground)

Section("Definitions") {
ForEach(self.definitions, id: \TaxonomyTermDefinitions.objectID) { definition in
if definition.job != nil {
DefinitionLink(job: definition.job!)
}
}
}
.listRowBackground(Theme.textBackground)

Section("Settings") {
Toggle("Published", isOn: $alive)
DatePicker(
"Created",
selection: $created,
displayedComponents: [.date, .hourAndMinute]
)
// @TODO: implement JobPicker as a sheet
}
.listRowBackground(Theme.textBackground)

if self.term != nil {
Button("Delete Term", role: .destructive, action: self.actionInitiateDelete)
.alert("Are you sure?", isPresented: $isDeleteAlertPresented) {
Button("Yes", role: .destructive) {
self.actionOnDelete()
}
} message: {
Text("This term will be permanently deleted.")
}
.listRowBackground(Color.red)
.foregroundStyle(.white)
}
}
Spacer()
}
.background(self.page.primaryColour)
.onAppear(perform: actionOnAppear)
.toolbarBackground(Theme.textBackground.opacity(0.7), for: .navigationBar)
.toolbarBackground(.visible, for: .navigationBar)
.scrollContentBackground(.hidden)
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
// Creates new entity on tap, then sends user back to Today
Button {
self.actionOnSave()
} label: {
Text("Save")
}
.foregroundStyle(self.state.theme.tint)
.alert("Saved", isPresented: $isSaveAlertPresented) {
Button("OK") {
dismiss()
}
} message: {
Text("It is done.")
}
}
}
}
}

extension TermDetail {
/// Onload handler. Sets timestamp and message fields.
/// - Returns: Void
private func actionOnAppear() -> Void {
if self.term != nil {
if let tmstmp = self.term!.created {
self.created = tmstmp
}

if let name = self.term!.name {
self.name = name
}

if let def = self.term!.definitions {
self.definitions = def.allObjects as! [TaxonomyTermDefinitions]
}

self.alive = self.term!.alive
}
}

/// Save handler
/// - Returns: Void
private func actionOnSave() -> Void {
if self.term != nil {
self.term!.name = self.name
// self.term!.definitions = self.definition
self.term!.alive = self.alive
} else {
// CoreDataTaxonomyTerms(moc: self.state.moc).create(
// message: self.message,
// timestamp: self.timestamp,
// job: self.job,
// saveByDefault: false
// )
}

isSaveAlertPresented.toggle()
PersistenceController.shared.save()
}

/// Soft delete a Task
/// - Returns: Void
private func actionOnDelete() -> Void {
if self.term != nil {
self.state.moc.delete(self.term!)
}

PersistenceController.shared.save()
dismiss()
}

/// Opens the delete object alert
/// - Returns: Void
private func actionInitiateDelete() -> Void {
self.isDeleteAlertPresented.toggle()
}
}
Loading

0 comments on commit b525914

Please sign in to comment.