Skip to content

Commit 1e2dcac

Browse files
committed
Merge branch 'trunk' into feat/WOOMOB-575-separate-pos-tab-visibility
# Conflicts: # Modules/Sources/Experiments/DefaultFeatureFlagService.swift # Modules/Sources/Experiments/FeatureFlag.swift
2 parents f0f976e + e9b8543 commit 1e2dcac

File tree

14 files changed

+1287
-29
lines changed

14 files changed

+1287
-29
lines changed

Modules/Sources/Experiments/DefaultFeatureFlagService.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
9595
return true
9696
case .pointOfSaleAsATabi2:
9797
return buildConfig == .localDeveloper || buildConfig == .alpha
98+
case .pointOfSaleOrdersi1:
99+
return buildConfig == .localDeveloper || buildConfig == .alpha
98100
default:
99101
return true
100102
}

Modules/Sources/Experiments/FeatureFlag.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,8 @@ public enum FeatureFlag: Int {
199199
/// Enables displaying POS as a tab in the tab bar for stores in eligible countries
200200
///
201201
case pointOfSaleAsATabi2
202+
203+
/// Enables displaying Point Of Sale details in order list and order details
204+
///
205+
case pointOfSaleOrdersi1
202206
}

Modules/Sources/Storage/Model/MIGRATIONS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
This file documents changes in the WCiOS Storage data model. Please explain any changes to the data model as well as any custom migrations.
44

5+
## Model 123 (Release 22.8.0.0)
6+
- @iamgabrielma 2025-06-30
7+
- Added `createdVia` attribute to `Order` entity.
8+
59
## Model 122 (Release 22.7.0.0)
610
- @itsmeichigo 2025-06-20
711
- Added `shipmentID` attribute to `ShippingLabel` entity.

Modules/Sources/Storage/Model/Order+CoreDataProperties.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ extension Order {
2020
@NSManaged public var billingPostcode: String?
2121
@NSManaged public var billingState: String?
2222
@NSManaged public var chargeID: String?
23+
@NSManaged public var createdVia: String?
2324
@NSManaged public var currency: String?
2425
@NSManaged public var customerID: Int64
2526
@NSManaged public var customerNote: String?

Modules/Sources/Storage/Resources/WooCommerce.xcdatamodeld/.xccurrentversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
<plist version="1.0">
44
<dict>
55
<key>_XCCurrentVersionName</key>
6-
<string>Model 122.xcdatamodel</string>
6+
<string>Model 123.xcdatamodel</string>
77
</dict>
88
</plist>

Modules/Sources/Storage/Resources/WooCommerce.xcdatamodeld/Model 123.xcdatamodel/contents

Lines changed: 1070 additions & 0 deletions
Large diffs are not rendered by default.

Modules/Tests/StorageTests/CoreData/MigrationTests.swift

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3363,6 +3363,41 @@ final class MigrationTests: XCTestCase {
33633363
let updatedShipmentID = migratedLabel.value(forKey: "shipmentID") as? String
33643364
XCTAssertEqual(updatedShipmentID, id)
33653365
}
3366+
3367+
func test_migrating_from_122_to_123_adds_new_attribute_createdVia_to_order() throws {
3368+
// Given
3369+
let sourceContainer = try startPersistentContainer("Model 122")
3370+
let sourceContext = sourceContainer.viewContext
3371+
3372+
let object = sourceContext.insert(entityName: "Order", properties: [
3373+
"orderID": 123,
3374+
"statusKey": "" // statusKey is a required value, unrelated to this migration
3375+
])
3376+
try sourceContext.save()
3377+
3378+
// `createdVia` should not be present in model 122
3379+
XCTAssertNil(object.entity.attributesByName["createdVia"], "Precondition. Attribute does not exist.")
3380+
3381+
// When
3382+
let targetContainer = try migrate(sourceContainer, to: "Model 123")
3383+
3384+
// Then
3385+
let targetContext = targetContainer.viewContext
3386+
let migratedObject = try XCTUnwrap(targetContext.first(entityName: "Order"))
3387+
3388+
// `createdVia` should be present in model 123
3389+
XCTAssertNotNil(migratedObject.entity.attributesByName["createdVia"])
3390+
3391+
// `createdVia` value should default as nil in model 123
3392+
let value = migratedObject.value(forKey: "createdVia") as? String
3393+
XCTAssertNil(value)
3394+
3395+
// `createdVia` must be settable
3396+
migratedObject.setValue("pos-rest-api", forKey: "createdVia")
3397+
try targetContext.save()
3398+
let updatedValue = migratedObject.value(forKey: "createdVia") as? String
3399+
XCTAssertEqual(updatedValue, "pos-rest-api")
3400+
}
33663401
}
33673402

33683403
// MARK: - Persistent Store Setup and Migrations

