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
[BUU] Change name of my products 🚧 #11208
[BUU] Change name of my products 🚧 #11208
Conversation
b36b21b
to
f205f0a
Compare
f205f0a
to
5775aff
Compare
f6a64f0
to
d6ccd95
Compare
862114c
to
91f0c1f
Compare
868b648
to
73bfe63
Compare
90fdda1
to
e9640d7
Compare
91f0c1f
to
052b7c7
Compare
bcd809a
to
b3a7e14
Compare
b3a7e14
to
32414d4
Compare
Oops, I missed a broken spec. JB I think it would still be worth your review if you have the chance. I'll next look at it on Tuesday. |
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 missed a broken spec.
I suppose this was a flaky one?
BTW, real nice job!
Quick comments:
- Should we hide
form-actions
toolbar if no modification are currently made? - I tried to modify a product name, but I received an error. Even if I don't change any name, and click on "Save changes" button, I received an error ("
#<ActiveModel::Error attribute=base, type=Image attachment is not a valid image., options={}>
I suppose this is related to an old product on my page?
).broadcast | ||
morph :nothing | ||
|
||
# dunno why this doesn't work. |
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.
It's not clear to me as well.
|
||
// "Naked" inputs. Row hover helps reveal them. | ||
input { | ||
border-color: transparent; |
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.
No need to change background color as well?
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.
Good question. Currently, the input background and the row background are white.
When we have row:hover
, background-color: $light-grey
; and we rely on the input
background-color: white
.
So technically, the code doesn't ensure the inputs are naked (eg if one of the background colours change in the future), and I think we could add more rules to ensure that. But I don't think we should add more style rules until we need them.
@@ -220,11 +220,13 @@ Metrics/ClassLength: | |||
- 'app/models/spree/user.rb' | |||
- 'app/models/spree/variant.rb' | |||
- 'app/models/spree/zone.rb' | |||
- 'app/reflexes/products_reflex.rb' |
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.
seems legit 👌
(For now at least,) we use one big standard Rails form, and ModelSet to update each record. Submitting with Reflex allows us to manage the loading state along with the rest of the page (although I would rather use the built in HTTP POST standard). Aria-label makes it a bit easier for testing (and accessibility software of course!). Technically it should have been aria-labelledby="id_of_column_header" but that would have resulted in more HTML and processing, which seemed silly. Best viewed with whitespace ignored.
Perhaps this should be tested in the system spec too ("I can rename a product and still see it after saving"). But I'd like to find the compromise to avoid bulking up system specs too much. I think it's covered well enough by the reflex spec?
Before, it would abort after the first invalid record, and it doesn't tell you about the others. This way you find out about all at once. This affects the existing Bulk Edit Products screen, and can result in longer error messages than before. But I would argue that's a good thing. I think this is technically optional for BUU at this point, but a helpful improvement.
But it's not perfect. Can we use a pseudo element instead?
Inputs add extra padding, so we add the same padding to the header. Using an opt-in class, because I think we won't want this on all columns.
As much as I hate to add to this list, this is still a work in progress so it's not worth refactoring at this point.
32414d4
to
2edf504
Compare
Thanks @jibees,
For sure. I plan to do this when implementing the modified/"dirty" field state.
Yes I would guess so. It might be a good time to refresh your dev database. |
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 have a couple of suggestions but this is work in progress and it can all be changed later.
app/reflexes/products_reflex.rb
Outdated
# TO Consider: We could actually rearrange the form to suit that format more directly. eg: | ||
# '[products][0][id]' (hidden field) | ||
# '[products][0][name]' |
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 guess that this is necessary when you want to support creating several new products in the same form. Then you can't use the id as index. But I find this approach of stuffing all kind of data into one action unnecessarily complex. Doing lots of stuff at once has the challenge of lots of things potentially failing and providing lots of error feedback while also adding a lot of logic regarding different actions to one thing. In this case the ModelSet encapsulates it quite well but it's still complicated.
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.
Good points. At this stage, we want to provide that behaviour (updating multiple at once) so I think it makes sense to use the one form, for now. So far we haven't hit any issues with this method, so I'd avoid complicating it. For now..
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.
What about new products or deleting products? Will there be a separate form or UX?
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 assume, new products will continue to be with a specific form, and deleting would be one-by-one.
But if we needed to do it in bulk here, then we could.. but like you say it makes things complicated!
Rails is clever enough to not query the database without ids Co-authored-by: Maikel <maikel@email.org.au>
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.
Great, thank you!
Hi @dacook, |
Ok, I've staged the PR just as a quick check whether it staged with no issues, and made some bulk product edits, with the feature toggle on and off. Nothing unusual, so merging not to block this work 👍 |
Thanks both! I think I wasn't aware of the |
What? Why?
Adding a new bulk update form for product names, submitting using Reflex.
You can edit the name of any product (but we don't yet highlight modified/unsaved fields)
On saving, any modified products will attempt to update
Any errors are captured and some information is displayed to the user (more to be added in next PR).
On successful save, the table reloads to show saved fields (but there's no success message yet).
Editing:
Errors:
What should we test?
No testing required, this is a work in progress behind feature toggle.
Release notes
Changelog Category: Feature toggle