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

send-shipment-email-optionally #11762

Merged

Conversation

binarygit
Copy link
Contributor

@binarygit binarygit commented Nov 5, 2023

What? Why?

What should we test?

Scenanio 1:

  • Login as admin
  • Visit page /admin/orders
  • Click on ship
    image
  • Ascertain that a modal shows up asking you to confirm if a shipment email should be sent
  • Ascertain when you check the checkbox, a shipment email is sent
  • Ascertain no shipment email is sent if the checkbox remains unchecked

Scenario 2:

  • Login as admin
  • Visit page /admin/orders/<order_number>/edit
  • Click on ship
    image
  • Ascertain that a modal shows up asking you to confirm if a shipment email should be sent
  • Ascertain when you check the checkbox, a shipment email is sent
  • Ascertain no shipment email is sent if the checkbox remains unchecked

Release notes

Changelog Category (reviewers may add a label for the release notes):

  • User facing changes
  • API changes (V0, V1, DFC or Webhook)
  • Technical changes only
  • Feature toggled

The title of the pull request will be included in the release notes.

Dependencies

Documentation updates

@binarygit binarygit force-pushed the send-shipment-email-optionally branch from ab03a22 to 3a99a57 Compare November 5, 2023 09:23
@rioug
Copy link
Collaborator

rioug commented Nov 5, 2023

Moving back to In Dev, as this is still a draft PR

@binarygit binarygit force-pushed the send-shipment-email-optionally branch 4 times, most recently from 09be01e to 6fbcbec Compare November 16, 2023 14:16
@binarygit binarygit force-pushed the send-shipment-email-optionally branch from 6fbcbec to 257cffc Compare November 21, 2023 08:18
@binarygit binarygit marked this pull request as ready for review November 21, 2023 09:15
Copy link
Member

@mkllnk mkllnk left a comment

Choose a reason for hiding this comment

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

Thank you, this is great. There's just one little thing that I like changed.

%div{class: "margin-bottom-30"}
= hidden_field_tag :id, order.id
= check_box_tag :send_shipment_email
= label_tag :send_shipment_email, "Send email confirmation to customer"
Copy link
Member

Choose a reason for hiding this comment

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

This needs a translations.

%form
= render ConfirmModalComponent.new(id: "ship_order", confirm_reflexes: "click->Admin::OrdersReflex#ship", controller: "orders", reflex: "Admin::Orders#ship") do
%div{class: "margin-bottom-30"}
%p This will mark the order as Shipped
Copy link
Member

Choose a reason for hiding this comment

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

Here, too.

%div{class: "margin-bottom-30"}
= hidden_field_tag :id, order.id
= check_box_tag :send_shipment_email
= label_tag :send_shipment_email, "Send email confirmation to customer"
Copy link
Member

Choose a reason for hiding this comment

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

And here.

@binarygit
Copy link
Contributor Author

@mkllnk Thanks for the review. I will work on this tomorrow. Was out sick past couple of days!

@binarygit
Copy link
Contributor Author

@mkllnk Done

Copy link
Collaborator

@rioug rioug left a comment

Choose a reason for hiding this comment

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

Great work ! 🙏

@drummer83 drummer83 self-assigned this Dec 4, 2023
@drummer83 drummer83 added no-staging-UK A tag which does not trigger deployments, indicating a server is being used pr-staged-uk staging.openfoodnetwork.org.uk and removed no-staging-UK A tag which does not trigger deployments, indicating a server is being used labels Dec 4, 2023
@drummer83
Copy link
Contributor

drummer83 commented Dec 4, 2023

Hi @binarygit,
Great to have you back! 🎉
And thank you for working on this issue! 🙏

Here are my test results.

The short version

Unfortunately the specification was incomplete - there is a third place for marking an order as shipped. It's listed as an action in the actions dropdown menu as well. This alone wouldn't be a problem, but unfortunately the behaviour of that action has now changed after this PR - which is why I think that this is a regression we should fix before releasing. Before your PR there was always the email sent without asking, after your PR there is no email sent without asking (using the actions dropdown). Users can't notice and this will cause irritation for sure. We should avoid that.

The long version

Places to test

  1. Button on the orders page
  2. Button on the edit order page
  3. Actions drop down list on the edit order page

Design

Note: I tested with the new design as well as the legacy one, but images are taken from the new one only.

I think we should have the checkbox active as default value because this mimics the behaviour before the PR. Users could be very annoyed by the extra clicks when following their standard workflows. To be confirmed by @openfoodfoundation/train-drivers-product-owners.

