Skip to content
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

Order: Displaying Notes #73

Merged
merged 37 commits into from
Jun 25, 2018
Merged

Order: Displaying Notes #73

merged 37 commits into from
Jun 25, 2018

Conversation

mindgraffiti
Copy link
Contributor

Fixes #13

To test:

  1. Navigate to Orders
  2. Choose Order No. 1107 or Order No. 1044. "Add a note" row should display and order notes should display.

Notes: The table cells are using default separator styles, which looks different compared to the mockups.

@mindgraffiti mindgraffiti added the feature: order details Related to order details. label May 29, 2018
@mindgraffiti mindgraffiti added this to the External closed beta group milestone May 29, 2018
@mindgraffiti mindgraffiti self-assigned this May 29, 2018
@mindgraffiti mindgraffiti added this to MVLP Backlog in MVLP Kanban Board via automation May 29, 2018
super.awakeFromNib()
imageView?.tintColor = StyleManager.wooCommerceBrandColor
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)


// Configure the view for the selected state
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)

case let cell as AddItemTableViewCell:
cell.configure(image: viewModel.addNoteIcon, text: viewModel.addNoteText)
case let cell as OrderNoteTableViewCell where row == .orderNote:
cell.configure(with: viewModel.orderNotes[indexPath.row - 1])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how to express this better. it's [indexPath.row - 1] because the first indexPath.row is the "Add a note" row.

@@ -0,0 +1,32 @@
/// WooCommerce API Credentials. Generated on May 29, 2018 at 11:16:32
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be in git ignore?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in git ignore. Not sure what happened, but please please 🔥

@mindgraffiti mindgraffiti moved this from MVLP Backlog to Review/Testing in MVLP Kanban Board May 29, 2018
@mindgraffiti mindgraffiti added the type: enhancement A request for an enhancement. label Jun 13, 2018
Copy link
Collaborator

@jleandroperez jleandroperez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UI looking great! Few incoming comments, thanks Thuy!!

@@ -0,0 +1,32 @@
/// WooCommerce API Credentials. Generated on May 29, 2018 at 11:16:32
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in git ignore. Not sure what happened, but please please 🔥


/// WordPress.com Auth Callback Scheme (AKA Magic Link!)
///
#define DOTCOM_AUTH_SCHEME woocommerce
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. The entire DerivedSources is in gitignore, please please, remove, and make sure not to commit that, never. It's all good for now, since the project is closed. But if this was OSS, this would probably not be good!

@@ -20,7 +20,7 @@ struct Order: Decodable {
let items: [OrderItem]
let currency: String
let total: String
let notes: [OrderNote]?
var notes: [OrderNote]?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(It's okay, no need to change anything here!!). We're using immutable data models, which means that the app itself should never update / modify fields directly.

Ideally speaking, the Service Layer ("Yosemite.framework") posts changes to the backend, and the data flows back from the Networking layer (OR service layer itself) to the UI .

Nevertheless, since we're removing this file in a little bit, and this is only for testing purposes, super OK to leave it this way!

}
}

return array
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swifty snippet:

        guard let notes = notes else {
            return []
        }

        return notes.map { note in
            return OrderNoteViewModel(with: note)
        }

(If notes wasn't optional, the guard wouldn't even be needed)

// "date_created": "2017-03-21T16:46:41",
let format = DateFormatter()
format.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"
date = format.date(from: orderNote.dateCreated)!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace with DateFormatter.Defaults.dateTimeFormatter (which should do the same).

