Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 009b4d2

Browse files
committed
feature #26398 [WebProfilerBundle] Display the missing translation panel by default (javiereguiluz)
This PR was squashed before being merged into the 4.1-dev branch (closes #26398). Discussion ---------- [WebProfilerBundle] Display the missing translation panel by default | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> Display the "Missing Translations" panel by default ... except if there are no missing translations. Commits ------- 15fe686 [WebProfilerBundle] Display the missing translation panel by default
2 parents febc096 + 15fe686 commit 009b4d2

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/Symfony/Bundle/TwigBundle/Resources/views/base_js.html.twig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@
4545
var tabNavigation = document.createElement('ul');
4646
tabNavigation.className = 'tab-navigation';
4747
48+
var selectedTabId = 'tab-' + i + '-0'; /* select the first tab by default */
4849
for (var j = 0; j < tabs.length; j++) {
4950
var tabId = 'tab-' + i + '-' + j;
5051
var tabTitle = tabs[j].querySelector('.tab-title').innerHTML;
5152
5253
var tabNavigationItem = document.createElement('li');
5354
tabNavigationItem.setAttribute('data-tab-id', tabId);
54-
if (j == 0) { addClass(tabNavigationItem, 'active'); }
55+
if (hasClass(tabs[j], 'active')) { selectedTabId = tabId; }
5556
if (hasClass(tabs[j], 'disabled')) { addClass(tabNavigationItem, 'disabled'); }
5657
tabNavigationItem.innerHTML = tabTitle;
5758
tabNavigation.appendChild(tabNavigationItem);
@@ -61,6 +62,7 @@
6162
}
6263
6364
tabGroups[i].insertBefore(tabNavigation, tabGroups[i].firstChild);
65+
addClass(document.querySelector('[data-tab-id="' + selectedTabId + '"]'), 'active');
6466
}
6567
6668
/* display the active tab and add the 'click' event listeners */

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/translation.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
{% endfor %}
116116

117117
<div class="sf-tabs">
118-
<div class="tab">
118+
<div class="tab {{ collector.countMissings == 0 ? 'active' }}">
119119
<h3 class="tab-title">Defined <span class="badge">{{ collector.countDefines }}</span></h3>
120120

121121
<div class="tab-content">
@@ -156,7 +156,7 @@
156156
</div>
157157
</div>
158158

159-
<div class="tab">
159+
<div class="tab {{ collector.countMissings > 0 ? 'active' }}">
160160
<h3 class="tab-title">Missing <span class="badge {{ collector.countMissings ? 'status-error' }}">{{ collector.countMissings }}</span></h3>
161161

162162
<div class="tab-content">

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,13 +406,14 @@
406406
var tabNavigation = document.createElement('ul');
407407
tabNavigation.className = 'tab-navigation';
408408
409+
var selectedTabId = 'tab-' + i + '-0'; /* select the first tab by default */
409410
for (var j = 0; j < tabs.length; j++) {
410411
var tabId = 'tab-' + i + '-' + j;
411412
var tabTitle = tabs[j].querySelector('.tab-title').innerHTML;
412413
413414
var tabNavigationItem = document.createElement('li');
414415
tabNavigationItem.setAttribute('data-tab-id', tabId);
415-
if (j == 0) { addClass(tabNavigationItem, 'active'); }
416+
if (hasClass(tabs[j], 'active')) { selectedTabId = tabId; }
416417
if (hasClass(tabs[j], 'disabled')) { addClass(tabNavigationItem, 'disabled'); }
417418
tabNavigationItem.innerHTML = tabTitle;
418419
tabNavigation.appendChild(tabNavigationItem);
@@ -422,6 +423,7 @@
422423
}
423424
424425
tabGroups[i].insertBefore(tabNavigation, tabGroups[i].firstChild);
426+
addClass(document.querySelector('[data-tab-id="' + selectedTabId + '"]'), 'active');
425427
}
426428
427429
/* display the active tab and add the 'click' event listeners */

0 commit comments

Comments
 (0)