Skip to content

Commit a972eea

Browse files
authored
More clean up in how we load js and css files (#4287)
- [x] Remove unused document-category.js. - [x] Replaced toggle-payment-block.js with alpine code. - [x] 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. - [x] Merge application-form-links-new-window.js in to application-form.js. - [x] Load comment_form.media on submission and project detail templates directly. - [x] Remove outdated block extras and move block extra css just above block extra js in templates.
1 parent 4086c24 commit a972eea

40 files changed

+94
-160
lines changed

hypha/apply/activity/templates/activity/include/comment_form.html

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
>
1111
{% csrf_token %}
1212

13-
{{ comment_form.media }}
1413
{% for hidden in comment_form.hidden_fields %}
1514
{{ hidden }}
1615
{% endfor %}

hypha/apply/dashboard/templates/dashboard/contracting_dashboard.html

-5
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,3 @@ <h4 class="heading heading--normal">{% trans "PAFs for review" %}</h4>
3434
{% endif %}
3535
</div>
3636
{% endblock %}
37-
38-
{% block extra_js %}
39-
<script src="{% static 'js/submission-filters.js' %}"></script>
40-
<script src="{% static 'js/tabs.js' %}"></script>
41-
{% endblock %}

hypha/apply/dashboard/templates/dashboard/finance_dashboard.html

-5
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,3 @@ <h4 class="heading heading--normal">{% trans "PAFs for review" %}</h4>
100100

101101
</div>
102102
{% endblock %}
103-
104-
{% block extra_js %}
105-
{{ my_reviewed.filterset.form.media.js }}
106-
<script src="{% static 'js/submission-filters.js' %}"></script>
107-
{% endblock %}

hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
{% load render_table from django_tables2 %}
33
{% load i18n static statusbar_tags workflow_tags %}
44

5-
{% block extra_css %}
6-
{{ filter.form.media.css }}
7-
{% endblock %}
8-
95
{% block title %}{% trans "Dashboard" %}{% endblock %}
106

117
{% block content %}
@@ -90,6 +86,10 @@ <h2 class="text-xl mb-2">
9086

9187
{% endblock %}
9288

89+
{% block extra_css %}
90+
{{ filter.form.media.css }}
91+
{% endblock %}
92+
9393
{% block extra_js %}
9494
{{ filter.form.media.js }}
9595
<script src="{% static 'js/submission-filters.js' %}"></script>

hypha/apply/dashboard/templates/dashboard/staff_dashboard.html

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
{% load render_table from django_tables2 %}
33
{% load i18n static nh3_tags markdown_tags heroicons %}
44

5-
{% block extra_css %}
6-
{{ my_reviewed.filterset.form.media.css }}
7-
{% endblock %}
8-
95
{% block title %}{% trans "Dashboard" %}{% endblock %}
106

117
{% block content %}
@@ -136,9 +132,12 @@ <h2 class="heading heading--normal">{{ review_heading }}</h2>
136132
</div>
137133
{% endblock %}
138134

135+
{% block extra_css %}
136+
{{ my_reviewed.filterset.form.media.css }}
137+
{% endblock %}
138+
139139
{% block extra_js %}
140140
{{ my_reviewed.filterset.form.media.js }}
141141
<script src="{% static 'js/all-submissions-table.js' %}"></script>
142142
<script src="{% static 'js/submission-filters.js' %}"></script>
143-
<script src="{% static 'js/tabs.js' %}"></script>
144143
{% endblock %}

hypha/apply/determinations/templates/determinations/base_determination_form.html

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
action="" method="post"
3131
x-data="{ isFormSubmitting: false }"
3232
x-on:submit="isFormSubmitting = true">
33-
{{ form.media }}
3433
{% csrf_token %}
3534
{% for hidden in form.hidden_fields %}
3635
{{ hidden }}

hypha/apply/funds/templates/funds/application_base.html

+1-5
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ <h3>{% blocktrans %}Sorry this {{ page|verbose_name }} is not accepting applicat
3939
</a>
4040
{% endif %}
4141
<form class="form application-form" action="/test500/" method="POST" enctype="multipart/form-data">
42-
{{ form.media }}
4342
{% csrf_token %}
44-
4543
{% for field in form %}
4644
{% if field.field %}
4745
{% if field.field.multi_input_field %}
@@ -62,7 +60,7 @@ <h3>{% blocktrans %}Sorry this {{ page|verbose_name }} is not accepting applicat
6260
{% endif %}
6361
{% endfor %}
6462

65-
{# Hidden fields needed e.g. for django-file-form. See `StreamBaseForm.hidden_fields` #}
63+
{# Hidden fields needed e.g. for django-file-form. See `StreamBaseForm.hidden_fields` #}
6664
{% for hidden_field in form.hidden_fields %}
6765
{{ hidden_field }}
6866
{% endfor %}
@@ -88,9 +86,7 @@ <h3>{% blocktrans %}Sorry this {{ page|verbose_name }} is not accepting applicat
8886

8987
{% block extra_js %}
9088
<script src="{% static 'js/application-form.js' %}"></script>
91-
<script src="{% static 'js/tinymce-word-count.js' %}"></script>
9289
<script src="{% static 'js/submission-form-copy.js' %}"></script>
93-
<script src="{% static 'js/application-form-links-new-window.js' %}"></script>
9490
{% if not show_all_group_fields %}
9591
<script src="{% static 'js/form-group-toggle.js' %}"></script>
9692
{% endif %}

hypha/apply/funds/templates/funds/applicationsubmission_community_detail.html

-5
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,3 @@ <h5>{% trans "Reviews & assignees" %}</h5>
2222

2323
{% block related %}
2424
{% endblock %}
25-
26-
{% block extra_js %}
27-
{{ reviewer_form.media.js }}
28-
{{ block.super }}
29-
{% endblock %}

hypha/apply/funds/templates/funds/applicationsubmission_detail.html

+5
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,12 @@ <h4 class="m-0 sr-only">{% trans "Add communication" %}</h4>
261261
</div>
262262
{% endblock %}
263263

264+
{% block extra_css %}
265+
{{ comment_form.media.css }}
266+
{% endblock %}
267+
264268
{% block extra_js %}
269+
{{ comment_form.media.js }}
265270
<script src="{% static 'js/tabs.js' %}"></script>
266271
<script src="{% static 'js/submission-text-cleanup.js' %}"></script>
267272
<script>

hypha/apply/funds/templates/funds/applicationsubmission_form.html

+3-5
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
<div class="wrapper--sidebar--inner">
1515
<form class="form application-form" action="" method="post" enctype="multipart/form-data">
1616
{% csrf_token %}
17-
{{ form.media }}
18-
1917
{% for field in form %}
2018
{% if field.field %}
2119
{% if field.field.multi_input_field %}
@@ -28,7 +26,7 @@
2826
{% endif %}
2927
{% endfor %}
3028

31-
{# Hidden fields needed e.g. for django-file-form. See `StreamBaseForm.hidden_fields` #}
29+
{# Hidden fields needed e.g. for django-file-form. See `StreamBaseForm.hidden_fields` #}
3230
{% for hidden_field in form.hidden_fields %}
3331
{{ hidden_field }}
3432
{% endfor %}
@@ -40,16 +38,16 @@
4038
{% endfor %}
4139
</div>
4240
</form>
41+
<p class="wrapper--error message-no-js js-hidden">{% trans "You must have Javascript enabled to use this form." %}</p>
4342
</div>
4443
</div>
4544

4645
{% endblock %}
4746

4847
{% block extra_js %}
49-
<script src="{% static 'js/tinymce-word-count.js' %}"></script>
48+
<script src="{% static 'js/application-form.js' %}"></script>
5049
<script src="{% static 'js/multi-input-fields.js' %}"></script>
5150
<script src="{% static 'js/submission-form-copy.js' %}"></script>
52-
<script src="{% static 'js/application-form-links-new-window.js' %}"></script>
5351
{% if not show_all_group_fields %}
5452
<script src="{% static 'js/form-group-toggle.js' %}"></script>
5553
{% endif %}

hypha/apply/funds/templates/funds/applicationsubmission_reviewer_detail.html

-5
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,3 @@ <h5>{% trans "Reviews & assignees" %}</h5>
2929

3030
{% block related %}
3131
{% endblock %}
32-
33-
{% block extra_js %}
34-
{{ reviewer_form.media.js }}
35-
{{ block.super }}
36-
{% endblock %}

hypha/apply/funds/templates/funds/base_submissions_table.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
{% load static %}
33
{% load render_table from django_tables2 %}
44

5-
{% block extra_css %}
6-
{{ filter.form.media.css }}
7-
{% endblock %}
8-
95
{% block content %}
106
{% block table %}
117
{% include "funds/includes/table_filter_and_search.html" with filter_form=filter_form search_term=search_term use_search=True filter_action=filter_action filter_classes="filters-open" can_export=can_export %}
@@ -14,6 +10,10 @@
1410
{% endblock %}
1511
{% endblock %}
1612

13+
{% block extra_css %}
14+
{{ filter.form.media.css }}
15+
{% endblock %}
16+
1717
{% block extra_js %}
1818
{{ filter.form.media.js }}
1919
<script src="{% static 'js/all-submissions-table.js' %}"></script>

hypha/apply/funds/templates/funds/grouped_application_list.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
{% extends "base-apply.html" %}
22
{% load i18n static %}
33

4-
{% block extra_css %}
5-
{{ filter.form.media.css }}
6-
{% endblock %}
7-
84
{% block content %}
95

106
{% adminbar %}
@@ -14,6 +10,10 @@
1410
<div id="grouped-applications-list"></div>
1511
{% endblock %}
1612

13+
{% block extra_css %}
14+
{{ filter.form.media.css }}
15+
{% endblock %}
16+
1717
{% block extra_js %}
1818
{{ filter.form.media.js }}
1919
<script src="{% static 'js/all-submissions-table.js' %}"></script>

hypha/apply/funds/templates/funds/includes/delegated_form_base.html

-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
{% if action %}action="{{ action }}"{% endif %}
88
>
99
{% csrf_token %}
10-
11-
{{ form.media }}
1210
{% for hidden in form.hidden_fields %}
1311
{{ hidden }}
1412
{% endfor %}
@@ -42,5 +40,4 @@
4240
{{ value }}
4341
</button>
4442
</div>
45-
4643
</form>

hypha/apply/funds/templates/funds/includes/dialog_form_base.html

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
enctype="multipart/form-data"
1111
>
1212
{% csrf_token %}
13-
14-
{{ form.media }}
1513
{% for hidden in form.hidden_fields %}
1614
{{ hidden }}
1715
{% endfor %}

hypha/apply/funds/templates/funds/includes/translate_application_form.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
hx-post="{{ request.path }}"
99
>
1010
{% csrf_token %}
11-
{{ form.media }}
1211
{% for hidden in form.hidden_fields %}
1312
{{ hidden }}
1413
{% endfor %}
@@ -122,4 +121,4 @@
122121
showClearBtn(true);
123122
}
124123
})
125-
</script>
124+
</script>

hypha/apply/funds/templates/funds/includes/update_reviewer_form.html

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
hx-post="{{ request.path }}"
1010
>
1111
{% csrf_token %}
12-
{{ form.media }}
1312
{% for hidden in form.hidden_fields %}
1413
{{ hidden }}
1514
{% endfor %}

hypha/apply/funds/templates/funds/rounds.html

+3-6
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@
44

55
{% block title %}{% trans "Rounds" %}{% endblock %}
66

7-
{% block extra_css %}
8-
{{ filter.form.media.css }}
9-
{% endblock %}
10-
11-
127
{% block content %}
13-
148
{% adminbar %}
159
{% slot header %}{% trans "Rounds" %}{% endslot %}
1610
{% slot sub_heading %}{% trans "Explore current and past rounds" %}{% endslot %}
@@ -20,7 +14,10 @@
2014
{% include "funds/includes/table_filter_and_search.html" with filter_form=filter_form search_term=search_term can_export=can_export %}
2115
{% render_table table %}
2216
</div>
17+
{% endblock %}
2318

19+
{% block extra_css %}
20+
{{ filter.form.media.css }}
2421
{% endblock %}
2522

2623
{% block extra_js %}

hypha/apply/projects/templates/application_projects/includes/invoices.html

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</a>
1212
{% endif %}
1313
</div>
14-
<div class="data-block__body">
14+
<div class="data-block__body" x-data="{ showrejected: false }">
1515
{% if object.invoices.not_rejected %}
1616
<table class="data-block__table">
1717
<thead>
@@ -33,10 +33,11 @@
3333

3434
{% if object.invoices.rejected %}
3535
<p class="data-block__rejected">
36-
<a class="data-block__rejected-link js-payment-block-rejected-link" href="#">{% trans "Show rejected" %}</a>
36+
{% trans "Show rejected" as showrejectedtext %}{% trans "Hide rejected" as hiderejectedtext %}
37+
<a class="data-block__rejected-link" href="#" @click="showrejected = ! showrejected" x-text="showrejected ? '{{ hiderejectedtext }}' : '{{ showrejectedtext }}'">{{ showrejectedtext }}</a>
3738
</p>
3839

39-
<table class="data-block__table is-hidden js-payment-block-rejected-table">
40+
<table class="data-block__table" x-show="showrejected" x-transition>
4041
<thead>
4142
<tr>
4243
<th class="data-block__table-date">{% trans "Date submitted" %}</th>

hypha/apply/projects/templates/application_projects/invoice_form.html

-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
<div class="wrapper--sidebar--inner">
3434
<form class="form" action="" method="post" enctype="multipart/form-data">
3535
{% csrf_token %}
36-
{{ form.media }}
37-
3836
{% for field in form %}
3937
{% if field.field %}
4038
{% include "forms/includes/field.html" %}

hypha/apply/projects/templates/application_projects/invoice_list.html

-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
{% block title %}{% trans "Invoices" %}{% endblock %}
77

88
{% block content %}
9-
109
{% adminbar %}
1110
{% slot header %}{% trans "All Invoices" %} ({{ table.rows|length }}){% endslot %}
1211
{% slot sub_heading %}{% trans "View, search and filter all project invoices" %}{% endslot %}
@@ -28,7 +27,6 @@
2827
<p>{% trans "No Invoices available" %}</p>
2928
{% endif %}
3029
</div>
31-
3230
{% endblock content %}
3331

3432
{% block extra_css %}

hypha/apply/projects/templates/application_projects/modals/report_frequency_config.html

-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@
4242
enctype="multipart/form-data"
4343
>
4444
{% csrf_token %}
45-
46-
{{ form.media }}
4745
{% for hidden in form.hidden_fields %}
4846
{{ hidden }}
4947
{% endfor %}

hypha/apply/projects/templates/application_projects/project_approval_detail.html

-8
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33

44
{% block title %}{{ object.title }}{% endblock %}
55

6-
{% block extra_css %}
7-
{{ reviewer_form.media.css }}
8-
{% endblock %}
9-
106
{% block content %}
117
{% adminbar %}
128
{% slot back_link %}
@@ -150,7 +146,3 @@ <h5>{% trans "Actions to take" %}</h5>
150146
</div>
151147
</div>
152148
{% endblock content %}
153-
154-
{% block extra_js %}
155-
{{ block.super }}
156-
{% endblock %}

0 commit comments

Comments
 (0)