Skip to content

Commit f567f59

Browse files
committed
batch action, action-bar, invoices table
1 parent 9ab09e8 commit f567f59

13 files changed

Lines changed: 79 additions & 257 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
{% if paf_for_review.count %}
2626
<div id="paf_for_review" class="wrapper wrapper--bottom-space">
27-
<h4 class="heading heading--normal">{% trans "PAFs for review" %}</h4>
27+
<h2 class="card-title">{% trans "PAFs for review" %}</h2>
2828
{% render_table paf_for_review.table %}
2929
</div>
3030
{% endif %}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ <h2 class="mb-2 card-title">{% trans 'Invoices' %} </h2>
8989

9090
{% if paf_for_review.count %}
9191
<div id="paf_for_review" class="wrapper wrapper--bottom-space">
92-
<h4 class="heading heading--normal">{% trans "PAFs for review" %}</h4>
92+
<h2 class="card-title">{% trans "PAFs for review" %}</h2>
9393
{% render_table paf_for_review.table %}
9494
</div>
9595
{% endif %}

hypha/apply/dashboard/templates/dashboard/partner_dashboard.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
<div class="wrapper wrapper--large wrapper--inner-space-medium">
1717

1818
<div class="wrapper wrapper--bottom-space">
19-
<h4 class="heading heading--normal">
19+
<h2 class="card-title">
2020
{% trans "You are the partner of these submissions" %} <span class="py-0.5 px-2.5 text-sm font-medium text-blue-800 bg-blue-100 rounded-sm dark:text-blue-300 dark:bg-blue-900 me-2">{{ partner_submissions_count }}</span>
21-
</h4>
21+
</h2>
2222

2323
{% if partner_submissions.data %}
2424
{% render_table partner_submissions %}
@@ -28,7 +28,7 @@ <h4 class="heading heading--normal">
2828
</div>
2929

