Skip to content

Commit b525914

Browse files
authored
Merge pull request #40 from aapis/feature/taxonomy-terms
New feature: taxonomy terms
2 parents 8bb7b94 + c40eadf commit b525914

File tree

16 files changed

+504
-78
lines changed

16 files changed

+504
-78
lines changed

KlockWork-iOS/KlockWork-iOS.xcodeproj/project.pbxproj

+18-6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
5387AE892C0143D100EEC581 /* SearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5387AE882C0143D100EEC581 /* SearchBar.swift */; };
3737
538A10312C30FB600028B785 /* ViewMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538A10302C30FB5E0028B785 /* ViewMode.swift */; };
3838
538A10332C31C7D70028B785 /* RowAddButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538A10322C31C7CC0028B785 /* RowAddButton.swift */; };
39+
538A534C2C6FE8DA00711639 /* TermFilter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538A534B2C6FE8D600711639 /* TermFilter.swift */; };
40+
538A53502C6FEA6600711639 /* CoreDataTaxonomyTerms.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538A534F2C6FEA6600711639 /* CoreDataTaxonomyTerms.swift */; };
41+
538A53522C6FF1C400711639 /* TermDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538A53512C6FF1C200711639 /* TermDetail.swift */; };
42+
538A53562C7026B500711639 /* CoreDataTaxonomyTermDefinitions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538A53552C7026B500711639 /* CoreDataTaxonomyTermDefinitions.swift */; };
3943
53911FC52C19E87300B77DAB /* ActivityWeight.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53911FC42C19E87300B77DAB /* ActivityWeight.swift */; };
4044
539134EA2C0269B600B48494 /* PageConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539134E92C0269B600B48494 /* PageConfiguration.swift */; };
4145
539134EC2C02883000B48494 /* PersonDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539134EB2C02883000B48494 /* PersonDetail.swift */; };
@@ -62,7 +66,6 @@
6266
53D4CB7E2BFE93B000AFEDEA /* Planning.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D4CB6D2BFE93B000AFEDEA /* Planning.swift */; };
6367
53D4CB7F2BFE93B000AFEDEA /* Today.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D4CB6E2BFE93B000AFEDEA /* Today.swift */; };
6468
53D4CB802BFE93B000AFEDEA /* CompanyDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D4CB702BFE93B000AFEDEA /* CompanyDetail.swift */; };
65-
53D4CB812BFE93B000AFEDEA /* Item.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D4CB712BFE93B000AFEDEA /* Item.swift */; };
6669
53D4CB822BFE93B000AFEDEA /* JobDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D4CB722BFE93B000AFEDEA /* JobDetail.swift */; };
6770
53D4CB832BFE93B000AFEDEA /* NoteDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D4CB732BFE93B000AFEDEA /* NoteDetail.swift */; };
6871
53D4CB842BFE93B000AFEDEA /* TaskDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D4CB742BFE93B000AFEDEA /* TaskDetail.swift */; };
@@ -148,6 +151,10 @@
148151
5387AE882C0143D100EEC581 /* SearchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchBar.swift; sourceTree = "<group>"; };
149152
538A10302C30FB5E0028B785 /* ViewMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewMode.swift; sourceTree = "<group>"; };
150153
538A10322C31C7CC0028B785 /* RowAddButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RowAddButton.swift; sourceTree = "<group>"; };
154+
538A534B2C6FE8D600711639 /* TermFilter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TermFilter.swift; sourceTree = "<group>"; };
155+
538A534F2C6FEA6600711639 /* CoreDataTaxonomyTerms.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = CoreDataTaxonomyTerms.swift; path = ../../DLPrototype/DLPrototype/Models/CoreData/CoreDataTaxonomyTerms.swift; sourceTree = "<group>"; };
156+
538A53512C6FF1C200711639 /* TermDetail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TermDetail.swift; sourceTree = "<group>"; };
157+
538A53552C7026B500711639 /* CoreDataTaxonomyTermDefinitions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = CoreDataTaxonomyTermDefinitions.swift; path = ../../DLPrototype/DLPrototype/Models/CoreData/CoreDataTaxonomyTermDefinitions.swift; sourceTree = "<group>"; };
151158
53911FC42C19E87300B77DAB /* ActivityWeight.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ActivityWeight.swift; path = ../../DLPrototype/DLPrototype/Enums/ActivityWeight.swift; sourceTree = "<group>"; };
152159
539134E92C0269B600B48494 /* PageConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageConfiguration.swift; sourceTree = "<group>"; };
153160
539134EB2C02883000B48494 /* PersonDetail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersonDetail.swift; sourceTree = "<group>"; };
@@ -176,7 +183,6 @@
176183
53D4CB6D2BFE93B000AFEDEA /* Planning.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Planning.swift; sourceTree = "<group>"; };
177184
53D4CB6E2BFE93B000AFEDEA /* Today.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Today.swift; sourceTree = "<group>"; };
178185
53D4CB702BFE93B000AFEDEA /* CompanyDetail.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CompanyDetail.swift; sourceTree = "<group>"; };
179-
53D4CB712BFE93B000AFEDEA /* Item.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Item.swift; sourceTree = "<group>"; };
180186
53D4CB722BFE93B000AFEDEA /* JobDetail.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JobDetail.swift; sourceTree = "<group>"; };
181187
53D4CB732BFE93B000AFEDEA /* NoteDetail.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoteDetail.swift; sourceTree = "<group>"; };
182188
53D4CB742BFE93B000AFEDEA /* TaskDetail.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TaskDetail.swift; sourceTree = "<group>"; };
@@ -335,6 +341,7 @@
335341
53C059B92C33BCB20066111C /* Filter */ = {
336342
isa = PBXGroup;
337343
children = (
344+
538A534B2C6FE8D600711639 /* TermFilter.swift */,
338345
53C059B72C33BCAA0066111C /* RecordFilter.swift */,
339346
);
340347
path = Filter;
@@ -343,6 +350,8 @@
343350
53D4CB4A2BFE930100AFEDEA = {
344351
isa = PBXGroup;
345352
children = (
353+
538A53552C7026B500711639 /* CoreDataTaxonomyTermDefinitions.swift */,
354+
538A534F2C6FEA6600711639 /* CoreDataTaxonomyTerms.swift */,
346355
53911FC42C19E87300B77DAB /* ActivityWeight.swift */,
347356
5311F4052C17C66900FB3071 /* CDAssessmentThreshold.swift */,
348357
53E3A26A2C098A50004A85C3 /* CDAssessmentFactor.swift */,
@@ -432,8 +441,8 @@
432441
53D4CB752BFE93B000AFEDEA /* Detail */ = {
433442
isa = PBXGroup;
434443
children = (
444+
538A53512C6FF1C200711639 /* TermDetail.swift */,
435445
53D4CB702BFE93B000AFEDEA /* CompanyDetail.swift */,
436-
53D4CB712BFE93B000AFEDEA /* Item.swift */,
437446
53D4CB722BFE93B000AFEDEA /* JobDetail.swift */,
438447
53D4CB732BFE93B000AFEDEA /* NoteDetail.swift */,
439448
53D4CB742BFE93B000AFEDEA /* TaskDetail.swift */,
@@ -583,6 +592,8 @@
583592
isa = PBXSourcesBuildPhase;
584593
buildActionMask = 2147483647;
585594
files = (
595+
538A53562C7026B500711639 /* CoreDataTaxonomyTermDefinitions.swift in Sources */,
596+
538A53502C6FEA6600711639 /* CoreDataTaxonomyTerms.swift in Sources */,
586597
53911FC52C19E87300B77DAB /* ActivityWeight.swift in Sources */,
587598
5311F4062C17C66900FB3071 /* CDAssessmentThreshold.swift in Sources */,
588599
53E3A26B2C098A50004A85C3 /* CDAssessmentFactor.swift in Sources */,
@@ -612,6 +623,7 @@
612623
53F926322BFEA00E00948076 /* String.swift in Sources */,
613624
53F926062BFE9BF300948076 /* CoreDataCalendarEvent.swift in Sources */,
614625
53F926072BFE9BF300948076 /* CoreDataCompanies.swift in Sources */,
626+
538A53522C6FF1C400711639 /* TermDetail.swift in Sources */,
615627
539134EC2C02883000B48494 /* PersonDetail.swift in Sources */,
616628
53F926082BFE9BF300948076 /* CoreDataJob.swift in Sources */,
617629
532441662C04428700659F14 /* Titlebar.swift in Sources */,
@@ -673,11 +685,11 @@
673685
53D4CB842BFE93B000AFEDEA /* TaskDetail.swift in Sources */,
674686
53E50C172C0E619C00A85FDC /* OverviewWidget.swift in Sources */,
675687
53D4CB862BFE93B000AFEDEA /* Jobs.swift in Sources */,
676-
53D4CB812BFE93B000AFEDEA /* Item.swift in Sources */,
677688
53D4CB7D2BFE93B000AFEDEA /* Explore.swift in Sources */,
678689
53E50C192C0E61DB00A85FDC /* Legend.swift in Sources */,
679690
539134EE2C028F6900B48494 /* ProjectDetail.swift in Sources */,
680691
539134F82C039F3100B48494 /* Records.swift in Sources */,
692+
538A534C2C6FE8DA00711639 /* TermFilter.swift in Sources */,
681693
53E6974C2C23ABA7005A7375 /* CompanySelector.swift in Sources */,
682694
537582CC2BFFD70D00CB528C /* RecordDetail.swift in Sources */,
683695
5311F3F92C1794FD00FB3071 /* PageActionBar.Planning.swift in Sources */,
@@ -817,7 +829,7 @@
817829
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
818830
CODE_SIGN_ENTITLEMENTS = "KlockWork-iOS/KlockWork_iOS.entitlements";
819831
CODE_SIGN_STYLE = Automatic;
820-
CURRENT_PROJECT_VERSION = 17;
832+
CURRENT_PROJECT_VERSION = 18;
821833
DEAD_CODE_STRIPPING = YES;
822834
DEVELOPMENT_ASSET_PATHS = "\"KlockWork-iOS/Preview Content\"";
823835
DEVELOPMENT_TEAM = 6DT7L2N5X6;
@@ -859,7 +871,7 @@
859871
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
860872
CODE_SIGN_ENTITLEMENTS = "KlockWork-iOS/KlockWork_iOS.entitlements";
861873
CODE_SIGN_STYLE = Automatic;
862-
CURRENT_PROJECT_VERSION = 17;
874+
CURRENT_PROJECT_VERSION = 18;
863875
DEAD_CODE_STRIPPING = YES;
864876
DEVELOPMENT_ASSET_PATHS = "\"KlockWork-iOS/Preview Content\"";
865877
DEVELOPMENT_TEAM = 6DT7L2N5X6;

KlockWork-iOS/KlockWork-iOS/Entities/Companies.swift

+1-19
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@ struct Companies: View {
3434
Text(item.name!)
3535
}
3636
}
37-
.onDelete(perform: deleteItems)
3837
.listRowBackground(Theme.textBackground)
3938
} else {
40-
Button(action: addItem) {
39+
Button(action: {}) {
4140
Text("No companies found. Create one!")
4241
}
4342
.listRowBackground(Theme.textBackground)
@@ -64,20 +63,3 @@ struct Companies: View {
6463
}
6564
}
6665
}
67-
68-
extension Companies {
69-
private func addItem() {
70-
withAnimation {
71-
let newItem = Item(timestamp: Date())
72-
// modelContext.insert(newItem)
73-
}
74-
}
75-
76-
private func deleteItems(offsets: IndexSet) {
77-
withAnimation {
78-
for index in offsets {
79-
// modelContext.delete(items[index])
80-
}
81-
}
82-
}
83-
}

KlockWork-iOS/KlockWork-iOS/Entities/Detail/Item.swift

-19
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
//
2+
// TermDetail.swift
3+
// KlockWork-iOS
4+
//
5+
// Created by Ryan Priebe on 2024-08-16.
6+
//
7+
8+
import SwiftUI
9+
10+
struct TermDetail: View {
11+
typealias DefinitionLink = Tabs.Content.Individual.SingleJobLink
12+
13+
@EnvironmentObject private var state: AppState
14+
@Environment(\.dismiss) private var dismiss
15+
public var term: TaxonomyTerm?
16+
@State private var created: Date = Date()
17+
@State private var name: String = ""
18+
@State private var definitions: [TaxonomyTermDefinitions] = []
19+
@State private var alive: Bool = false
20+
@State private var isSaveAlertPresented: Bool = false
21+
@State private var isDeleteAlertPresented: Bool = false
22+
public var page: PageConfiguration.AppPage = .create
23+
24+
var body: some View {
25+
VStack {
26+
List {
27+
Section("Term") {
28+
TextField("Name", text: $name, axis: .vertical)
29+
}
30+
.listRowBackground(Theme.textBackground)
31+
32+
Section("Definitions") {
33+
ForEach(self.definitions, id: \TaxonomyTermDefinitions.objectID) { definition in
34+
if definition.job != nil {
35+
DefinitionLink(job: definition.job!)
36+
}
37+
}
38+
}
39+
.listRowBackground(Theme.textBackground)
40+
41+
Section("Settings") {
42+
Toggle("Published", isOn: $alive)
43+
DatePicker(
44+
"Created",
45+
selection: $created,
46+
displayedComponents: [.date, .hourAndMinute]
47+
)
48+
// @TODO: implement JobPicker as a sheet
49+
}
50+
.listRowBackground(Theme.textBackground)
51+
52+
if self.term != nil {
53+
Button("Delete Term", role: .destructive, action: self.actionInitiateDelete)
54+
.alert("Are you sure?", isPresented: $isDeleteAlertPresented) {
55+
Button("Yes", role: .destructive) {
56+
self.actionOnDelete()
57+
}
58+
} message: {
59+
Text("This term will be permanently deleted.")
60+
}
61+
.listRowBackground(Color.red)
62+
.foregroundStyle(.white)
63+
}
64+
}
65+
Spacer()
66+
}
67+
.background(self.page.primaryColour)
68+
.onAppear(perform: actionOnAppear)
69+
.toolbarBackground(Theme.textBackground.opacity(0.7), for: .navigationBar)
70+
.toolbarBackground(.visible, for: .navigationBar)
71+
.scrollContentBackground(.hidden)
72+
.toolbar {
73+
ToolbarItem(placement: .topBarTrailing) {
74+
// Creates new entity on tap, then sends user back to Today
75+
Button {
76+
self.actionOnSave()
77+
} label: {
78+
Text("Save")
79+
}
80+
.foregroundStyle(self.state.theme.tint)
81+
.alert("Saved", isPresented: $isSaveAlertPresented) {
82+
Button("OK") {
83+
dismiss()
84+
}
85+
} message: {
86+
Text("It is done.")
87+
}
88+
}
89+
}
90+
}
91+
}
92+
93+
extension TermDetail {
94+
/// Onload handler. Sets timestamp and message fields.
95+
/// - Returns: Void
96+
private func actionOnAppear() -> Void {
97+
if self.term != nil {
98+
if let tmstmp = self.term!.created {
99+
self.created = tmstmp
100+
}
101+
102+
if let name = self.term!.name {
103+
self.name = name
104+
}
105+
106+
if let def = self.term!.definitions {
107+
self.definitions = def.allObjects as! [TaxonomyTermDefinitions]
108+
}
109+
110+
self.alive = self.term!.alive
111+
}
112+
}
113+
114+
/// Save handler
115+
/// - Returns: Void
116+
private func actionOnSave() -> Void {
117+
if self.term != nil {
118+
self.term!.name = self.name
119+
// self.term!.definitions = self.definition
120+
self.term!.alive = self.alive
121+
} else {
122+
// CoreDataTaxonomyTerms(moc: self.state.moc).create(
123+
// message: self.message,
124+
// timestamp: self.timestamp,
125+
// job: self.job,
126+
// saveByDefault: false
127+
// )
128+
}
129+
130+
isSaveAlertPresented.toggle()
131+
PersistenceController.shared.save()
132+
}
133+
134+
/// Soft delete a Task
135+
/// - Returns: Void
136+
private func actionOnDelete() -> Void {
137+
if self.term != nil {
138+
self.state.moc.delete(self.term!)
139+
}
140+
141+
PersistenceController.shared.save()
142+
dismiss()
143+
}
144+
145+
/// Opens the delete object alert
146+
/// - Returns: Void
147+
private func actionInitiateDelete() -> Void {
148+
self.isDeleteAlertPresented.toggle()
149+
}
150+
}

0 commit comments

Comments
 (0)