Skip to content

Commit a7a0a41

Browse files
committed
Update terminology to prefer options rather than terms
1 parent bc2d4cb commit a7a0a41

File tree

3 files changed

+44
-44
lines changed

3 files changed

+44
-44
lines changed

WooCommerce/Classes/ViewRelated/Products/Variations/Add Attributes/AddAttributeOptionsViewController.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ private extension AddAttributeOptionsViewController {
200200
///
201201
func configure(_ cell: UITableViewCell, for row: Row, at indexPath: IndexPath) {
202202
switch (row, cell) {
203-
case (.termTextField, let cell as TextFieldTableViewCell):
203+
case (.optionTextField, let cell as TextFieldTableViewCell):
204204
configureTextField(cell: cell)
205-
case (let .selectedTerms(name), let cell as BasicTableViewCell):
205+
case (let .selectedOptions(name), let cell as BasicTableViewCell):
206206
configureOptionOffered(cell: cell, text: name, index: indexPath.row)
207-
case (let .existingTerms(name), let cell as BasicTableViewCell):
207+
case (let .existingOptions(name), let cell as BasicTableViewCell):
208208
configureOptionAdded(cell: cell, text: name)
209209
default:
210210
fatalError("Unsupported Cell")
@@ -249,7 +249,7 @@ private extension AddAttributeOptionsViewController {
249249
// MARK: - Placeholders
250250
//
251251
private extension AddAttributeOptionsViewController {
252-
/// Renders ghost placeholder while terms are being synched.
252+
/// Renders ghost placeholder while options are being synched.
253253
///
254254
func displayGhostTableView() {
255255
let options = GhostOptions(displaysSectionHeader: false,
@@ -303,15 +303,15 @@ extension AddAttributeOptionsViewController {
303303
}
304304

305305
enum Row: Equatable {
306-
case termTextField
307-
case selectedTerms(name: String)
308-
case existingTerms(name: String)
306+
case optionTextField
307+
case selectedOptions(name: String)
308+
case existingOptions(name: String)
309309

310310
fileprivate var type: UITableViewCell.Type {
311311
switch self {
312-
case .termTextField:
312+
case .optionTextField:
313313
return TextFieldTableViewCell.self
314-
case .selectedTerms, .existingTerms:
314+
case .selectedOptions, .existingOptions:
315315
return BasicTableViewCell.self
316316
}
317317
}

WooCommerce/Classes/ViewRelated/Products/Variations/Add Attributes/AddAttributeOptionsViewModel.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ final class AddAttributeOptionsViewModel {
9393

9494
private(set) var sections: [Section] = []
9595

96-
/// Stores manager to dispatch sync terms(options) action.
96+
/// Stores manager to dispatch sync global options action.
9797
///
9898
private let stores: StoresManager
9999

100-
/// Storage manager to read fetched terms(options).
100+
/// Storage manager to read fetched global options.
101101
///
102102
private let viewStorage: StorageManagerType
103103

@@ -110,7 +110,7 @@ final class AddAttributeOptionsViewModel {
110110
case .new:
111111
updateSections()
112112
case .existing:
113-
synchronizeOptions()
113+
synchronizeGlobalOptions()
114114
}
115115
}
116116
}
@@ -143,13 +143,13 @@ extension AddAttributeOptionsViewModel {
143143
}
144144
}
145145

146-
// MARK: - Synchronize Product Attribute terms
146+
// MARK: - Synchronize Product Attribute Options
147147
//
148148
private extension AddAttributeOptionsViewModel {
149149
/// Updates data in sections
150150
///
151151
func updateSections() {
152-
let textFieldSection = Section(header: nil, footer: Localization.footerTextField, rows: [.termTextField], allowsReorder: false)
152+
let textFieldSection = Section(header: nil, footer: Localization.footerTextField, rows: [.optionTextField], allowsReorder: false)
153153
let offeredSection = createOfferedSection()
154154
let addedSection = createAddedSection()
155155
sections = [textFieldSection, offeredSection, addedSection].compactMap { $0 }
@@ -161,10 +161,10 @@ private extension AddAttributeOptionsViewModel {
161161
}
162162

163163
let rows = state.optionsOffered.map { option in
164-
AddAttributeOptionsViewModel.Row.selectedTerms(name: option)
164+
AddAttributeOptionsViewModel.Row.selectedOptions(name: option)
165165
}
166166

167-
return Section(header: Localization.headerSelectedTerms, footer: nil, rows: rows, allowsReorder: true)
167+
return Section(header: Localization.headerSelectedOptions, footer: nil, rows: rows, allowsReorder: true)
168168
}
169169

170170
func createAddedSection() -> Section? {
@@ -173,38 +173,38 @@ private extension AddAttributeOptionsViewModel {
173173
return nil
174174
}
175175

176-
let rows = state.optionsAdded.map { term in
177-
AddAttributeOptionsViewModel.Row.existingTerms(name: term.name)
176+
let rows = state.optionsAdded.map { option in
177+
AddAttributeOptionsViewModel.Row.existingOptions(name: option.name)
178178
}
179179

180-
return Section(header: Localization.headerExistingTerms, footer: nil, rows: rows, allowsReorder: false)
180+
return Section(header: Localization.headerExistingOptions, footer: nil, rows: rows, allowsReorder: false)
181181
}
182182

183-
/// Synchronizes options(terms) for global attributes
183+
/// Synchronizes options for global attributes
184184
///
185-
func synchronizeOptions() {
185+
func synchronizeGlobalOptions() {
186186
guard case let .existing(attribute) = source, attribute.isGlobal else {
187187
return
188188
}
189189

190-
let fetchTerms = ProductAttributeTermAction.synchronizeProductAttributeTerms(siteID: attribute.siteID,
191-
attributeID: attribute.attributeID) { [weak self] _ in
190+
let fetchOptions = ProductAttributeTermAction.synchronizeProductAttributeTerms(siteID: attribute.siteID,
191+
attributeID: attribute.attributeID) { [weak self] _ in
192192
guard let self = self else { return }
193193
self.state.optionsAdded = self.optionsOfferedResultsController.fetchedObjects
194194
self.state.isSyncing = false
195195
}
196196
state.isSyncing = true
197-
stores.dispatch(fetchTerms)
197+
stores.dispatch(fetchOptions)
198198
}
199199
}
200200

201201
private extension AddAttributeOptionsViewModel {
202202
enum Localization {
203203
static let footerTextField = NSLocalizedString("Add each option and press enter",
204204
comment: "Footer of text field section in Add Attribute Options screen")
205-
static let headerSelectedTerms = NSLocalizedString("OPTIONS OFFERED",
205+
static let headerSelectedOptions = NSLocalizedString("OPTIONS OFFERED",
206206
comment: "Header of selected attribute options section in Add Attribute Options screen")
207-
static let headerExistingTerms = NSLocalizedString("ADD OPTIONS",
207+
static let headerExistingOptions = NSLocalizedString("ADD OPTIONS",
208208
comment: "Header of existing attribute options section in Add Attribute Options screen")
209209
}
210210
}

WooCommerce/WooCommerceTests/ViewRelated/Variations/Add Attributes/AddAttributeOptionsViewModelTests.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class AddAttributeOptionsViewModelTests: XCTestCase {
1414

1515
// Then
1616
let textFieldSection = try XCTUnwrap(viewModel.sections.last?.rows)
17-
XCTAssertEqual(textFieldSection, [AddAttributeOptionsViewController.Row.termTextField])
17+
XCTAssertEqual(textFieldSection, [AddAttributeOptionsViewController.Row.optionTextField])
1818
XCTAssertEqual(viewModel.sections.count, 1)
1919
}
2020

@@ -28,7 +28,7 @@ final class AddAttributeOptionsViewModelTests: XCTestCase {
2828

2929
// Then
3030
let offeredSection = try XCTUnwrap(viewModel.sections.last?.rows)
31-
XCTAssertEqual(offeredSection, [AddAttributeOptionsViewController.Row.selectedTerms(name: sampleOptionName)])
31+
XCTAssertEqual(offeredSection, [AddAttributeOptionsViewController.Row.selectedOptions(name: sampleOptionName)])
3232
XCTAssertEqual(viewModel.sections.count, 2)
3333
}
3434

@@ -44,8 +44,8 @@ final class AddAttributeOptionsViewModelTests: XCTestCase {
4444

4545
// Then
4646
let offeredSection = try XCTUnwrap(viewModel.sections.last?.rows)
47-
XCTAssertEqual(offeredSection, [AddAttributeOptionsViewController.Row.selectedTerms(name: sampleOptionName),
48-
AddAttributeOptionsViewController.Row.selectedTerms(name: newOptionName)])
47+
XCTAssertEqual(offeredSection, [AddAttributeOptionsViewController.Row.selectedOptions(name: sampleOptionName),
48+
AddAttributeOptionsViewController.Row.selectedOptions(name: newOptionName)])
4949
XCTAssertEqual(viewModel.sections.count, 2)
5050
}
5151

@@ -74,9 +74,9 @@ final class AddAttributeOptionsViewModelTests: XCTestCase {
7474
// Then
7575
let optionsOffered = try XCTUnwrap(viewModel.sections.last?.rows)
7676
XCTAssertEqual(optionsOffered, [
77-
.selectedTerms(name: "Option 2"),
78-
.selectedTerms(name: "Option 3"),
79-
.selectedTerms(name: "Option 1")
77+
.selectedOptions(name: "Option 2"),
78+
.selectedOptions(name: "Option 3"),
79+
.selectedOptions(name: "Option 1")
8080
])
8181

8282
}
@@ -94,9 +94,9 @@ final class AddAttributeOptionsViewModelTests: XCTestCase {
9494
// Then
9595
let optionsOffered = try XCTUnwrap(viewModel.sections.last?.rows)
9696
XCTAssertEqual(optionsOffered, [
97-
.selectedTerms(name: "Option 1"),
98-
.selectedTerms(name: "Option 2"),
99-
.selectedTerms(name: "Option 3")
97+
.selectedOptions(name: "Option 1"),
98+
.selectedOptions(name: "Option 2"),
99+
.selectedOptions(name: "Option 3")
100100
])
101101
}
102102

@@ -113,8 +113,8 @@ final class AddAttributeOptionsViewModelTests: XCTestCase {
113113
// Then
114114
let optionsOffered = try XCTUnwrap(viewModel.sections.last?.rows)
115115
XCTAssertEqual(optionsOffered, [
116-
.selectedTerms(name: "Option 1"),
117-
.selectedTerms(name: "Option 3")
116+
.selectedOptions(name: "Option 1"),
117+
.selectedOptions(name: "Option 3")
118118
])
119119
}
120120

@@ -131,9 +131,9 @@ final class AddAttributeOptionsViewModelTests: XCTestCase {
131131
// Then
132132
let optionsOffered = try XCTUnwrap(viewModel.sections.last?.rows)
133133
XCTAssertEqual(optionsOffered, [
134-
.selectedTerms(name: "Option 1"),
135-
.selectedTerms(name: "Option 2"),
136-
.selectedTerms(name: "Option 3")
134+
.selectedOptions(name: "Option 1"),
135+
.selectedOptions(name: "Option 2"),
136+
.selectedOptions(name: "Option 3")
137137
])
138138
}
139139

@@ -164,9 +164,9 @@ final class AddAttributeOptionsViewModelTests: XCTestCase {
164164
// Then
165165
let optionsAdded = try XCTUnwrap(viewModel.sections.last?.rows)
166166
XCTAssertEqual(optionsAdded, [
167-
.existingTerms(name: "Option 1"),
168-
.existingTerms(name: "Option 2"),
169-
.existingTerms(name: "Option 3")
167+
.existingOptions(name: "Option 1"),
168+
.existingOptions(name: "Option 2"),
169+
.existingOptions(name: "Option 3")
170170
])
171171
}
172172

0 commit comments

Comments
 (0)