3030
<div class="wrapper wrapper--bottom-space">
31-
<h4 class="heading heading--normal">{% trans "Your active submissions" %}</h4>
31+
<h2 class="card-title">{% trans "Your active submissions" %}</h2>
3232
{% for submission in my_submissions %}
3333
<div class="list-row">
3434
<div class="wrapper wrapper--status-bar-inner">
@@ -55,7 +55,7 @@ <h6 class="heading heading--no-margin heading--submission-meta"><span>{% trans "
5555

5656
{% if my_inactive_submissions.data %}
5757
<div class="wrapper wrapper--bottom-space">
58-
<h4 class="heading heading--normal">{% trans "Submission history" %}</h4>
58+
<h2 class="card-title">{% trans "Submission history" %}</h2>
5959
{% render_table my_inactive_submissions %}
6060
</div>
6161
{% endif %}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ <h3 class="mb-2 text-xl">
111111

112112
{% if PROJECTS_ENABLED and active_invoices.count %}
113113
<div id="active-invoices" class="wrapper wrapper--bottom-space">
114-
<h4 class="heading heading--normal">{% trans "Active Invoices" %}</h4>
114+
<h2 class="card-title">{% trans "Active Invoices" %}</h2>
115115
{% render_table active_invoices.table %}
116116
</div>
117117
{% endif %}

hypha/apply/funds/templates/funds/includes/search-input.html

Lines changed: 0 additions & 23 deletions
This file was deleted.

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

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,53 @@
22
{% load querystrings table_tags static %}
33

44
{% if heading or use_search %}
5-
<div class="wrapper wrapper--table-actions js-table-actions">
6-
<div class="actions-bar">
7-
{# Left #}
8-
<div class="actions-bar__inner actions-bar__inner--left">
9-
{% if heading %}
10-
<h2 class="mb-2 text-xl">{{ heading }}</h2>
11-
{% endif %}
5+
<div class="flex flex-wrap gap-4 justify-between items-center w-full actions-bar js-table-actions">
6+
{# Left #}
7+
<div class="actions-bar__inner actions-bar__inner--left">
8+
{% if heading %}
9+
<h2 class="mb-2 text-xl">{{ heading }}</h2>
10+
{% endif %}
1211

13-
</div>
12+
{% if invoice_batch_actions %}
13+
<div class="items-center card-actions actions-bar__inner--batch-actions">
14+
<span class="label ps-2">
15+
<span data-js-batch-actions="total-selections">0</span> {% trans "selected" %}
16+
</span>
17+
<button
18+
class="btn btn-sm"
19+
href="{% url 'apply:projects:bulk_invoice_status_update' %}"
20+
hx-target="#htmx-modal"
21+
data-js-batch-actions="invoice-update-status"
22+
>
23+
{% heroicon_micro "arrows-right-left" class="fill-fg-muted" aria_hidden=true %}
24+
{% trans "Update status" %}
25+
</button>
26+
</div>
27+
{% endif %}
28+
</div>
1429

15-
{# Right #}
16-
<div class="flex gap-4 items-center">
17-
{% if use_search|default:False %}
18-
{% include "funds/includes/search-input.html" %}
19-
{% endif %}
20-
</div>
30+
{# Right #}
31+
<div class="flex gap-4 items-center">
32+
{% if use_search|default:False %}
33+
<form
34+
action="{{ search_action }}"
35+
method="get"
36+
role="search"
37+
class="relative"
38+
>
39+
<label class="flex gap-2 items-center w-auto input input-sm input-border">
40+
{% heroicon_mini "magnifying-glass" size=20 class="opacity-50 h-[1em]" aria_hidden=true %}
41+
<input
42+
type="search"
43+
placeholder="{% trans 'Search...' %}"
44+
name="query"
45+
{% if search_term %}value="{{ request.GET.query }}"{% endif %}
46+
aria-label="{% trans 'Search input' %}"
47+
class="sm:w-auto w-[15ch]"
48+
>
49+
</label>
50+
</form>
51+
{% endif %}
2152
</div>
2253
</div>
2354
{% endif %}

hypha/apply/projects/reports/tables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class Meta:
6565
sequence = ["project", "report_period", "..."]
6666
model = Report
6767
template_name = "application_projects/tables/table.html"
68-
attrs = {"class": "table overflow-x-auto projects-table"}
68+
attrs = {"class": "table border-x border-b mb-2 rounded-b-box projects-table"}
6969

7070
def render_report_period(self, record):
7171
return f"{record.start} to {record.end_date}"

hypha/apply/projects/tables.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Meta:
5454
model = Invoice
5555
order_by = ["-requested_at"]
5656
template_name = "application_projects/tables/table.html"
57-
attrs = {"class": "table overflow-x-auto invoices-table"}
57+
attrs = {"class": "table invoices-table"}
5858

5959
def render_project(self, record):
6060
return get_project_title(record.project)
@@ -73,10 +73,10 @@ class FinanceInvoiceTable(BaseInvoiceTable):
7373
class Meta:
7474
fields = [
7575
"selected",
76+
"invoice_number",
7677
"invoice_date",
7778
"requested_at",
7879
"vendor_name",
79-
"invoice_number",
8080
"invoice_amount",
8181
"status",
8282
]
@@ -85,7 +85,7 @@ class Meta:
8585
sequence = fields
8686
order_by = ["-requested_at", "invoice_date"]
8787
template_name = "application_projects/tables/table.html"
88-
attrs = {"class": "table overflow-x-auto invoices-table"}
88+
attrs = {"class": "table border-x border-b mb-2 invoices-table"}
8989
row_attrs = {
9090
"data-record-id": lambda record: record.id,
9191
}
@@ -121,7 +121,7 @@ class Meta:
121121
sequence = fields
122122
order_by = ["-requested_at"]
123123
template_name = "application_projects/tables/table.html"
124-
attrs = {"class": "table overflow-x-auto invoices-table"}
124+
attrs = {"class": "table invoices-table"}
125125
row_attrs = {
126126
"data-record-id": lambda record: record.id,
127127
}
@@ -182,7 +182,7 @@ class Meta:
182182
model = Project
183183
template_name = "application_projects/tables/table.html"
184184
orderable = False
185-
attrs = {"class": "table overflow-x-auto projects-table"}
185+
attrs = {"class": "table border-x border-b mb-2 rounded-b-box projects-table"}
186186

187187

188188
class ProjectsAssigneeDashboardTable(BaseProjectsTable):
@@ -198,7 +198,7 @@ class Meta:
198198
model = Project
199199
orderable = False
200200
exclude = ["status"]
201-
attrs = {"class": "table overflow-x-auto projects-table"}
201+
attrs = {"class": "table border-x border-b mb-2 rounded-b-box projects-table"}
202202

203203

204204
class PAFForReviewDashboardTable(tables.Table):
@@ -261,4 +261,4 @@ class Meta:
261261
orderable = True
262262
order_by = ("end_date",)
263263
template_name = "application_projects/tables/table.html"
264-
attrs = {"class": "table overflow-x-auto projects-table"}
264+
attrs = {"class": "table border-x border-b mb-2 rounded-b-box projects-table"}

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,10 @@
1111
{% slot sub_heading %}{% trans "View, search and filter all project invoices" %}{% endslot %}
1212
{% endadminbar %}
1313

14-
<div class="flex justify-between mt-2">
15-
<div class="text-sm breadcrumbs">
16-
<ul>
17-
<li><a href="{% url 'dashboard:dashboard' %}">Home</a></li>
18-
<li><a href="{% url 'apply:projects:all' %}">Projects</a></li>
19-
<li>Invoices</li>
20-
</ul>
21-
</div>
22-
{% include "funds/includes/search-input.html" %}
23-
</div>
24-
2514
<div class="mt-4 wrapper wrapper--large">
26-
2715
{% if table %}
2816
{% trans "invoices" as search_placeholder %}
29-
{% include "funds/includes/table_filter_and_search.html" with search_term=search_term use_search=false invoice_batch_actions=True search_placeholder=search_placeholder %}
17+
{% include "funds/includes/table_filter_and_search.html" with search_term=search_term use_search=True invoice_batch_actions=True search_placeholder=search_placeholder %}
3018
{% render_table table %}
3119
{% else %}
3220
<p>{% trans "No Invoices available" %}</p>

hypha/static_src/javascript/batch-actions.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
const $body = $("body");
44
const $checkbox = $(".js-batch-select");
55
const $allCheckboxInput = $(".js-batch-select-all");
6-
const $batchButtons = $(".js-batch-button");
7-
const $batchInvoiceProgress = $(".js-batch-invoice-progress");
6+
const $batchButtons = $("[data-js-batch-actions]");
87
const $batchTitlesList = $(".js-batch-titles");
98
const $batchTitleCount = $(".js-batch-title-count");
109
const $hiddenIDlist = $(".js-submissions-id");
@@ -73,10 +72,6 @@
7372
});
7473
});
7574

76-
$batchInvoiceProgress.click(function () {
77-
updateInvoiceProgressButton();
78-
});
79-
8075
// show/hide the list of actions
8176
$toggleBatchList.click((e) => {
8277
e.preventDefault();
@@ -131,15 +126,14 @@
131126
}
132127
});
133128

