Skip to content

Commit 2a2fab2

Browse files
committed
Add simplified ghost rows
1 parent 91194ec commit 2a2fab2

File tree

2 files changed

+33
-65
lines changed

2 files changed

+33
-65
lines changed

WooCommerce/Classes/ViewRelated/Orders/Order Creation/ProductsSection/AddProductToOrderViewModel.swift

Lines changed: 11 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ final class AddProductToOrderViewModel: ObservableObject {
6262
///
6363
var ghostRows: [ProductRowViewModel] {
6464
return Array(0..<6).map { index in
65-
ProductRowViewModel(product: sampleGhostProduct(id: index), canChangeQuantity: false)
65+
ghostProductRow(id: index)
6666
}
6767
}
6868

@@ -199,69 +199,15 @@ extension AddProductToOrderViewModel {
199199

200200
/// Used for ghost list view while syncing
201201
///
202-
private func sampleGhostProduct(id: Int64) -> Product {
203-
Product(siteID: 1,
204-
productID: id,
205-
name: "Love Ficus",
206-
slug: "",
207-
permalink: "",
208-
date: Date(),
209-
dateCreated: Date(),
210-
dateModified: nil,
211-
dateOnSaleStart: nil,
212-
dateOnSaleEnd: nil,
213-
productTypeKey: ProductType.simple.rawValue,
214-
statusKey: ProductStatus.draft.rawValue,
215-
featured: false,
216-
catalogVisibilityKey: ProductCatalogVisibility.hidden.rawValue,
217-
fullDescription: nil,
218-
shortDescription: nil,
219-
sku: "123456",
220-
price: "20",
221-
regularPrice: nil,
222-
salePrice: nil,
223-
onSale: false,
224-
purchasable: true,
225-
totalSales: 0,
226-
virtual: false,
227-
downloadable: false,
228-
downloads: [],
229-
downloadLimit: -1,
230-
downloadExpiry: -1,
231-
buttonText: "",
232-
externalURL: nil,
233-
taxStatusKey: ProductTaxStatus.taxable.rawValue,
234-
taxClass: nil,
235-
manageStock: false,
236-
stockQuantity: 7,
237-
stockStatusKey: ProductStockStatus.inStock.rawValue,
238-
backordersKey: ProductBackordersSetting.notAllowed.rawValue,
239-
backordersAllowed: false,
240-
backordered: false,
241-
soldIndividually: true,
242-
weight: nil,
243-
dimensions: ProductDimensions(length: "1", width: "1", height: "1"),
244-
shippingRequired: false,
245-
shippingTaxable: false,
246-
shippingClass: nil,
247-
shippingClassID: 0,
248-
productShippingClass: nil,
249-
reviewsAllowed: false,
250-
averageRating: "5",
251-
ratingCount: 0,
252-
relatedIDs: [],
253-
upsellIDs: [],
254-
crossSellIDs: [],
255-
parentID: 0,
256-
purchaseNote: nil,
257-
categories: [],
258-
tags: [],
259-
images: [],
260-
attributes: [],
261-
defaultAttributes: [],
262-
variations: [],
263-
groupedProducts: [],
264-
menuOrder: 0,
265-
addOns: [])
202+
private func ghostProductRow(id: Int64) -> ProductRowViewModel {
203+
ProductRowViewModel(productOrVariationID: id,
204+
name: "Ghost Product",
205+
sku: nil,
206+
price: "20",
207+
stockStatusKey: ProductStockStatus.inStock.rawValue,
208+
stockQuantity: 1,
209+
manageStock: false,
210+
canChangeQuantity: false,
211+
imageURL: nil)
266212
}
267213
}

WooCommerce/Classes/ViewRelated/Orders/Order Creation/ProductsSection/AddProductVariationToOrderViewModel.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ final class AddProductVariationToOrderViewModel: ObservableObject {
4444
///
4545
@Published private(set) var shouldShowScrollIndicator = false
4646

47+
/// View models of the ghost rows used during the loading process.
48+
///
49+
var ghostRows: [ProductRowViewModel] {
50+
return Array(0..<6).map { index in
51+
ghostProductRow(id: index)
52+
}
53+
}
54+
4755
/// Product Variations Results Controller.
4856
///
4957
private lazy var productVariationsResultsController: ResultsController<StorageProductVariation> = {
@@ -165,4 +173,18 @@ extension AddProductVariationToOrderViewModel {
165173
case results
166174
case empty
167175
}
176+
177+
/// Used for ghost list view while syncing
178+
///
179+
private func ghostProductRow(id: Int64) -> ProductRowViewModel {
180+
ProductRowViewModel(productOrVariationID: id,
181+
name: "Ghost Variation",
182+
sku: nil,
183+
price: "20",
184+
stockStatusKey: ProductStockStatus.inStock.rawValue,
185+
stockQuantity: 1,
186+
manageStock: false,
187+
canChangeQuantity: false,
188+
imageURL: nil)
189+
}
168190
}

0 commit comments

Comments
 (0)