Skip to content

Commit 73a42c5

Browse files
committed
Revert legacy customer note & addresses editing from #7532
1 parent 4ea3d06 commit 73a42c5

File tree

4 files changed

+45
-12
lines changed

4 files changed

+45
-12
lines changed

WooCommerce/Classes/ViewModels/Order Details/OrderDetailsDataSource.swift

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -458,12 +458,16 @@ private extension OrderDetailsDataSource {
458458
cell.selectionStyle = .none
459459
if customerNote.isNotEmpty {
460460
cell.body = customerNote.quoted
461+
cell.onEditTapped = { [weak self] in
462+
self?.onCellAction?(.editCustomerNote, nil)
463+
}
461464
} else {
462465
cell.body = nil
466+
cell.onAddTapped = { [weak self] in
467+
self?.onCellAction?(.editCustomerNote, nil)
468+
}
463469
}
464470

465-
cell.onEditTapped = nil
466-
cell.onAddTapped = nil
467471
cell.addButtonTitle = NSLocalizedString("Add Customer Note", comment: "Title for the button to add the Customer Provided Note in Order Details")
468472
cell.editButtonAccessibilityLabel = NSLocalizedString(
469473
"Update Note",
@@ -890,12 +894,16 @@ private extension OrderDetailsDataSource {
890894

891895
if let formattedPostalAddress = shippingAddress?.formattedPostalAddress {
892896
cell.address = formattedPostalAddress
897+
cell.onEditTapped = { [weak self] in
898+
self?.onCellAction?(.editShippingAddress, nil)
899+
}
893900
} else {
894901
cell.address = nil
902+
cell.onAddTapped = { [weak self] in
903+
self?.onCellAction?(.editShippingAddress, nil)
904+
}
895905
}
896906

897-
cell.onEditTapped = nil
898-
cell.onAddTapped = nil
899907
cell.addButtonTitle = NSLocalizedString("Add Shipping Address", comment: "Title for the button to add the Shipping Address in Order Details")
900908
cell.editButtonAccessibilityLabel = NSLocalizedString(
901909
"Update Address",
@@ -1095,12 +1103,17 @@ extension OrderDetailsDataSource {
10951103
var rows: [Row] = []
10961104

10971105
/// Customer Note
1098-
if order.customerNote?.isNotEmpty == true {
1099-
rows.append(.customerNote)
1100-
}
1106+
/// Always visible to allow adding & editing.
1107+
rows.append(.customerNote)
11011108

11021109
/// Shipping Address
1103-
if order.shippingAddress?.isEmpty == false {
1110+
/// Almost always visible to allow editing.
1111+
let orderContainsOnlyVirtualProducts = self.products.filter { (product) -> Bool in
1112+
return items.first(where: { $0.productID == product.productID}) != nil
1113+
}.allSatisfy { $0.virtual == true }
1114+
1115+
1116+
if order.shippingAddress != nil && orderContainsOnlyVirtualProducts == false {
11041117
rows.append(.shippingAddress)
11051118
}
11061119

@@ -1110,9 +1123,8 @@ extension OrderDetailsDataSource {
11101123
}
11111124

11121125
/// Billing Address
1113-
if order.billingAddress?.isEmpty == false {
1114-
rows.append(.billingDetail)
1115-
}
1126+
/// Always visible to allow editing.
1127+
rows.append(.billingDetail)
11161128

11171129
/// Return `nil` if there is no rows to display.
11181130
guard rows.isNotEmpty else {
@@ -1599,6 +1611,8 @@ extension OrderDetailsDataSource {
15991611
case createShippingLabel
16001612
case shippingLabelTrackingMenu(shippingLabel: ShippingLabel, sourceView: UIView)
16011613
case viewAddOns(addOns: [OrderItemAttribute])
1614+
case editCustomerNote
1615+
case editShippingAddress
16021616
}
16031617

16041618
enum Constants {

WooCommerce/Classes/ViewModels/Order Details/OrderDetailsViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ extension OrderDetailsViewModel {
395395
viewController.show(productListVC, sender: nil)
396396
case .billingDetail:
397397
ServiceLocator.analytics.track(.orderDetailShowBillingTapped)
398-
let billingInformationViewController = BillingInformationViewController(order: order, editingEnabled: false)
398+
let billingInformationViewController = BillingInformationViewController(order: order, editingEnabled: true)
399399
viewController.navigationController?.pushViewController(billingInformationViewController, animated: true)
400400
case .customFields:
401401
ServiceLocator.analytics.track(.orderViewCustomFieldsTapped)

WooCommerce/Classes/ViewRelated/Orders/Order Details/Customer Section/CustomerNoteTableViewCell.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ final class CustomerNoteTableViewCell: UITableViewCell {
2929
}
3030
set {
3131
bodyTextView.text = newValue
32+
bodyTextView.isHidden = newValue == nil || newValue?.isEmpty == true
3233
}
3334
}
3435

WooCommerce/Classes/ViewRelated/Orders/Order Details/OrderDetailsViewController.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,10 @@ private extension OrderDetailsViewController {
386386
shippingLabelTrackingMoreMenuTapped(shippingLabel: shippingLabel, sourceView: sourceView)
387387
case let .viewAddOns(addOns):
388388
itemAddOnsButtonTapped(addOns: addOns)
389+
case .editCustomerNote:
390+
editCustomerNoteTapped()
391+
case .editShippingAddress:
392+
editShippingAddressTapped()
389393
}
390394
}
391395

@@ -542,6 +546,20 @@ private extension OrderDetailsViewController {
542546
present(actionSheet, animated: true)
543547
}
544548

549+
func editCustomerNoteTapped() {
550+
let editNoteViewController = EditCustomerNoteHostingController(viewModel: viewModel.editNoteViewModel)
551+
present(editNoteViewController, animated: true)
552+
553+
ServiceLocator.analytics.track(event: WooAnalyticsEvent.OrderDetailsEdit.orderDetailEditFlowStarted(subject: .customerNote))
554+
}
555+
556+
func editShippingAddressTapped() {
557+
let viewModel = EditOrderAddressFormViewModel(order: viewModel.order, type: .shipping)
558+
let editAddressViewController = EditOrderAddressHostingController(viewModel: viewModel)
559+
let navigationController = WooNavigationController(rootViewController: editAddressViewController)
560+
present(navigationController, animated: true, completion: nil)
561+
}
562+
545563
@objc private func collectPaymentTapped() {
546564
collectPayment()
547565

0 commit comments

Comments
 (0)