Also we have three different designs of the modal now:

Place Design
Orders page grafik
Edit order page (button) grafik
Edit order page (action) grafik

If not too much work we should unify and in my opinion we should copy this one:
grafik

To do:

  • Make checkbox active as default value.
  • Add .<br />Are you sure you want to proceed? to the header string.
  • Rephrase the text: Send a shipment/pick up notification email to the customer..
  • Use the same design for all three places.

Admin vs. super admin users

Functionality and design are identical for both users. ✔️
However I noticed that as super admin user it takes a long time until the click on the confirmation button is accepted, the modal is closed and the order is marked as shipped. I counted approx. 6 seconds, and that's long enough to try several times and even click cancel - which closes the modal immediately but still marks the order as shipped. Very confusing. Since marking the order as shipped on the /orders page is very quick even for super admins I am hoping that there is room for improvement here. Not sure what is happening during these 6 seconds though.

Action dropdown opens automatically

After marking an order as shipped via the button on the edit order page, the actions dropdown is opened automatically even though the mouse is positioned somewhere else on the screen. This is a (minor) regression as well.
Here is an example (sorry, the mouse is invisible):

Peek.2023-12-04.20-54.mp4

Conclusion

I think we should improve before merging. Would you be ok with that @binarygit?
Also awaiting some feedback from @openfoodfoundation/train-drivers-product-owners especially regarding the default setting of the checkbox..

Thanks for your work on this again! 🙏

@drummer83 drummer83 added feedback-needed and removed pr-staged-uk staging.openfoodnetwork.org.uk labels Dec 4, 2023
@RachL
Copy link
Contributor

RachL commented Dec 5, 2023

Yes good call on marking the checkbox active by default 👍 thanks @drummer83

Regarding the designs perhaps we can work on this in a separate PR? If the behavior works, it's a nice little improvement (so many people ship by mistake and then can't cancel anymore). Of course if it's fast to add it, forget me :)

Nice to have you back @binarygit 😍

@drummer83 drummer83 removed their assignment Dec 6, 2023
@binarygit
Copy link
Contributor Author

@drummer83 Thank You so much for the through testing and your remarks. I agree with you. I don't think it will take alot of time to incorporate these changes. I'll work on this this evening and should finish.

@binarygit binarygit force-pushed the send-shipment-email-optionally branch from 059de87 to 007c95b Compare December 9, 2023 11:10
@binarygit binarygit force-pushed the send-shipment-email-optionally branch from 007c95b to 8114d6e Compare December 20, 2023 14:13
@drummer83 drummer83 added the pr-staged-uk staging.openfoodnetwork.org.uk label Jan 6, 2024
@drummer83
Copy link
Contributor

Hi @binarygit,
Thanks for continuing your work on this!

Button on page /orders

  • Working fine:
    • Modal opens ✔️
    • Modal can be cancelled ✔️
    • Checkbox is active by default ✔️
    • Sending email respect the setting of the checkbox ✔️
    • Confirming the modal marks the order as shipped ✔️

Button on page /admin/orders/<order_number>/edit

  • Nothing happens when clicking the button ❌

Error invoking action "click->modal-link#open"

 TypeError: this.application.getControllerForElementAndIdentifier(...) is null
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    __trace__ inline-script-content.js:149
    r inline-script-content.js:162
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    e admin-62bef5ece206ebcb243a.js:2
    d admin-62bef5ece206ebcb243a.js:2
    M admin-62bef5ece206ebcb243a.js:2
    k admin-62bef5ece206ebcb243a.js:2
    i admin-62bef5ece206ebcb243a.js:2
    s admin-62bef5ece206ebcb243a.js:2
    promise callback*i admin-62bef5ece206ebcb243a.js:2
    s admin-62bef5ece206ebcb243a.js:2
    n admin-62bef5ece206ebcb243a.js:2
    n admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    <anonymous> admin-62bef5ece206ebcb243a.js:2
    n admin-62bef5ece206ebcb243a.js:2
    <anonymous> admin-62bef5ece206ebcb243a.js:2
    n admin-62bef5ece206ebcb243a.js:2
    <anonymous> admin-62bef5ece206ebcb243a.js:2
    <anonymous> admin-62bef5ece206ebcb243a.js:2
 

 
