-
Notifications
You must be signed in to change notification settings - Fork 57
[1114] change item quantities in cart #1129
Conversation
this looks pretty solid. I might just say we should remove the commented code out (save it somewhere, but it doesn't need to be merged to master, especially since the cart UX will go hand in hand with the API-Client rewrite in which we'll scrap all our ERB anyway) @orenyk what do you think'? |
@connormcl Would you mind merging in |
I'll merge in master now, then resubmit. |
You might have issues rebasing if you perform a merge; I'd almost recommend a non-squashing rebase ( I'm with @squidgetx about the commented code, we'll be rewriting most of this ultimately and may decide not to impose validations on catalog buttons depending on how we rework the cart UX (#1119). EDIT: Note that you'll have to force push to get your newly rebased branch back up to GitHub, make sure you only push up this branch by specifying it ( |
d89e98d
to
b58f4e1
Compare
This should be good to merge now that it's been rebased. |
IMO we should probably implement this with HTML5 number inputs instead of custom buttons, which would be less brittle and less likely to break on layout changes without serious layout / styling considerations. |
Fair point, but that would involve refactoring the cart update methods. We could either add a new route for cart amount updates or replace |
@TyPetrochko @connormcl Have you tested it on smaller browser widths? I'd expect it to break even more because the column width will be smaller. |
@connormcl had mostly fixed this as of Sunday night, I think he was just writing some integration tests before pushing (although, to be fair @connormcl, a comment to that effect would have been helpful 😛). |
Like @orenyk said above me, I should have commented earlier to update. Anyways, now the cart uses a number field that should have a consistent layout regardless of window size. Additionally, I wrote some simple integration tests for changing cart item quantities/removing items. I would appreciate code review! |
@quantity = 0 | ||
|
||
fill_in 'quantity_field', with: @quantity.to_s | ||
find(:xpath, "//input[@id='quantity_field']").set @quantity.to_s |
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.
Just out of curiosity, is there a reason why xpath would be preferred here over a CSS selector?
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.
Not sure there's a preference, but implementing my id
suggestion above would make this much simpler: fill_in "#quantity_field_#{EquipmentModel.first.id}", with: quantity.to_s
(I think, double check with the Capybara docs).
This seems pretty slick! Nice work 😄. I'm just going to read through the code, but the general functionality seems to work very well from playing with it. |
return if quantity < 0 | ||
key = equipment_model.id | ||
items[key] = items[key] ? quantity : 0 | ||
self.items = items.except(key) if items[key] <= 0 |
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.
Do you need to test for items[key] <= 0
or could you just test items[key] == 0
? You'd have return
ed already if the quantity was less than zero.
Ok, almost there! I think we can replace the old cart model methods ( |
closes #1114 - use number fields to adjust item quantities - add simple integration tests for new edit_cart_item method
a19bf75
to
116cc03
Compare
Looks good! |
Resolved #1114