Perhaps the date field should be optional, itself? (it'd be a very very good idea to remove the !)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dateTimeFormatter method is an extension only found in the Networking subproject. Do I copy it over to the main project or is there somewhere else I should add it?

@mindgraffiti
Copy link
Contributor Author

mindgraffiti commented Jun 25, 2018

@jleandroperez thank you for the review! It's ready for a second look.

Copy link
Collaborator

@jleandroperez jleandroperez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few nipticky comments, and one crash. Steps:

  1. Launch WC
  2. Press over the Orders TabBar button
  3. Press over the first row

As a result, the app is crashing. Stack trace below!

706F150-66CA-4CB4-9CB5-697716718DE2/WooCommerce.app> (loaded)' with name 'AddItemTableViewCell''
*** First throw call stack:
(
	0   CoreFoundation                      0x0000000109a091e6 __exceptionPreprocess + 294
	1   libobjc.A.dylib                     0x0000000108b5c031 objc_exception_throw + 48
	2   CoreFoundation                      0x0000000109a7e975 +[NSException raise:format:] + 197
	3   UIKit                               0x0000000105d192e9 -[UINib instantiateWithOwner:options:] + 501
	4   UIKit                               0x00000001059d2cc4 -[UITableView _dequeueReusableViewOfType:withIdentifier:] + 613
	5   UIKit                               0x00000001059d31bb -[UITableView _dequeueReusableCellWithIdentifier:forIndexPath:usingPresentationValues:] + 148
	6   UIKit                               0x00000001059d30f3 -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 91
	7   WooCommerce                         0x00000001044ab7da _T011WooCommerce26OrderDetailsViewControllerC05tableE0So07UITableE4CellCSo0hE0C_10Foundation9IndexPathV12cellForRowAttF + 634
	8   WooCommerce                         0x00000001044aca0c _T011WooCommerce26OrderDetailsViewControllerC05tableE0So07UITableE4CellCSo0hE0C_10Foundation9IndexPathV12cellForRowAttFTo + 92
	9   UIKit                               0x00000001059ee567 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 783
	10  UIKit                               0x00000001059eeae4 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74
	11  UIKit                               0x00000001059b5eaa -[UITableView _updateVisibleCellsNow:isRecursive:] + 3168
	12  UIKit                               0x00000001059d67e0 -[UITableView layoutSubviews] + 176
	13  UIKit                               0x00000001059607a8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1515
	14  QuartzCore                          0x0000000110b81456 -[CALayer layoutSublayers] + 177
	15  QuartzCore                          0x0000000110b85667 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 395
	16  QuartzCore                          0x0000000110b0c0fb _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 343
	17  QuartzCore                          0x0000000110b3979c _ZN2CA11Transaction6commitEv + 568
	18  UIKit                               0x00000001058b9f2c _afterCACommitHandler + 272
	19  CoreFoundation                      0x00000001099ab607 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
	20  CoreFoundation                      0x00000001099ab55e __CFRunLoopDoObservers + 430
	21  CoreFoundation                      0x000000010998fb81 __CFRunLoopRun + 1537
	22  CoreFoundation                      0x000000010998f30b CFRunLoopRunSpecific + 635
	23  GraphicsServices                    0x000000010f68aa73 GSEventRunModal + 62
	24  UIKit                               0x0000000105891057 UIApplicationMain + 159
	25  WooCommerce                         0x0000000104489387 main + 55
	26  libdyld.dylib                       0x000000010b111955 start + 1
	27  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

Podfile Outdated
@@ -1,4 +1,4 @@
source 'https://github.com/CocoaPods/Specs.git'

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind nuking the two empty spaces at the top?

statusText = NSLocalizedString("Private note", comment: "Labels an order note to let the user know it's private and not seen by the customer")
}

// "date_created": "2017-03-21T16:46:41",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we nuke this one?


// "date_created": "2017-03-21T16:46:41",
let format = DateFormatter.Defaults.dateTimeFormatter
date = format.date(from: orderNote.dateCreated)!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably a bad idea to use an Implicitly Unwrapped Optional here. Whenever there's a parsing issue, the app will crash.

Can we turn the date field into an Optional instead?

formatter.timeStyle = .short

let formattedDateString = formatter.string(from: date)
return formattedDateString
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return formatter.string(from: date)

} catch {
print("error:\(error)")
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to change this, since it's testing code, and it's going away supersoon!. But in general, you may wanna avoid nested levels.

A simple way to express this, in a "flattened fashion" would be:

guard let path = Bundle.main.url(forResource: resource, withExtension: "json") else {
	return basicOrder
}

do {
	let json = try Data(contentsOf: path)
	let decoder = JSONDecoder()
	let orderNotesFromJson = try decoder.decode([OrderNote].self, from: json)
	var order = basicOrder
	order.notes = orderNotesFromJson
	return order
} catch {
	DDLogError("error:\(error)")
}

(The lesser indentation levels, the better, since it really aids readability)

@jleandroperez jleandroperez changed the title Issue/13 order notes Order: Displaying Notes Jun 25, 2018
Copy link
Collaborator

@jleandroperez jleandroperez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All clear!!!

:shipit:

@mindgraffiti mindgraffiti merged commit bdc4df6 into develop Jun 25, 2018
MVLP Kanban Board automation moved this from Review/Testing to Done/Merged Jun 25, 2018
@mindgraffiti mindgraffiti deleted the issue/13-order-notes branch June 25, 2018 20:01
@mindgraffiti
Copy link
Contributor Author

Thanks Jorge!

@astralbodies astralbodies mentioned this pull request Jun 27, 2018
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: order details Related to order details. type: enhancement A request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants