-
Notifications
You must be signed in to change notification settings - Fork 121
[POS Orders] Persist sales channel filter in order settings #15891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import Foundation | ||
|
|
||
| /// Used to filter orders by sales channel | ||
| /// | ||
| public enum SalesChannelFilter: String, Codable, Hashable { | ||
| case pointOfSale = "pos-rest-api" | ||
| case any = "any" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,17 +12,20 @@ public struct StoredOrderSettings: Codable, Equatable { | |
| public let dateRangeFilter: OrderDateRangeFilter? | ||
| public let productFilter: FilterOrdersByProduct? | ||
| public let customerFilter: CustomerFilter? | ||
| public let salesChannelFilter: SalesChannelFilter? | ||
|
|
||
| public init(siteID: Int64, | ||
| orderStatusesFilter: [OrderStatusEnum]?, | ||
| dateRangeFilter: OrderDateRangeFilter?, | ||
| productFilter: FilterOrdersByProduct?, | ||
| customerFilter: CustomerFilter?) { | ||
| customerFilter: CustomerFilter?, | ||
| salesChannelFilter: SalesChannelFilter?) { | ||
| self.siteID = siteID | ||
| self.orderStatusesFilter = orderStatusesFilter | ||
| self.dateRangeFilter = dateRangeFilter | ||
| self.productFilter = productFilter | ||
| self.customerFilter = customerFilter | ||
| self.salesChannelFilter = salesChannelFilter | ||
| } | ||
|
|
||
| public func numberOfActiveFilters() -> Int { | ||
|
|
@@ -39,6 +42,9 @@ public struct StoredOrderSettings: Codable, Equatable { | |
| if customerFilter != nil { | ||
| total += 1 | ||
| } | ||
| if let salesChannelFilter = salesChannelFilter, case .pointOfSale = salesChannelFilter { | ||
| total += 1 | ||
| } | ||
|
|
||
| return total | ||
| } | ||
|
|
@@ -51,6 +57,7 @@ public struct StoredOrderSettings: Codable, Equatable { | |
| case dateRangeFilter = "date_range_filter" | ||
| case productFilter = "product_filter" | ||
| case customerFilter = "customer_filter" | ||
| case salesChannelFilter = "sales_channel_filter" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. non-blocking 💭 do you think we might update our naming to match the definition in pfZP8i-c4-p2#comment-158 at some point? If so, we might want to call it
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question, this is something that I thought about when adding it. Since we do not know when we'll need these, or if the terms will change or evolve further before we do, I'd keep with |
||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think this value can be a value for the use case, instead of matching the
created_viavalue in the networking layer. Likeposorpoint_of_salewith the same casing as other order filters likeOrderDateRangeFilter.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I didn't realized we don't need the raw value from the API here, we just case match when creating the query on the
OrderListViewModeland create the predicate we need from there. We actually don't need any raw value at all and can just use the enum case.Let me know if you'd prefer to have some here for a specific case, otherwise I've removed these on 7cdb10b