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

More clean up in how we load js and css files #4287

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

frjo
Copy link
Contributor

@frjo frjo commented Dec 17, 2024

  • Remove unused document-category.js.
  • Replaced toggle-payment-block.js with alpine code.
  • Load all *media.js|css that needs jQuery in block extra or directly in base.html. Move jQuery back to the bottom of the page.
  • Merge application-form-links-new-window.js in to application-form.js.
  • Load comment_form.media on submission and project detail templates directly.
  • Remove outdated block extras and move block extra css just above block extra js in templates.

Test Steps

  • Test all roles dashboards so all needed js and css gets loaded.
  • Test submission and project pages so all needed js and css gets loaded.
  • Test that all file upload fields, especially in htmx dialog, work as they should.

@frjo frjo added Type: Maintenance Type: Patch Mini change, used in release drafter labels Dec 17, 2024
<!-- Please do not add new features that require jQuery! -->
<script src="{% static 'js/vendor/jquery.min.js' %}"></script>

{{ form.media.js }}
Copy link
Contributor Author

@frjo frjo Dec 17, 2024

Choose a reason for hiding this comment

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

@theskumar Is this ok, any drawbacks?

Seems to have no ill effect. On many pages there are no "form.media*" but then it just outputs nothing silently.

This is needed on many htmx loaded dialogs etc. Loading it here we make sure it is loaded after jQuery and available when needed.

Copy link
Member

Choose a reason for hiding this comment

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

I don't see much of an issue. I would suggest wrapping it in a if condition. I probably won't happen, but do check for duplicate rendering, one via the {{ form }} itself or in the inline template and one in the base template.

For the dialog/htmx, the file upload widget and select2 might break, they don't reinitialize if new element is added dynamically.

@frjo frjo force-pushed the maintenance/clean-up-js-files branch from b24d254 to 8863a2e Compare December 17, 2024 19:06
@frjo frjo added Status: Needs testing Tickets that need testing/qa Status: Needs dev testing 🧑‍💻 Tasks that should be tested by the dev team labels Dec 18, 2024
@wes-otf
Copy link
Contributor

wes-otf commented Dec 19, 2024

I didn't see any issues in my testing, seems pretty good!

@frjo
Copy link
Contributor Author

frjo commented Dec 20, 2024

As @theskumar predicted this PR breaks file uploads in htmx dialogs.

@frjo frjo force-pushed the maintenance/clean-up-js-files branch from 8863a2e to 7c64842 Compare December 20, 2024 08:10
@frjo frjo changed the title More clean up in how we load js files More clean up in how we load js and css files Dec 20, 2024
@frjo frjo requested a review from theskumar December 20, 2024 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Maintenance Type: Patch Mini change, used in release drafter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants