Skip to content

Commit ea7d263

Browse files
feat: Configurable filter bar (#468)
1 parent f06d434 commit ea7d263

File tree

6 files changed

+310
-162
lines changed

6 files changed

+310
-162
lines changed

swift-paperless/Localization/Settings.xcstrings

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,6 +1755,17 @@
17551755
}
17561756
}
17571757
},
1758+
"filterConfiguration" : {
1759+
"extractionState" : "manual",
1760+
"localizations" : {
1761+
"en" : {
1762+
"stringUnit" : {
1763+
"state" : "translated",
1764+
"value" : "Document filter configuration"
1765+
}
1766+
}
1767+
}
1768+
},
17581769
"identities" : {
17591770
"extractionState" : "manual",
17601771
"localizations" : {
@@ -2391,6 +2402,17 @@
23912402
}
23922403
}
23932404
},
2405+
"resetFilterConfiguration" : {
2406+
"extractionState" : "manual",
2407+
"localizations" : {
2408+
"en" : {
2409+
"stringUnit" : {
2410+
"state" : "translated",
2411+
"value" : "Reset"
2412+
}
2413+
}
2414+
}
2415+
},
23942416
"selectCertificate" : {
23952417
"extractionState" : "manual",
23962418
"localizations" : {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// FilterBarComponent.swift
3+
// swift-paperless
4+
//
5+
// Created by Paul Gessinger on 15.02.26.
6+
//
7+
8+
import Foundation
9+
10+
enum FilterBarComponent: String, CaseIterable, Codable {
11+
case tags
12+
case documentType
13+
case correspondent
14+
case storagePath
15+
case permissions
16+
case customFields
17+
case asn
18+
case date
19+
20+
var localizedName: LocalizedStringResource {
21+
switch self {
22+
case .tags: .localizable(.tags)
23+
case .documentType: .localizable(.documentType)
24+
case .correspondent: .localizable(.correspondent)
25+
case .storagePath: .localizable(.storagePath)
26+
case .permissions: .localizable(.permissions)
27+
case .customFields: .localizable(.customFields)
28+
case .asn: .localizable(.asn)
29+
case .date: .localizable(.dateFilterTitle)
30+
}
31+
}
32+
}
33+
34+
enum FilterBarConfiguration: Equatable, Codable {
35+
case `default`
36+
case configured([FilterBarComponent])
37+
}

swift-paperless/Utilities/AppSettings.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ enum SettingsKeys: String {
1717
case defaultSearchMode
1818
case defaultSortField
1919
case defaultSortOrder
20+
case filterBarConfiguration
2021

2122
case editingUserInterfaceExperiment
2223

@@ -90,6 +91,10 @@ class AppSettings: ObservableObject {
9091
@PublishedUserDefaultsBacked(.defaultSortOrder)
9192
var defaultSortOrder = DataModel.SortOrder.descending
9293

94+
// @TODO: We need a sentinel here that's just "all defaults"
95+
@PublishedUserDefaultsBacked(.filterBarConfiguration)
96+
var filterBarConfiguration = FilterBarConfiguration.default
97+
9398
enum EditingUserInterface: String, Codable, CaseIterable {
9499
static var allCases: [AppSettings.EditingUserInterface] {
95100
[.automatic, .v3]
@@ -144,6 +149,7 @@ extension AppSettings {
144149
}
145150
}
146151

152+
@available(*, deprecated)
147153
@MainActor
148154
@propertyWrapper
149155
class AppSettingsObject: ObservableObject {
@@ -169,6 +175,7 @@ class AppSettingsObject: ObservableObject {
169175
}
170176
}
171177

178+
@available(*, deprecated)
172179
@MainActor
173180
@propertyWrapper
174181
struct AppSetting<Value: Codable>: DynamicProperty {

0 commit comments

Comments
 (0)