-
Notifications
You must be signed in to change notification settings - Fork 57
Conversation
@@ -1,3 +1,7 @@ | |||
.warning-icon { | |||
color: $btn-warning-bg; | |||
} | |||
|
|||
#empty_cart_btn { | |||
margin-bottom: 0px; |
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.
Too much indentation
I've started working through this now, here are some thoughts from playing around with it:
You can address @mnquintana's comments regardless, and I'm going to give the code a first read through, but think about the UX here and how we can improve it. |
function toggle_form(){ | ||
if ($('#form').is(':visible')){ | ||
pause_cart(); // lock the cart so users can't change it while page is reloading | ||
location.reload();// update the info here so it's all new when we close the form |
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.
missing space between semicolon and comment
Following up on my previous comment, the fact that clicking on the "Edit Reservation" button when the form is open keeps the changes (which it has to since we've already updated the cart) is incredibly counter-intuitive to me. |
Another note: the "Empty Cart" button is actually broken since it calls the |
</div> | ||
<% end %> | ||
</div> | ||
<%# edit reservation 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.
There should be spaces after / before the ERB tags (i.e. <% # edit reservation 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.
Also, if this code and the code in the _new_request.html.erb
partial is identical, you should separate it out into a partial as well.
I am creating a new form instead of embedding the cart. currently working on putting in the new routes and logic. |
@AlanLiu96 is this ready to be reviewed? For future reference, we'd use the |
Almost, I'm finishing up the tests tonight/tomorrow, and then It'll be ready for review |
Great, keep up the good work 😄 |
Whoops, I just realized that you had updated this status in May! Looking over it now... |
@@ -41,6 +42,48 @@ def update_user_per_cat_page | |||
end | |||
end | |||
|
|||
def submit_form # rubocop:disable MethodLength, AbcSize |
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 name is a bit too vague; let's make it a little more specific so that we know what it's for (updating the cart during confirmation... but not in so many words 😛).
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.
Another, more fundamental, comment - this method duplicates a lot of code from other methods, which is not good. I'd really like it if we could simply call the ApplicationController#update_cart
method in here to deal with updating the dates and then something like your code to handle quantity updates. This would require tweaking the structure of the form and potentially the update_cart
method, but it would be much more sustainable.
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.
Hmm.. I agree that it's not good that it duplicates code from update_cart, which hurts it in sustainability, but I feel like we should handle the dates in the form separately from the dates in the cart. Right now submitting the form with an error in dates doesn't affect the original cart, so the original values of the cart are restored. Integrating update_cart into it to handle the date validation on the form removes that function because it sets the dates back to their default values. I'm not sure which is more important in this case.
Another option is to call update_cart again after the validations on the form to handle the blackouts, but I'm not sure if it's worth it to call it just to handle the blackout notifications.
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.
I'm ok with tweaking the cart date handling through this issue so that we can use the same code for both use cases. Don't forget, this issue is designed to allow for cart edits through the checkout page, so there really isn't such a thing as the "original" cart - we're meant to be editing the actual cart by submitting the form. If a user enters invalid dates here I think we'd want it to behave the way it would in the catalog views; that keeps us consistent.
That's just my opinion, though; let me know if that makes sense or if you still disagree 😄.
This looks really good! It's crazy to compare it to what we had before 😄. I left a bunch of comments inline, here are a few other thoughts:
Let me know if you have questions regarding the refactoring of the controller method, great work! |
fill_in "quantity_field_#{@eq_model.id}", # edit and submit | ||
with: (@eq_model.max_per_user) | ||
quantity_forms[0].submit_form! | ||
expect(page).to have_content 'Confirm Reservation' |
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.
I think you need to reload the page here to verify that everything still works. (EDIT: or is being treated as an HTML format request since it's from Capybara? We should confirm either way.) (EDIT 2: Yea, after testing this with save_and_open_page
it does submit the form with an HTML-format request so it reloads the page automatically.) Also, it doesn't look like you're testing to make sure that your change to the cart was actually saved. We could add another expectation here for that.
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.
Also, this test will pass even if the title of the page is "Confirm Reservation Request", so it doesn't actually work. You'd probably have to add a test to ensure that it doesn't say the longer title.
Ok, I ran through and left a bunch of notes inline. I also manually checked the various use cases specified in my earlier comment, and everything is working great, nice job! At this point, I'd say the code is pretty much complete but the tests need a bit of work. The setup of the various specs doesn't necessarily take you to the page you're expecting or result in the expected scenario, and our tests for whether or not we're on the reservation or request view doesn't actually check what we're trying to check. When you're writing tests (and I know it gets complicated particularly with integration tests), try to make sure you know exactly what the scenario is that you're testing, that the steps you take result in that scenario, and that the expectations you run actually validate your "hypothesis". Definitely make good use of Use this PR as a place to comment on your testing work and don't hesitate to reach out if you have questions about any specific test. This is really fantastic work - the page feels really snappy, it's a huge improvement over our current UX (and you've really polished it through this incredibly long code review) - let's get the tests wrapped up and we can finally merge this in 😀. Let me know when it's ready for another review, good luck! |
@AlanLiu96, is this ready for re-review? |
Not yet, should be done by Friday though |
No worries just checking, thanks! |
I changed most of the tests so that they were properly redirecting to the right page and that it was running the tests as expected. The only part I'm still not sure about is how to fix the page redirection when the cart is empty. Right now it refreshes the page using js, which causes the redirect, but ideally it would directly redirect to the catalog page. I'm not sure how to make it do this when rails expects javascript. |
ready for re-review. For the javascript change, it now redirects using js to the root path. |
resume_cart(); | ||
|
||
<% if @errors.empty? or (can? :override, :reservation_errors) %> | ||
$('#new_res_request').html('<%= escape_javascript(render :partial => '/reservations/new_reservation') %>'); |
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 is very minor but I'm not thrilled with this ID (new_res_request
) - we use the term 'request' to mean something specific. What about something like confirm-res-form
(also note the use of dashes instead of underscores for CSS selectors)? Just a suggestion...
Great work @AlanLiu96! I had a few minor comments but this is pretty much there. Unfortunately, you're going to have some merge conflicts to deal with before we can merge this in; once you've dealt with the remaining issues I'd recommend you squash all of your commits and then address the merge conflicts with a single rebase onto |
addressed all of the comments, going to go through the merge conflicts later today/tomorrow. |
Awesome, looks great! Responded to one point but it's really minor; if you're comfortable squashing on your own go ahead and you can start to work on the merge conflicts, otherwise we can work on it tomorrow night. |
8b37e2d
to
6430c70
Compare
Resolves #237 - Redesign & Add form to confirm reservation page - Allow user to edit cart & dates on confirm reservation page - Lock cart when changing quantities - Add submit_cart_updates_form in catalog controller to update cart with changes on confirm reservation page & redirect - Add change_reservation_dates in catalog controller to update cart dates - Separate update_cart in application controller into two different methods: performing cart updates and appropriate redirections/js calls - Add reservation_form.js to dynamically switch between reservations and reservation requests - Add controller tests & feature tests
6430c70
to
e75f66a
Compare
Resolves #237
(edited to reflect full changes)