Skip to content
This repository was archived by the owner on Jul 24, 2020. It is now read-only.

[1114] change item quantities in cart #1129

Merged
merged 1 commit into from
Apr 20, 2015

Conversation

connormcl
Copy link
Contributor

Resolved #1114

@squidgetx
Copy link
Contributor

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'?

@mnquintana
Copy link
Contributor

@connormcl Would you mind merging in master first? The diff is comparing against the version of master you branched from, instead of the one with the latest updates. (note: there will be a merge conflict)

@connormcl
Copy link
Contributor Author

I'll merge in master now, then resubmit.

@orenyk
Copy link
Contributor

orenyk commented Mar 1, 2015

You might have issues rebasing if you perform a merge; I'd almost recommend a non-squashing rebase (git rebase master) over a merge commit if we're looking to ultimately squash commits.

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 (git push -f origin 1114_change_item_quantities_in_cart). Also note that you'll have to update the views to reflect the Bootstrap upgrade regardless of how you deal with merge conflicts.

@squidgetx squidgetx changed the title 1114 change item quantities in cart [1114] change item quantities in cart Mar 23, 2015
@connormcl connormcl force-pushed the 1114_change_item_quantities_in_cart branch from d89e98d to b58f4e1 Compare March 28, 2015 21:49
@connormcl
Copy link
Contributor Author

This should be good to merge now that it's been rebased.

@orenyk
Copy link
Contributor

orenyk commented Mar 29, 2015

This layout is broken (see below), we need to make sure that it looks right, including potentially cases with double digit item counts.

selection_055

@mnquintana
Copy link
Contributor

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.

@orenyk
Copy link
Contributor

orenyk commented Mar 29, 2015

Fair point, but that would involve refactoring the cart update methods. We could either add a new route for cart amount updates or replace add_to_cart and remove_from_cart with a generalized edit_cart_item method. We can discuss more tonight.

@TyPetrochko
Copy link
Contributor

Going into 2 digits causes it to break for me,
screenshot from 2015-03-31 01 19 50

@mnquintana
Copy link
Contributor

@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.

@orenyk
Copy link
Contributor

orenyk commented Mar 31, 2015

@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 😛).

@connormcl
Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor

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).

@orenyk
Copy link
Contributor

orenyk commented Apr 7, 2015

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
Copy link
Contributor

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 returned already if the quantity was less than zero.

@orenyk
Copy link
Contributor

orenyk commented Apr 7, 2015

Ok, almost there! I think we can replace the old cart model methods (add_to_cart and remove_from_cart) with calls to our new method, which should probably be renamed and modified so that it can add new equipment models to the items hash. Other than that and some minor CSS / spec edits, we should basically be there.

closes #1114
- use number fields to adjust item quantities
- add simple integration tests for new edit_cart_item method
@connormcl connormcl force-pushed the 1114_change_item_quantities_in_cart branch from a19bf75 to 116cc03 Compare April 20, 2015 01:06
@orenyk
Copy link
Contributor

orenyk commented Apr 20, 2015

Looks good! :shipit:

orenyk added a commit that referenced this pull request Apr 20, 2015
@orenyk orenyk merged commit 4db1ada into master Apr 20, 2015
@orenyk orenyk deleted the 1114_change_item_quantities_in_cart branch October 27, 2015 19:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow changes to item quantity in cart
5 participants