Skip to content

Commit

Permalink
Rethink how form.media.js is loaded.
Browse files Browse the repository at this point in the history
  • Loading branch information
frjo committed Jan 2, 2025
1 parent d5afaf0 commit 3259aab
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ <h2>{{ value }}</h2>
{% endblock %}

{% block extra_js %}
{{ form.media.js }}
{{ field_blocks_ids|json_script:"block-ids" }}
<script src="{% static 'js/determination-template.js' %}"></script>
{% endblock %}
2 changes: 1 addition & 1 deletion hypha/apply/funds/templates/funds/application_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ <h3>{% blocktrans %}Sorry this {{ page|verbose_name }} is not accepting applicat
{% endif %}
<form class="form application-form" action="/test500/" method="POST" enctype="multipart/form-data">
{% csrf_token %}

{% for field in form %}
{% if field.field %}
{% if field.field.multi_input_field %}
Expand Down Expand Up @@ -86,6 +85,7 @@ <h3>{% blocktrans %}Sorry this {{ page|verbose_name }} is not accepting applicat
{% endblock %}

{% block extra_js %}
{{ form.media.js }}
<script src="{% static 'js/application-form.js' %}"></script>
<script src="{% static 'js/tinymce-word-count.js' %}"></script>
<script src="{% static 'js/submission-form-copy.js' %}"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<div class="wrapper--sidebar--inner">
<form class="form application-form" action="" method="post" enctype="multipart/form-data">
{% csrf_token %}

{% for field in form %}
{% if field.field %}
{% if field.field.multi_input_field %}
Expand Down Expand Up @@ -45,6 +44,7 @@
{% endblock %}

{% block extra_js %}
{{ form.media.js }}
<script src="{% static 'js/application-form.js' %}"></script>
<script src="{% static 'js/tinymce-word-count.js' %}"></script>
<script src="{% static 'js/multi-input-fields.js' %}"></script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load i18n static %}
{% load i18n %}
<form
class="form {{ extra_classes }}"
method="post"
Expand All @@ -7,7 +7,7 @@
{% if action %}action="{{ action }}"{% endif %}
>
{% csrf_token %}

{{ form.media.js }}
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
Expand Down Expand Up @@ -42,5 +42,3 @@
</button>
</div>
</form>
<!-- To initiate any file upload forms. -->
<script src="{% static 'js/file-uploads.js' %}"></script>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load i18n static %}
{% load i18n %}

<form
class="form {{ extra_classes }}"
Expand All @@ -10,7 +10,7 @@
enctype="multipart/form-data"
>
{% csrf_token %}

{{ form.media.js }}
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
Expand Down Expand Up @@ -40,5 +40,3 @@
>{% trans "Cancel" %}</button>
</div>
</form>
<!-- To initiate any file upload forms. -->
<script src="{% static 'js/file-uploads.js' %}"></script>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
hx-post="{{ request.path }}"
>
{% csrf_token %}
{{ form.media.js }}
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
hx-post="{{ request.path }}"
>
{% csrf_token %}
{{ form.media.js }}
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<div class="wrapper--sidebar--inner">
<form class="form" action="" method="post" enctype="multipart/form-data">
{% csrf_token %}

{% for field in form %}
{% if field.field %}
{% include "forms/includes/field.html" %}
Expand All @@ -48,3 +47,7 @@
</div>
</div>
{% endblock %}

{% block extra_js %}
{{ form.media.js }}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
enctype="multipart/form-data"
>
{% csrf_token %}

{{ form.media.js }}
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<div class="wrapper--sidebar--inner">
<form class="form" method="post">
{% csrf_token %}

{% for field in form %}
{% if field.field %}
{% include "forms/includes/field.html" %}
Expand All @@ -37,3 +36,7 @@
</div>
</div>
{% endblock %}

{% block extra_js %}
{{ form.media.js }}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

<form class="form" action="" method="post" enctype="multipart/form-data" novalidate>
{% csrf_token %}

{% for field in form %}
{% if field.field %}
{% if field.field.multi_input_field %}
Expand Down Expand Up @@ -77,5 +76,6 @@
{% endblock %}

{% block extra_js %}
{{ form.media.js }}
<script src="{% static 'js/multi-input-fields.js' %}"></script>
{% endblock %}
2 changes: 1 addition & 1 deletion hypha/apply/review/templates/review/review_edit_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

<form id="review-form-edit" class="form form--scoreable max-w-3xl" action="" method="post" novalidate>
{% csrf_token %}

{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
Expand Down Expand Up @@ -81,5 +80,6 @@ <h2>{{ value }}</h2>
{% endblock %}

{% block extra_js %}
{{ form.media.js }}
<script src="{% static 'js/review-form-actions.js' %}"></script>
{% endblock %}
2 changes: 1 addition & 1 deletion hypha/apply/review/templates/review/review_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
{% if not has_submitted_review %}
<form id="review-form-edit" class="form form--scoreable max-w-3xl flex-1" action="" method="post">
{% csrf_token %}

{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
Expand Down Expand Up @@ -102,5 +101,6 @@ <h2>{{ value }}</h2>
{% endblock %}

{% block extra_js %}
{{ form.media.js }}
<script src="{% static 'js/review-form-actions.js' %}"></script>
{% endblock %}
2 changes: 2 additions & 0 deletions hypha/apply/users/templates/wagtailusers/users/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@
<link rel="stylesheet" href="{% static 'css/wagtail_groups_list.css' %}">
{{ block.super }}
{% endblock %}

{% block extra_js %}
{{ block.super }}
{% include "wagtailadmin/pages/_editor_js.html" %}
{{ form.media.js }}
{% endblock %}
2 changes: 1 addition & 1 deletion hypha/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

<link rel="stylesheet" href="{% static 'css/tailwind-output.css' %}">
<link rel="stylesheet" href="{% static 'css/main.css' %}">
<!-- Load any form css -->
{{ form.media.css }}
{% block extra_css %}{% endblock %}
<link rel="stylesheet" href="{% static 'css/print.css' %}" media="print">
Expand Down Expand Up @@ -126,7 +127,6 @@
<!-- Please do not add new features that require jQuery! -->
<script src="{% static 'js/vendor/jquery.min.js' %}"></script>

{{ form.media.js }}
{% block extra_js %}{% endblock %}

{% block sentry_sdk %}
Expand Down

0 comments on commit 3259aab

Please sign in to comment.