RELEASE-NOTES.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
22.8
55
-----
6-
6+
- [*] POS: icon button with confirmation step used for clearing the cart [https://github.com/woocommerce/woocommerce-ios/pull/15829]
77

88
22.7
99
-----
@@ -18,6 +18,7 @@
1818
- [*] POS: Prevent card reader connection success alert flashing when connecting during a payment [https://github.com/woocommerce/woocommerce-ios/pull/15784]
1919
- [**] Shipping Labels: Support UPS extra services [https://github.com/woocommerce/woocommerce-ios/pull/15819, https://github.com/woocommerce/woocommerce-ios/pull/15821]
2020
- [*] Shipping Labels: Pre-fill custom forms with item description, value, and weight [https://github.com/woocommerce/woocommerce-ios/pull/15811]
21+
- [*] Shipping Labels: Pre-fill custom forms with item origin country [https://github.com/woocommerce/woocommerce-ios/pull/15835]
2122
- [internal] POS: Improved scrolling and animation performance by refactoring the shadow implementation and updating the cart and checkout views. [https://github.com/woocommerce/woocommerce-ios/pull/15817]
2223

2324
22.6

WooCommerce/Classes/POS/Presentation/CartView.swift

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct CartView: View {
3232
POSPageHeaderView(title: Localization.cartTitle,
3333
backButtonConfiguration: backButtonConfiguration,
3434
trailingContent: {
35-
DynamicHStack(horizontalAlignment: .trailing, verticalAlignment: .center, spacing: Constants.cartHeaderElementSpacing) {
35+
HStack(spacing: Constants.cartHeaderElementSpacing) {
3636
if let itemsInCartLabel = viewHelper.itemsInCartLabel(for: posModel.cart.purchasableItems.count) {
3737
Text(itemsInCartLabel)
3838
.font(Constants.itemsFont)
@@ -42,13 +42,9 @@ struct CartView: View {
4242
.foregroundColor(Color.posOnSurfaceVariantLowest)
4343
}
4444

45-
Button {
45+
CartClearMenuButton(removeAllItemsFromCart: {
4646
posModel.removeAllItemsFromCart()
47-
ServiceLocator.analytics.track(.pointOfSaleClearCartTapped)
48-
} label: {
49-
Text(Localization.clearButtonTitle)
50-
}
51-
.buttonStyle(POSOutlinedButtonStyle(size: .extraSmall))
47+
})
5248
.renderedIf(shouldShowClearCartButton)
5349
}
5450
})
@@ -137,10 +133,6 @@ private extension CartView {
137133
"pos.cartView.cartTitle",
138134
value: "Cart",
139135
comment: "Title at the header for the Cart view.")
140-
static let clearButtonTitle = NSLocalizedString(
141-
"pos.cartView.clearButtonTitle",
142-
value: "Clear",
143-
comment: "Title for the 'Clear' button to remove all products from the Cart.")
144136
static let addItemsToCartHint = NSLocalizedString(
145137
"pos.cartView.addItemsToCartHint",
146138
value: "Tap on a product to \n add it to the cart",
@@ -221,6 +213,37 @@ private extension CartView {
221213

222214
}
223215

216+
@available(iOS 17.0, *)
217+
private struct CartClearMenuButton: View {
218+
let removeAllItemsFromCart: () -> Void
219+
220+
var body: some View {
221+
Menu {
222+
Button(role: .destructive,
223+
action: {
224+
removeAllItemsFromCart()
225+
ServiceLocator.analytics.track(.pointOfSaleClearCartTapped)
226+
}) {
227+
Text(Localization.clearButtonTitle)
228+
}
229+
230+
} label: {
231+
Image(systemName: "trash")
232+
.font(.posButtonSymbolMedium)
233+
.foregroundStyle(Color.posOnSurface)
234+
.dynamicTypeSize(...POSHeaderLayoutConstants.maximumDynamicTypeSize)
235+
.accessibilityLabel(Localization.clearButtonTitle)
236+
}
237+
}
238+
239+
enum Localization {
240+
static let clearButtonTitle = NSLocalizedString(
241+
"pos.cartView.clearButtonTitle.1",
242+
value: "Clear cart",
243+
comment: "Title for the 'Clear cart' confirmation button to remove all products from the Cart.")
244+
}
245+
}
246+
224247
@available(iOS 17.0, *)
225248
private struct CartScrollViewContent: View {
226249
@Environment(PointOfSaleAggregateModel.self) private var posModel

WooCommerce/Classes/POS/Presentation/Item Selector/ParentProductCardView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ struct ParentProductCardView: View {
4040
.padding(.horizontal, Constants.horizontalTextPadding * (1 / scale))
4141
.padding(.vertical, Constants.verticalTextPadding * (1 / scale))
4242
Spacer()
43+
44+
Image(systemName: "chevron.forward")
45+
.accessibilityHidden(true)
46+
.font(.posButtonSymbolSmall)
47+
.foregroundStyle(Color.posOnSurfaceVariantLowest)
48+
.padding(.horizontal, POSPadding.medium * (1 / scale))
4349
}
4450
.frame(maxWidth: .infinity, idealHeight: dynamicTypeSize.isAccessibilitySize ? nil : dimension)
4551
.background(Constants.backgroundColor)

0 commit comments

Comments
 (0)