129+
const batchInvoiceProgressBtn = document.querySelector(
130+
"[data-js-batch-actions='invoice-update-status']"
131+
);
132+
134133
if (!actions || actions.length === 0) {
135-
$batchInvoiceProgress.attr("disabled", "disabled");
136-
$batchInvoiceProgress.attr(
137-
"data-tooltip",
138-
"Status changes can't be applied to Invoices with this combination of statuses"
139-
);
134+
batchInvoiceProgressBtn.setAttribute("disabled", "disabled");
140135
} else {
141-
$batchInvoiceProgress.removeAttr("disabled");
142-
$batchInvoiceProgress.removeAttr("data-tooltip");
136+
batchInvoiceProgressBtn.removeAttribute("disabled");
143137
}
144138
}
145139

@@ -158,7 +152,14 @@
158152
* Update the count of selected checkboxes.
159153
*/
160154
function updateCount() {
161-
$(".js-total-actions").html($(".js-batch-select:checked").length);
155+
const totalSelectionsElement = document.querySelector(
156+
'[data-js-batch-actions="total-selections"]'
157+
);
158+
if (totalSelectionsElement) {
159+
totalSelectionsElement.innerHTML = document.querySelectorAll(
160+
".js-batch-select:checked"
161+
).length;
162+
}
162163
}
163164

164165
/**

0 commit comments

Comments
 (0)