Object { identifier: "modal-link", controller: {…}, element: button.ship.button.icon-arrow-right
, index: 0, event: click }
[console-breadcrumbs.js:33:15](https://d2wy8f7a9ursnm.cloudfront.net/plugin-console-breadcrumbs/console-breadcrumbs.js)
    r console-breadcrumbs.js:33
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    __trace__ inline-script-content.js:149
    (Async: EventListener.handleEvent)
    r inline-script-content.js:162
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    e admin-62bef5ece206ebcb243a.js:2
    d admin-62bef5ece206ebcb243a.js:2
    M admin-62bef5ece206ebcb243a.js:2
    k admin-62bef5ece206ebcb243a.js:2
    i admin-62bef5ece206ebcb243a.js:2
    s admin-62bef5ece206ebcb243a.js:2
    (Async: promise callback)
    i admin-62bef5ece206ebcb243a.js:2
    s admin-62bef5ece206ebcb243a.js:2
    n admin-62bef5ece206ebcb243a.js:2
    n admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    value admin-62bef5ece206ebcb243a.js:2
    <anonymous> admin-62bef5ece206ebcb243a.js:2
    n admin-62bef5ece206ebcb243a.js:2
    <anonymous> admin-62bef5ece206ebcb243a.js:2
    n admin-62bef5ece206ebcb243a.js:2
    <anonymous> admin-62bef5ece206ebcb243a.js:2
    <anonymous> admin-62bef5ece206ebcb243a.js:2

Action from dropdown menu

  • Nothing happens when clicking 'Ship order' ❌

Conclusion

I'm really sorry. I think we have to look at the two failing cases. 😢

@drummer83 drummer83 removed the pr-staged-uk staging.openfoodnetwork.org.uk label Jan 6, 2024
@drummer83 drummer83 removed their assignment Jan 6, 2024
@binarygit
Copy link
Contributor Author

Thanks for testing this @drummer83 . I'll look into what's happening and push a fix.

@binarygit binarygit force-pushed the send-shipment-email-optionally branch from ecd2f9f to e7c806b Compare January 14, 2024 09:26
@binarygit binarygit force-pushed the send-shipment-email-optionally branch from e7c806b to e865f27 Compare January 14, 2024 09:48
@binarygit
Copy link
Contributor Author

binarygit commented Jan 14, 2024

@drummer83 Could you please test this again? The recent commit fixes the issues you mentioned above and also adds tests!

The meat of the commit is adding the tests which is why I am not re-requesting a review.

Also I think the whole commit history is shown as "new" because I rebased latest changes from master and there was a conflict in one file which I resolved.

@drummer83 drummer83 self-assigned this Jan 18, 2024
@drummer83 drummer83 added the pr-staged-uk staging.openfoodnetwork.org.uk label Jan 18, 2024
@drummer83
Copy link
Contributor

drummer83 commented Jan 18, 2024

Hi @binarygit,
I have tested this again! 👍

Button on page /orders

image

  • Working fine:
    • Modal opens ✔️
    • Modal can be cancelled (clicking 'Cancel' or outside of the modal) ✔️
    • Checkbox is active by default ✔️
    • Sending email respects the setting of the checkbox ✔️
    • Confirming the modal marks the order as shipped ✔️
  • Remaining issue:

Button on page /admin/orders/<order_number>/edit

image

  • Working fine:
    • Modal opens ✔️
    • Modal can be cancelled (clicking 'Cancel' or outside of the modal) ✔️
    • Checkbox is active by default ✔️
    • Sending email respects the setting of the checkbox ✔️
    • Confirming the modal marks the order as shipped ✔️
  • Remaining issues:

Action from dropdown menu

image

  • Working fine:
    • Modal opens ✔️
    • Modal can be cancelled (clicking 'Cancel' or outside of the modal) ✔️
    • Checkbox is active by default ✔️
    • Sending email respects the setting of the checkbox ✔️
    • Confirming the modal marks the order as shipped ✔️
  • Remaining issues:

Conclusion

Great! We are there now! 🥳
Thank you very much for your patience and for pushing this over the line!
I'm merging this one and will create issue for the little issues which are not related to your PR! 🚀
Thanks again!

@drummer83 drummer83 merged commit bed4057 into openfoodfoundation:master Jan 18, 2024
52 checks passed
@drummer83 drummer83 removed the pr-staged-uk staging.openfoodnetwork.org.uk label Jan 18, 2024
@mkllnk mkllnk added the user facing changes Thes pull requests affect the user experience label Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
user facing changes Thes pull requests affect the user experience
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Show pop-in alert when clicking 'ship' button from Orders screen
6 participants