-
Notifications
You must be signed in to change notification settings - Fork 32
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
Make sidebar items toggleable and save setting in cookie #1903
Conversation
510d480
to
8488a7a
Compare
Code Climate has analyzed commit 9c70462 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 74.3%. View more on Code Climate. |
8488a7a
to
65d381c
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.
Thanks, this is very useful, and works great.
My only complaint (besides the two small suggestions below) is that this sets a cookie for every box. Wouldn't it make more sense to set a single cookie containing a serialized JSON object with box names as the key / hidden status as the value?
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.
Thanks a lot! 🎉
My only complaint (besides the two small suggestions below) is that this sets a cookie for every box. Wouldn't it make more sense to set a single cookie containing a serialized JSON object with box names as the key / hidden status as the value?
Yes, definitely agree! 👍
I would even argue we don't need the value here - just store list of all ids which should be hidden and remove elements from that list which should be shown.
Also, from a security standpoint, it's kind of risky to set cookies to dynamic keys which are derived from the document. I didn't find an immediate way to exploit this, but imagine being able to set the csrftoken
cookie to a trivial value just by managing to create a HTML element with the id csrftoken
- definitely not ideal...
0d6f32d
to
ec02774
Compare
Thank you a lot for your feedback. Originally I wanted to only commit the HTMl files, but accidentally also committed the Typescript files. If you want to you can take a look at the HTML files and check if this okay as it is. And then we can have a chat about how it would be best to set the cookies |
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.
Thanks a lot for your changes! 👍
I really like that we now re-use existing functionality.
And then we can have a chat about how it would be best to set the cookies
I committed a suggestion for the cookie handling - not really perfect yet, but maybe you can play around with it and improve it.
The goal should be to make this also re-usable for other boxes (e.g. on the dashboard) and remember their state as well.
integreat_cms/cms/templates/pages/page_form_sidebar/_page_actions_template.html
Outdated
Show resolved
Hide resolved
integreat_cms/cms/templates/pages/page_form_sidebar/_page_minor_edit_template.html
Outdated
Show resolved
Hide resolved
integreat_cms/cms/templates/pages/page_form_sidebar/_page_settings_template.html
Outdated
Show resolved
Hide resolved
integreat_cms/cms/templates/pages/page_form_sidebar/_page_translator_view_template.html
Outdated
Show resolved
Hide resolved
80c1917
to
36c50e6
Compare
d7020f8
to
d82252f
Compare
d82252f
to
40748a3
Compare
Co-authored-by: Timo Ludwig <ludwig@integreat-app.de>
40748a3
to
9c70462
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.
Thanks a lot, really cool feature! 🚀
I noticed that it does not fix #1876 completely (since the issue was about all content forms, also events and POIs), but I think we should merge this PR now since it's a good improvement on its own, and add the event and poi forms later.
I also noticed that it creates problems if the sidebar has only one column (see #1769 (comment)), but I also think it could be part of the separate issue to fix this.
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.
Thank you 👍 Cool feature 😃
Short description
This PR adds the functionality to make items in the sidebar of content forms expandable and save the setting as a cookie.
Proposed changes
Side effects
Resolved issues
Fixes (partially): #1876
Pull Request Review Guidelines