-
Notifications
You must be signed in to change notification settings - Fork 121
[POS Orders] Display POS label in order details #15857
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 all commits
9a51370
7d26499
af09aca
5af9ef9
70df74e
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 |
|---|---|---|
|
|
@@ -2,59 +2,6 @@ import UIKit | |
| import Yosemite | ||
| import Gridicons | ||
|
|
||
| /// The ViewModel for `SummaryTableViewCell`. | ||
| /// | ||
| /// TODO This and that cell class should be renamed to be less ambiguous. | ||
| /// | ||
| struct SummaryTableViewCellViewModel { | ||
| fileprivate struct OrderStatusPresentation { | ||
| let style: OrderStatusEnum | ||
| let title: String | ||
| } | ||
|
|
||
| private let billingAddress: Address? | ||
| private let dateCreated: Date | ||
|
|
||
| fileprivate let presentation: OrderStatusPresentation | ||
|
|
||
| private let calendar: Calendar | ||
|
|
||
| init(order: Order, | ||
| status: OrderStatus?, | ||
| calendar: Calendar = .current) { | ||
|
|
||
| billingAddress = order.billingAddress | ||
| dateCreated = order.dateCreated | ||
|
|
||
| presentation = OrderStatusPresentation( | ||
| style: status?.status ?? order.status, | ||
| title: status?.name ?? order.status.rawValue | ||
| ) | ||
|
|
||
| self.calendar = calendar | ||
| } | ||
|
|
||
| /// The full name from the billing address | ||
| /// | ||
| var billedPersonName: String { | ||
| if let fullName = billingAddress?.fullName, fullName.isNotEmpty { | ||
| return fullName | ||
| } else { | ||
| return Localization.guestName | ||
| } | ||
| } | ||
|
|
||
| /// The date, time, and the order number concatenated together. Example, “Jan 22, 2018, 11:23 AM”. | ||
| /// | ||
| var subtitle: String { | ||
| let formatter = DateFormatter.dateAndTimeFormatter | ||
| formatter.timeZone = .siteTimezone | ||
| return formatter.string(from: dateCreated) | ||
| } | ||
| } | ||
|
|
||
| // MARK: - SummaryTableViewCell | ||
| // | ||
| final class SummaryTableViewCell: UITableViewCell { | ||
|
|
||
| /// Label: Title | ||
|
|
@@ -65,6 +12,10 @@ final class SummaryTableViewCell: UITableViewCell { | |
| /// | ||
| @IBOutlet private weak var subtitleLabel: UILabel! | ||
|
|
||
| /// Shows the sales channel if appropiate, at the moment only Point of Sale | ||
| /// | ||
| @IBOutlet private weak var salesChannelLabel: UILabel! | ||
|
|
||
| /// Label: Payment Status | ||
| /// | ||
| @IBOutlet private weak var paymentStatusLabel: PaddedLabel! | ||
|
|
@@ -80,7 +31,8 @@ final class SummaryTableViewCell: UITableViewCell { | |
| func configure(_ viewModel: SummaryTableViewCellViewModel) { | ||
| titleLabel.text = viewModel.billedPersonName | ||
| subtitleLabel.text = viewModel.subtitle | ||
|
|
||
| salesChannelLabel.text = viewModel.formattedSalesChannel | ||
| salesChannelLabel.isHidden = (salesChannelLabel.text == nil) | ||
| display(presentation: viewModel.presentation) | ||
| } | ||
|
|
||
|
|
@@ -91,8 +43,6 @@ final class SummaryTableViewCell: UITableViewCell { | |
| paymentStatusLabel.text = presentation.title | ||
| } | ||
|
|
||
| // MARK: - Overridden Methods | ||
|
|
||
| override func awakeFromNib() { | ||
| super.awakeFromNib() | ||
|
|
||
|
|
@@ -124,9 +74,6 @@ final class SummaryTableViewCell: UITableViewCell { | |
| } | ||
| } | ||
|
|
||
|
|
||
| // MARK: - Private | ||
| // | ||
| private extension SummaryTableViewCell { | ||
|
|
||
| /// Preserves the current Payment BG Color | ||
|
|
@@ -154,6 +101,14 @@ private extension SummaryTableViewCell { | |
| subtitleLabel.accessibilityIdentifier = "summary-table-view-cell-created-label" | ||
| paymentStatusLabel.applyPaddedLabelDefaultStyles() | ||
| paymentStatusLabel.accessibilityIdentifier = "summary-table-view-cell-payment-status-label" | ||
|
|
||
| if ServiceLocator.featureFlagService.isFeatureFlagEnabled(.pointOfSaleOrdersi1) { | ||
| salesChannelLabel.isHidden = false | ||
| salesChannelLabel.applyFootnoteStyle() | ||
| salesChannelLabel.accessibilityIdentifier = "summary-table-view-cell-sales-channel-label" | ||
| } else { | ||
| salesChannelLabel.isHidden = true | ||
| } | ||
| } | ||
|
|
||
| func configureIcon() { | ||
|
|
@@ -169,9 +124,6 @@ private extension SummaryTableViewCell { | |
| } | ||
| } | ||
|
|
||
|
|
||
| // MARK: - VoiceOver | ||
| /// | ||
|
Comment on lines
-172
to
-174
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. nit: any reasons for removing the comments here?
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. Not really, mostly cleaning up since I found them to be not very useful in this case (ie marking as voiceover the only voiceover function, or marking as private a private extension). Other places are way more blatant with this, for example in places like The variable or function name already tells us what we need to know. I'm fine with bringing them back if you'd prefer 👍 |
||
| private extension SummaryTableViewCell { | ||
| func configureIconForVoiceOver() { | ||
| updateStatusButton.accessibilityLabel = NSLocalizedString("Update Order Status", | ||
|
|
@@ -181,12 +133,3 @@ private extension SummaryTableViewCell { | |
| comment: "Accessibility hint for the button to update the order status") | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Localization | ||
|
|
||
| private extension SummaryTableViewCellViewModel { | ||
| enum Localization { | ||
| static let guestName: String = NSLocalizedString("Guest", | ||
| comment: "In Order Details, the name of the billed person when there are no name and last name.") | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import Foundation | ||
| import Yosemite | ||
|
|
||
| struct SummaryTableViewCellViewModel { | ||
| struct OrderStatusPresentation { | ||
| let style: OrderStatusEnum | ||
| let title: String | ||
| } | ||
|
|
||
| private let billingAddress: Address? | ||
| private let dateCreated: Date | ||
| private let salesChannel: String? | ||
|
|
||
| let presentation: OrderStatusPresentation | ||
|
|
||
| private let calendar: Calendar | ||
|
|
||
| init(order: Order, | ||
| status: OrderStatus?, | ||
| calendar: Calendar = .current) { | ||
|
|
||
| billingAddress = order.billingAddress | ||
| dateCreated = order.dateCreated | ||
| salesChannel = order.createdVia | ||
|
|
||
| presentation = OrderStatusPresentation( | ||
| style: status?.status ?? order.status, | ||
| title: status?.name ?? order.status.rawValue | ||
| ) | ||
|
|
||
| self.calendar = calendar | ||
| } | ||
|
|
||
| /// The full name from the billing address | ||
| /// | ||
| var billedPersonName: String { | ||
| if let fullName = billingAddress?.fullName, fullName.isNotEmpty { | ||
| return fullName | ||
| } else { | ||
| return Localization.guestName | ||
| } | ||
| } | ||
|
|
||
| /// The date, time, and the order number concatenated together. Example, “Jan 22, 2018, 11:23 AM”. | ||
| /// | ||
| var subtitle: String { | ||
| let formatter = DateFormatter.dateAndTimeFormatter | ||
| formatter.timeZone = .siteTimezone | ||
| return formatter.string(from: dateCreated) | ||
| } | ||
|
|
||
| /// Textual representation of the sales channel | ||
| /// | ||
| var formattedSalesChannel: String? { | ||
| guard let salesChannel = salesChannel else { | ||
| return nil | ||
| } | ||
| switch salesChannel { | ||
| case "pos-rest-api": | ||
| return "POS" | ||
| default: | ||
| return nil | ||
| } | ||
| } | ||
|
Comment on lines
+54
to
+64
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. This |
||
| } | ||
|
|
||
| private extension SummaryTableViewCellViewModel { | ||
| enum Localization { | ||
| static let guestName: String = NSLocalizedString("SummaryTableViewCellViewModel.guestName", | ||
| value: "Guest", | ||
| comment: "In Order Details, the name of the billed person when there are no name and last name.") | ||
| } | ||
| } | ||
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: might we want to hide the label if the text is nil? since this is in a stack view, if the stack view has a non-zero spacing (from the xib it looks like it has 4px spacing), the spacing still takes up space even if the label has zero width from nil text when it's not hidden.
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.
This fixes the order date not taking up the horizontal space when the sales channel label isn't shown, which is more obvious in large font sizes:
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.
TIL. Thanks for sharing the solution. Updated on 70df74e