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

Feature: Add loading indicator (Redmine issue: #6332)

parent 0d1c846f
Branches malostik-feature-#6332-improve-searching-with-js
No related tags found
No related merge requests found
...@@ -862,7 +862,7 @@ ...@@ -862,7 +862,7 @@
{%- if chsection[0] in statistics or render_empty %} {%- 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_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"> <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">
# {{ chsection[1] }} <span class="loading hidden">loading...</span><span class="label-tag">#</span> {{ chsection[1] }}
</a> </a>
</li> </li>
{%- if tmp.update({'cntr': tmp['cntr'] + 1}) %}{%- endif %} {%- if tmp.update({'cntr': tmp['cntr'] + 1}) %}{%- endif %}
......
...@@ -236,9 +236,13 @@ $(function() { ...@@ -236,9 +236,13 @@ $(function() {
//}); //});
$(document).on('show.bs.tab', 'a.chart-tab[data-api-url]', function (event) { $(document).on('show.bs.tab', 'a.chart-tab[data-api-url]', function (event) {
if (event.target.search_result_data != undefined) { if (event.target.search_result_data != undefined || event.target.search_active) {
return; return;
} }
event.target.search_active = true;
$(event.target).children('.loading, .label-tag').toggleClass('hidden');
event.target.promise = $.getJSON(event.target.getAttribute('data-api-url'), function(data) { event.target.promise = $.getJSON(event.target.getAttribute('data-api-url'), function(data) {
event.target.search_result_data = data; event.target.search_result_data = data;
...@@ -249,6 +253,8 @@ $(function() { ...@@ -249,6 +253,8 @@ $(function() {
let stats = data['statistics']; let stats = data['statistics'];
rendering_functions[dict_key].forEach(rendering_func => rendering_func(stats)); rendering_functions[dict_key].forEach(rendering_func => rendering_func(stats));
$(event.target.getAttribute('href') + ' div.chart-toolbar').removeClass('invisible'); $(event.target.getAttribute('href') + ' div.chart-toolbar').removeClass('invisible');
event.target.search_active = false;
$(event.target).children('.loading, .label-tag').toggleClass('hidden');
}); });
}); });
}); });
......
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