Skip to content

Commit

Permalink
Fix report types selection not being overriden (#3436)
Browse files Browse the repository at this point in the history
Co-authored-by: Peter-Paul van Gemerden <[email protected]>
Co-authored-by: ammar92 <[email protected]>
Co-authored-by: Jan Klopper <[email protected]>
  • Loading branch information
4 people authored Sep 10, 2024
1 parent ba809d0 commit 4958776
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
9 changes: 5 additions & 4 deletions rocky/reports/templates/partials/report_types_selection.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1>{% translate "Choose report types" %}</h1>
{% endblocktranslate %}
</p>
{% if not selected_oois %}
{% include "partials/return_button.html" with btn_text="Go back" %}
{% include "partials/return_button.html" with btn_text="Go back" selected_report_types=None %}

{% else %}
<h2>
Expand All @@ -40,7 +40,7 @@ <h2>
action="{{ previous }}"
class="inline layout-wide">
{% csrf_token %}
{% include "forms/report_form_fields.html" %}
{% include "forms/report_form_fields.html" with selected_report_types=None %}

<button type="submit" class="button ghost">
<span class="icon ti-chevron-left"></span>{% translate "Change selection" %}
Expand All @@ -52,12 +52,13 @@ <h2>{% translate "Available report types" %} ({{ count_available_report_types_ag
<h2>{% translate "Available report types" %} ({{ available_report_types|length }})</h2>
{% endif %}
<p>{% translate "All report types that are available for your selection." %}</p>
<a class="toggle-all" data-toggle-target="report_type">{% translate "Toggle all report types" %}</a>
<a class="toggle-all {% if all_report_types_checked %}toggle-on{% endif %}"
data-toggle-target="report_type">{% translate "Toggle all report types" %}</a>
<form class="inline layout-wide checkboxes_required"
method="post"
action="{{ next }}">
{% csrf_token %}
{% include "forms/report_form_fields.html" %}
{% include "forms/report_form_fields.html" with selected_report_types=None %}

<div class="column-4 tiles">
{% if available_report_types_aggregate %}
Expand Down
4 changes: 4 additions & 0 deletions rocky/reports/views/aggregate_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,13 @@ def get_report_types_for_aggregate_report(
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["available_report_types_aggregate"] = self.available_report_types

context["count_available_report_types_aggregate"] = len(self.available_report_types["required"]) + len(
self.available_report_types["optional"]
)
context["all_report_types_checked"] = (
len(self.get_report_type_selection()) == context["count_available_report_types_aggregate"]
)
context["total_oois"] = self.get_total_objects()
return context

Expand Down
4 changes: 3 additions & 1 deletion rocky/reports/views/generate_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ def post(self, request, *args, **kwargs):

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["available_report_types"] = self.get_report_types(get_report_types_for_oois(self.get_oois_pk()))
available_report_types = self.get_report_types(get_report_types_for_oois(self.get_oois_pk()))
context["available_report_types"] = available_report_types
context["all_report_types_checked"] = len(available_report_types) == len(self.get_report_type_selection())
context["total_oois"] = self.get_total_objects()
return context

Expand Down

0 comments on commit 4958776

Please sign in to comment.