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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUU] Showing error summary at top of form #11750

Merged

Conversation

dacook
Copy link
Member

@dacook dacook commented Nov 2, 2023

What? Why?

Presenting an error summary at the top of the form when performing a bulk update. And lots of necessary refactors.

This makes a small change to the backend of the current bulk edit products screen, but doesn't change any behaviour, so I think doesn't need manual testing.

What should we test? [admin_style_v3]

Changes listed below (Unchecked parts are not fully implemented).

1. When product has two fields updated:

  • one has error and other is valid. Neither are saved until error is corrected. (empty name, and changed unit)
    Screen Shot 2023-11-02 at 4 31 16 pm

2. When product and associated variant are updated, but there are errors:
Neither should be saved, summary should show, and unsaved values retained with red/orange border.
But these fail due to #11748

  • product has error, variant has error. 馃唶 Variant values are lost
  • product has error, variant is valid. 馃唶 Variant values are lost
  • product is valid, variant has error. 馃唶 Product got saved
    Screen Shot 2023-11-02 at 4 30 21 pm

3. When multiple products are updated

  • product 1 has error, product 2 has error
    Screen Shot 2023-11-02 at 4 26 00 pm
  • product 1 has error, product 2 is valid
    Screen Shot 2023-11-02 at 4 26 27 pm
  • product 1 is valid, product 2 has error
    Screen Shot 2023-11-02 at 4 27 04 pm

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.

It's generally expected that a #save method will return true on succes, and false on failure.
I found this in my stashes
Trying to cover it more comprehensively, and revealing we have a lot of behaviour to update.
Products and their variants should always get saved (or not saved) together. This is considered the most intuitive behaviour.

There's still duplication with the "variant has error" context, but I try to avoid nesting shared_examples, it starts to get ugly. Happy to discuss though.
@dacook dacook force-pushed the buu-editing-part5c-show-summary-11059 branch 3 times, most recently from 6cb7335 to 093758e Compare November 2, 2023 05:59
@dacook dacook marked this pull request as ready for review November 2, 2023 05:59
@dacook dacook changed the title [BUU] [BUU] Showing error summary at top of form Nov 2, 2023
@dacook dacook force-pushed the buu-editing-part5c-show-summary-11059 branch from 093758e to 8a88734 Compare November 3, 2023 02:26
Ignoring variants for now.
Best viewed with whitespace ignored.
This makes it easier to control in the next commit.
I chose to use the 'elements' collection rather than choosing which elements to include (ie this supports inputs, textareas, buttons and anything else I didn't think of). It could be a bit simpler if we assume the element is a form. Even simpler if it's a fieldset (that has a disabled property). But I didn't want to limit it too much.

Unfortunately JS is quite ugly compared to Ruby. And 'prettier' made it uglier in my opinion.
@dacook dacook force-pushed the buu-editing-part5c-show-summary-11059 branch from 8a88734 to 7fe6f3f Compare November 3, 2023 03:33
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.

Nice!

@mkllnk mkllnk merged commit eef7df8 into openfoodfoundation:master Nov 3, 2023
50 checks passed
@dacook dacook added the technical changes only These pull requests do not contain user facing changes and are grouped in release notes label Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
technical changes only These pull requests do not contain user facing changes and are grouped in release notes
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[BUU] Change name, SKU and price of my products and variants
2 participants