-
-
Notifications
You must be signed in to change notification settings - Fork 729
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] Stock level popout #11811
[BUU] Stock level popout #11811
Conversation
a901542
to
ef3bc57
Compare
389bc8b
to
1abedae
Compare
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.
Very nice ! 👍 There was a couple of things I didn't understand, see my comment.
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 questions! I will add a new commit.
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.
Looking good to me.
import { Application } from "stimulus"; | ||
import popout_controller from "../../../app/webpacker/controllers/popout_controller"; | ||
|
||
describe("PopoutController", () => { |
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 was wondering if we can solve this purely with CSS. And while that's possible, it wouldn't have the same functionality of reacting to down key events.
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.
So cool.. thanks we should keep that in mind wherever a simple popup is needed.
HTML also has a dialog
method, but funnily enough it requires javascript to make it work.
I wanted to use it but had a problem so had to revert to a div.
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.
Interesting, I didn't know that one. A shame that they didn't include another way of opening a modal, for example with an href, button attribute or label. So the minimal code would be:
<a href="javascript:document.getElementById('modal').showModal();">Open</a>
Some very simple Javascript could probably bind that to an attribute like data-modal-open="modal"
on any element. But it still needs Javascript while there are non-JS solutions out there.
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.
By the way, I just had to try it out and was quite happy to have this minimal example working:
<html>
<a href="javascript:document.getElementById('hello').showModal();">Show me</a>
<dialog id="hello">
Hello!
<form method="dialog">
<input type="submit" value="Nod">
</form>
</dialog>
</html>
It creates the false impression we can handle agregated stock.
But 'Array parameters do not play well with the check_box helper.' ...
The array format is generally fine, but to properly support checkboxes, we need this format with hash keys. https://guides.rubyonrails.org/form_helpers.html#understanding-parameter-naming-conventions
Also fixed it to line up properly. There's probably a better way to line it up but that's no my concern right now..
This doesn't _quite_ match the design, but would require a big CSS hack to customise it further, so I thought let's start with this.
Had to update the form controller a little bit to handle buttons. But arrow not showwing on focus. Getting some weird SCSS behaviour here.. maybe I'm trying to be too clever.
It looks like a select drop-down, so it can behave like one too.
I'm starting to think that these stimulus tests are worthless. The environment is not the same as a browser, which creates extra work to deal with the inconsistencies. And it means we're not testing real world behaviour. So these are just unit tests, but they take extra effort to put together due to the inter-relatedness with the DOM. Hmm.
Shoulda done this at the start.
I couldn't think of a simpler way to hardcode it, so now we have a clever generic method :) We can assume that hidden elements will stay hidden, but we need to check each time if an element is disabled or not.
This introduces a new 'toggle' controller, and we already had three\! So I created a generic interface that could be extended to potentially support all of them. I propose we try to reduce them all into the one controller, but won't go down the rabbit-hole just yet.. I have an idea on how to re-arrange and make it more contained, by assigning the controller only to the checkbox, and defining targets with aria-controls="", but chose to stick with Stimulus conventions for now.
b683358
to
f034e46
Compare
Rebased to resolve conflict. |
I'm not sure if we want to do this on all fields, so just scoped it here for now.
b134488
to
6bf418c
Compare
Hi @mariocarabotta , I've updated the style of the popout disabled field: the value is hidden as per the design. I've kept the style for other disabled fields the same for now. Let me know if you have a preferred style for those. edit: sorry for the contradictory message, I've fixed it now |
thanks @dacook just tested this and it's looking good! I think we can push this through (at least from a visual point of view, will let testers do more testing). |
Hi @mariocarabotta, sorry about the delayed response. Yes, I've implemented as disabled (and for the sake of your design, I made the value invisible). This is how the system currently works: we disable it but keep the old value stock level stored in the database (which does nothing). We could instead clear the stock level, which arguably makes sense. This means if you later un-check 'on demand' you would not get your old stock level back. I'm not sure if this would matter. So yes, we have two styles of disabled fields, and I agree we should unify them. I wasn't sure if this design applied everywhere else, so I didn't apply it. I think it would be a quick change to apply it everywhere, let me know if you'd like to do that. |
no need to change the backend. This issue can be tested and pushed from my side :) good work |
Staging in FR failed twice https://openfoodnetwork.slack.com/archives/CEF14NU3V/p1701425061641669 |
I've checked the shopfront is updated accordingly - I did not test if if it is working with inventory, but I guess we can see that even after merge. Aside of some weird overlap between on hand and producer column (which we can fix later) we are good to go :) No hover: With hover: @dacook is the error on staging FR relevant? Otherwise I let you rebase and merge :) |
@RachL we'll sort that one in a separate issue, already tracked
|
What? Why?
We're creating a new component as described in above issue. You can preview how it behaves here: https://www.figma.com/proto/v1zbrWDZSRd3Nqoe0SJ2Sm/Engineering-Delivery---Back-Office?page-id=708%3A5152&type=design&node-id=708-5153&viewport=278%2C123%2C0.33&t=HepYfjKLR82NcjTL-1&scaling=min-zoom&mode=design
Dev notes
I was able to keep the stimulus controllers nice and generic, and I hope to combine some existing controllers into one generic controller some day.
I wanted to make a "popout" ViewComponent with this, but remembered that
Still, it would be worth at least separating the CSS to a separate file.. 🤔
Or maybe it's worth trying to use ViewComponent and seeing if it happens to be possible.
What should Mario test?
I tried to make it behave how it seemed that it should. I covered these cases:
Checkbox style updates
Hrmm It doesn't quite match the design, but pretty close (not quite positioned right, and the border is not dark enough). It's possible to achieve the full design with a bit more effort, perhaps we can do that later (dev can see
.redesigned-input
as an example)Some checkbox labels are now un-bold.
Release notes
Changelog Category (reviewers may add a label for the release notes):
The title of the pull request will be included in the release notes.
Dependencies
Documentation updates