-
Notifications
You must be signed in to change notification settings - Fork 121
Order Details: Add a note #176
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
Conversation
…te` object. Should return an `OrderNote?` instead of an `[OrderNote]?`
Add nav bar, display nav buttons
- grouped table style - section titles
Generated by 🚫 Danger |
jleandroperez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great @mindgraffiti !!! few incoming nipticky comments, please, let me know if anything!.
|
|
||
| @objc func addButtonTapped() { | ||
| let indexPath = IndexPath(row: 0, section: 0) | ||
| guard let cell = tableView.cellForRow(at: indexPath) as? WriteCustomerNoteTableViewCell else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two notes here!!
- Instead of having the IndexPath for the TextView row, you can just do something like this:
WriteCustomerNoteTableViewCell.swift
class WriteCustomerNoteTableViewCell {
var onTextChange: ((String) -> Void)?
}
extension WriteCustomerNoteTableViewCell : UITextViewDelegate: {
func textViewDidChange() {
onTextChange?(textView.text)
}
}
|
|
||
| @objc func addButtonTapped() { | ||
| let indexPath = IndexPath(row: 0, section: 0) | ||
| guard let cell = tableView.cellForRow(at: indexPath) as? WriteCustomerNoteTableViewCell else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Having the mechanism mentioned above would let you disable the
addbutton, whenever there is no text (OR enable it whenisEmpty != false)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
| target: self, | ||
| action: #selector(addButtonTapped)) | ||
| rightBarButton.tintColor = .white | ||
| navigationItem.setRightBarButton(rightBarButton, animated: false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be neat if we could disable the Add button whenever there is no actual text entered.
(More details below in addButtonTapped!!)
| } | ||
|
|
||
| let action = OrderNoteAction.addOrderNote(siteID: viewModel.order.siteID, orderID: viewModel.order.orderID, isCustomerNote: isCustomerNote, note: note) { [weak self] (orderNote, error) in | ||
| guard orderNote != nil else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one should probably check on error rather than the note. (if let error = error { ... })
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
| // | ||
| extension AddANoteViewController: UITableViewDataSource { | ||
| func numberOfSections(in tableView: UITableView) -> Int { | ||
| return 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return sections.count
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
| } | ||
|
|
||
| func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
| return 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return sections[section].rows.count
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
| @@ -0,0 +1,25 @@ | |||
| import UIKit | |||
|
|
|||
| class ToggleEmailCustomerTableViewCell: UITableViewCell { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Can we rename this one to something like
SwitchTableViewCellperhaps?. - The
topLabel.text+bottomLabel.textsetup should probably be done insetupEmailCustomerCell. That would effectively let you turn this one into a reusable cell (and not just for ToggleEmail)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
| } | ||
|
|
||
| override func awakeFromNib() { | ||
| super.awakeFromNib() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please nuke this one, since it's not really needed! 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
| import UIKit | ||
| import Gridicons | ||
|
|
||
| class WriteCustomerNoteTableViewCell: UITableViewCell { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How aboooout... TextViewTableViewCell (or something like that?). Plus:
var iconImage: UIImage? {
set {
noteIconButton.setImage(newValue, for: .normal)
}
get {
return noteIconButton.image (...
}
The goal is: turn this cell into a generic one (and not just for this specific viewController).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(And you could also move this one, and the second new cell, over to ReusableViews perhaps?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
| } | ||
|
|
||
| self?.upsertStoredOrderNotes(readOnlyOrderNotes: [note], orderID: orderID) | ||
| onCompletion(note, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should proooobably do an optimistic update here. @bummytime thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jleandroperez @mindgraffiti seems to make sense. Similar to the pattern here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jleandroperez @bummytime not sure how to apply optimistic insert here. Do these steps make sense?
- Create an OrderNote object with a fake noteID and upsert it.
- If POSTing the note fails, write a function that deletes the fake note by noteID
- If POSTing is successful, delete the fake note by noteID and upsert the new note from the response
jleandroperez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOVED this PR!!!. (As discussed over Slack!!):
- First Responder is no longer getting dismissed, whenever the Note Type is switched
- selectionStyle is set to .none in the two Cells
- Updated the firstResponder behavior to automatically toggle upon viewWillAppear / viewWillDisappear.
![]()
|
Thank you Jorge! |
Closes #75.
In this PR, an
addOrderNoteaction has been added to Yosemite. The action triggers apostnetwork request. On completion, if successful the new order note is inserted into core data.The UI button
Add a notedisplays a new modal view and is connected to the action. Upon successful completion, the order details view refreshes and displays the new order note.cc: @bummytime @jleandroperez