Skip to content

Commit f26b5fb

Browse files
committed
Update results count when filtering in all views
Also fix bug in JS (counting now only table rows but also the table itself)
1 parent 4551662 commit f26b5fb

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

app/models/mainsearch_strings.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
$real_search_results = count($locale1_strings);
2626
$limit_results = 200;
2727
// Limit results to 200 per locale
28-
array_splice($locale1_strings, $limit_results - 1);
29-
array_splice($locale2_strings, $limit_results - 1);
28+
array_splice($locale1_strings, $limit_results);
29+
array_splice($locale2_strings, $limit_results);
3030

3131
$searches = [
3232
$source_locale => $locale1_strings,

app/views/check_variables.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
include __DIR__ . '/simplesearchform.php';
66

77
if ($error_count > 0) {
8-
$content = "<h2>{$error_count} " .
9-
($error_count == 1 ? 'result' : 'results') .
10-
" found</h2>\n";
8+
$search_id = 'check_variable';
9+
$content = "<h2><span class=\"results_count_{$search_id}\">"
10+
. Utils::pluralize($error_count, 'result')
11+
. "</span> found</h2>\n";
1112

1213
if (isset($filter_block)) {
1314
$content .= "<div id='filters'>" .
@@ -17,7 +18,7 @@
1718
"</div>\n";
1819
}
1920

20-
$content .= "<table class='collapsable'>\n" .
21+
$content .= "<table class='collapsable results_table {$search_id}'>\n" .
2122
" <tr>\n" .
2223
" <th>Entity</th>\n" .
2324
" <th>{$source_locale}</th>\n" .
@@ -39,7 +40,7 @@
3940
$path_locale2 = VersionControl::hgPath($locale, $repo, $string_id);
4041

4142
$component = explode('/', $string_id)[0];
42-
$content .= "<tr class='{$component}'>
43+
$content .= "<tr class='{$component} {$search_id}'>
4344
<td>
4445
<span class='celltitle'>Entity</span>
4546
<a class='link_to_entity' href=\"/{$string_id_link}\">" . ShowResults::formatEntity($string_id) . "</a>

app/views/unchanged_strings.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
// Include the common simple search form
55
include __DIR__ . '/simplesearchform.php';
66

7-
$content = '<h2>' . count($unchanged_strings) . " strings identical to English</h2>\n";
7+
$search_id = 'unchanged_strings';
8+
$content = "<h2><span class=\"results_count_{$search_id}\">"
9+
. Utils::pluralize(count($unchanged_strings), 'string')
10+
. "</span> identical to English</h2>\n";
811

912
if (isset($filter_block)) {
1013
$content .= "<div id='filters'>" .
@@ -14,7 +17,7 @@
1417
"</div>\n";
1518
}
1619

17-
$content .= "<table class='collapsable'>\n";
20+
$content .= "<table class='collapsable results_table {$search_id}'>\n";
1821
$content .= " <tr class='column_headers'>\n" .
1922
" <th>String ID</th>\n" .
2023
" <th>English</th>\n" .
@@ -33,7 +36,7 @@
3336
*/
3437
$direction = RTLSupport::getDirection($source_locale);
3538

36-
$content .= " <tr class='{$component}'>\n" .
39+
$content .= " <tr class='{$component} {$search_id}'>\n" .
3740
" <td dir='ltr'><a href='{$entity_link}'>{$string_id}</a></td>\n" .
3841
" <td dir='{$direction}' lang='{$source_locale}'>{$string_value}</td>\n" .
3942
" <td dir='{$direction}' lang='{$locale}'>" . $strings_locale[$string_id] . "</td>\n" .

web/js/component_filter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ $(document).ready(function() {
2424
available_searches.forEach(function(search_id) {
2525
var class_name;
2626
class_name = e.target.id === 'showall'
27-
? '.' + search_id
28-
: '.' + search_id + '.' + e.target.id;
27+
? 'tr.' + search_id
28+
: 'tr.' + search_id + '.' + e.target.id;
2929

3030
var results_count = $(class_name).length;
3131
var results_message =

0 commit comments

Comments
 (0)