Skip to content
Snippets Groups Projects
Commit 21d08414 authored by Jakub Maloštík's avatar Jakub Maloštík
Browse files

Allow explicit section selection (Redmine issue: #6332, #6413)

parent 24ae06d5
No related branches found
No related tags found
No related merge requests found
......@@ -846,11 +846,12 @@
bool render_empty: Render the section even in case the required key does not
exist in the data.
bool active_first: Highlight the first section as active.
string active_section: The name of the section that should be active on load (takes precedence over active_first)
function get_url_func: function which will return url to redirect to if the section
name is not present in statistics (useful with render_empty = True)
-#}
{%- macro render_dashboard_nav(statistics, id_prefix, hide_sections = [], only_sections = None, render_empty = False, active_first = False, get_url_func = None) %}
{%- macro render_dashboard_nav(statistics, id_prefix, hide_sections = [], only_sections = None, render_empty = False, active_first = False, active_section = None, get_url_func = None) %}
{%- set tmp = {'cntr': 0} %}
{%- for chsection in (
('abuses', _('abuses')),
......@@ -874,7 +875,7 @@
) -%}
{%- if chsection[0] not in hide_sections and (not only_sections or chsection[0] in only_sections) %}
{%- if chsection[0] in statistics or render_empty %}
<li role="presentation" class="text-center{% if active_first and not tmp['cntr'] %} active{% endif %}">
<li role="presentation" class="text-center{% if active_section == chsection[0] or (active_section == None and active_first and not tmp['cntr']) %} active{% endif %}">
<a role="tab" data-toggle="tab"{%- if chsection[0] not in statistics and get_url_func %}data-api-url="{{ get_url_func(chsection[0]) }}"{%- endif %} data-dict-key="{{ chsection[0] }}" href="#tab-{{ id_prefix.replace('_', '-') }}-{{ chsection[0] }}" class="chart-tab">
<span class="loading hidden">loading...</span><span class="label-tag">#</span> {{ chsection[1] }}
</a>
......@@ -899,10 +900,11 @@
bool render_empty: Render the section even in case the required key does not
exist in the data.
bool active_first: Highlight the first section as active.
string active_section: The name of the section that should be active on load (takes precedence over active_first)
dict cfg_params: Additional chart configuration and customization parameters.
-#}
{%- macro render_dashboard_panels(statistics, statistics_var_name, id_prefix, hide_sections = [], only_sections = None, render_empty = False, active_first = False, cfg_params = {}) %}
{%- macro render_dashboard_panels(statistics, statistics_var_name, id_prefix, hide_sections = [], only_sections = None, render_empty = False, active_first = False, active_section = None, cfg_params = {}) %}
{%- set tmp = {'cntr': 0} %}
{%- for chsection in (
(
......@@ -1034,7 +1036,7 @@
) -%}
{%- if chsection[0] not in hide_sections and (not only_sections or chsection[0] in only_sections) %}
{%- if chsection[0] in statistics or render_empty %}
<div role="tabpanel" class="tab-pane fade{% if active_first and not tmp['cntr'] %} in active{% endif %}" id="tab-{{ id_prefix.replace('_', '-') }}-{{ chsection[0] }}">
<div role="tabpanel" class="tab-pane fade{% if active_section == chsection[0] or (active_section == None and active_first and not tmp['cntr']) %} in active{% endif %}" id="tab-{{ id_prefix.replace('_', '-') }}-{{ chsection[0] }}">
<h4>{{ chsection[1] }}</h4>
<p>
{{ chsection[2] }}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment