Skip to content

Commit

Permalink
Merge pull request #83 from aapis/bugfix/find-view
Browse files Browse the repository at this point in the history
A couple bug fixes in Find
  • Loading branch information
aapis authored Feb 11, 2023
2 parents 1b56126 + 8a0de69 commit b9d9ff1
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 14 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 = 74;
CURRENT_PROJECT_VERSION = 75;
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 = 74;
CURRENT_PROJECT_VERSION = 75;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"DLPrototype/Preview Content\"";
DEVELOPMENT_TEAM = 6DT7L2N5X6;
Expand Down
8 changes: 6 additions & 2 deletions DLPrototype/Views/Find/Results/JobResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ struct JobResult: View {
Theme.subHeaderColour

HStack {
Text("\(bucket.count) Jobs")
if bucket.count > 1 {
Text("\(bucket.count) Jobs")
} else {
Text("1 Job")
}

Spacer()
FancyButton(text: "Open", action: minimize, icon: minimizeIcon, transparent: true, showLabel: false)
Expand Down Expand Up @@ -62,7 +66,7 @@ struct JobResult: View {
ScrollView {
VStack(spacing: 1) {
ForEach(0..<bucket.count) { i in
if i <= bucket.count {
if i < bucket.count {
let item = bucket[i + offset]

JobRow(job: item, colour: Color.fromStored(item.colour ?? Theme.rowColourAsDouble))
Expand Down
8 changes: 6 additions & 2 deletions DLPrototype/Views/Find/Results/NoteResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ struct NoteResult: View {
Theme.subHeaderColour

HStack {
Text("\(bucket.count) Notes")
if bucket.count > 1 {
Text("\(bucket.count) Notes")
} else {
Text("1 Note")
}

Spacer()
FancyButton(text: "Open", action: minimize, icon: minimizeIcon, transparent: true, showLabel: false)
Expand Down Expand Up @@ -60,7 +64,7 @@ struct NoteResult: View {
ScrollView {
VStack(spacing: 1) {
ForEach(0..<bucket.count) { i in
if i <= bucket.count {
if i < bucket.count {
let item = bucket[i + offset]

NoteRow(note: item)
Expand Down
8 changes: 6 additions & 2 deletions DLPrototype/Views/Find/Results/ProjectResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ struct ProjectResult: View {
Theme.subHeaderColour

HStack {
Text("\(bucket.count) Projects")
if bucket.count > 1 {
Text("\(bucket.count) Projects")
} else {
Text("1 Project")
}

Spacer()
FancyButton(text: "Open", action: minimize, icon: minimizeIcon, transparent: true, showLabel: false)
Expand Down Expand Up @@ -62,7 +66,7 @@ struct ProjectResult: View {
ScrollView {
VStack(spacing: 1) {
ForEach(0..<bucket.count) { i in
if i <= bucket.count {
if i < bucket.count {
let item = bucket[i + offset]

ProjectRow(project: item)
Expand Down
9 changes: 6 additions & 3 deletions DLPrototype/Views/Find/Results/RecordResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ struct RecordResult: View {
Theme.subHeaderColour

HStack {
Text("\(bucket.count) Records")
if bucket.count > 1 {
Text("\(bucket.count) Records")
} else {
Text("1 Record")
}

Spacer()
FancyButton(text: "Open", action: minimize, icon: minimizeIcon, transparent: true, showLabel: false)
Expand Down Expand Up @@ -60,7 +64,7 @@ struct RecordResult: View {
ScrollView {
VStack(spacing: 1) {
ForEach(0..<maxPerPage) { i in
if i <= bucket.count {
if i < bucket.count {
let item = bucket[i + offset]
let entry = Entry(
timestamp: item.timestamp!,
Expand Down Expand Up @@ -149,7 +153,6 @@ struct RecordResult: View {

private func showPage(_ index: Int) -> Void {
page = (index + 1)
// offset = (bucket.count > maxPerPage ? index * maxPerPage : page)
offset = index * maxPerPage
}
}
2 changes: 1 addition & 1 deletion DLPrototype/Views/Find/Results/Results.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ struct Results: View {

// fetch all jobs where the URI matches $text
let jr: NSFetchRequest<Job> = Job.fetchRequest()
jr.predicate = NSPredicate(format: "uri CONTAINS[c] %@", text.wrappedValue)
jr.predicate = NSPredicate(format: "uri CONTAINS[c] %@ OR jid.string CONTAINS[c] %@", text.wrappedValue, text.wrappedValue)
jr.sortDescriptors = [
NSSortDescriptor(keyPath: \Job.jid, ascending: false)
]
Expand Down
8 changes: 6 additions & 2 deletions DLPrototype/Views/Find/Results/TaskResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ struct TaskResult: View {
Theme.subHeaderColour

HStack {
Text("\(bucket.count) Tasks")
if bucket.count > 1 {
Text("\(bucket.count) Tasks")
} else {
Text("1 Task")
}

Spacer()
FancyButton(text: "Open", action: minimize, icon: minimizeIcon, transparent: true, showLabel: false)
Expand Down Expand Up @@ -60,7 +64,7 @@ struct TaskResult: View {
ScrollView {
VStack(spacing: 1) {
ForEach(0..<bucket.count) { i in
if i <= bucket.count {
if i < bucket.count {
let item = bucket[i + offset]

TaskView(task: item, showJobId: true, showCreated: true, showUpdated: true, showCompleted: true, colourizeRow: true)
Expand Down

0 comments on commit b9d9ff1

Please sign in to comment.