Permalink
Browse files

Fix #721: Allow sorting columns in search results (#727)

* Fix #721: Allow sorting columns in search results
* clean up our code to always define additional css and js files in the dispatcher
* make tables in all views sortable except a couple were it didn't make sense (like a 3 rows table)
* update the select_column.js and its associated html to not conflict with sorttable.js on the click event
* fix naming of variables for consistency
  • Loading branch information...
pascalchevrel committed Apr 13, 2016
1 parent dbf3ce6 commit 4fc1ad03a39e493e16451f39e357f8677c67a4f7
@@ -259,7 +259,7 @@ public static function resultsTable($search_object, $search_results, $page)
$extra_column_header = "<th>{$locale3}</th>";
}
$table = "<table class='collapsable results_table'>
$table = "<table class='collapsable results_table sortable'>
<thead>
<tr class='column_headers'>
<th>Entity</th>
@@ -151,7 +151,7 @@ public static function highlightString($str)
* @param array $arr2 Optional. A second column of data
* @param array $titles Column titles, by default 4 columns
* @param string $cssclass optional css class to apply to the table
* @return string and html table
* @return void
*/
public static function printSimpleTable(
$arr,
@@ -1,8 +1,5 @@
<?php
require_once INC . 'l10n-init.php';
// Include JS lib after $javascript_include gets reset in l10n-init.php.
$javascript_include = ['/js/select_column.js'];
include MODELS . 'channelcomparison.php';
include VIEWS . 'channelcomparison.php';
@@ -2,7 +2,6 @@
namespace Transvision;
$locales_list = [];
$javascript_include = ['/js/show_hide_tabs.js'];
foreach (Project::getRepositories() as $repo) {
$locales_list = array_merge($locales_list, Project::getRepositoryLocales($repo));
@@ -1,8 +1,5 @@
<?php
require_once INC . 'l10n-init.php';
// Include JS lib after $javascript_include gets reset in l10n-init.php.
$javascript_include = ['/js/sorttable.js'];
include MODELS . 'showrepos.php';
include VIEWS . 'showrepos.php';
@@ -19,7 +19,6 @@
include MODELS . 'tmx_downloading.php';
include VIEWS . 'tmx_downloading.php';
} else {
$javascript_include = ['/js/select_all.js'];
$l10n = new \tinyl10n\ChooseLocale($locales_list);
$locale = $l10n->getCompatibleLocale();
include VIEWS . 'tmx_downloads.php';
@@ -4,9 +4,6 @@
// Get requested repo and locale.
require_once INC . 'l10n-init.php';
// Include JS lib after $javascript_include gets reset in l10n-init.php.
$javascript_include = ['/js/sorttable.js'];
include MODELS . 'unlocalized_words.php';
switch ($page) {
View
@@ -11,83 +11,99 @@
$extra = null;
$experimental = false;
$show_title = true;
$css_files = ['transvision.css'];
$js_files = ['/js/base.js'];
switch ($url['path']) {
case '/':
$controller = 'mainsearch';
$show_title = false;
$js_files[] = '/js/component_filter.js';
$js_files[] = '/js/main_search.js';
$js_files[] = '/js/sorttable.js';
$js_files[] = '/assets/jQuery-Autocomplete/dist/jquery.autocomplete.min.js';
break;
case '3locales':
$controller = 'mainsearch';
$show_title = true;
$page_title = '3 locales search';
$page_descr = 'One source locale, get search results for two target locales';
$js_files[] = '/js/component_filter.js';
$js_files[] = '/js/main_search.js';
$js_files[] = '/js/sorttable.js';
$js_files[] = '/assets/jQuery-Autocomplete/dist/jquery.autocomplete.min.js';
break;
case 'accesskeys':
$view = 'accesskeys';
$view = 'accesskeys';
$page_title = 'Access Keys';
$page_descr = 'Check your access keys.';
$js_files[] = '/js/sorttable.js';
break;
case Strings::StartsWith($url['path'], 'api'):
$controller = 'api';
$page_title = 'API response';
$page_descr = '';
$template = false;
$template = false;
break;
case 'channelcomparison':
$controller = 'channelcomparison';
$page_title = 'Channel Comparison';
$page_descr = 'Compare strings from channel to channel.';
$js_files[] = '/js/select_column.js';
$js_files[] = '/js/sorttable.js';
break;
case 'consistency':
$experimental = true;
$controller = 'consistency';
$page_title = 'Translation Consistency';
$page_descr = 'Analyze translation consistency across repositories.';
$controller = 'consistency';
$page_title = 'Translation Consistency';
$page_descr = 'Analyze translation consistency across repositories.';
break;
case 'credits':
$view = 'credits';
$view = 'credits';
$page_title = 'Credits';
$page_descr = '';
break;
case 'downloads':
$controller = 'tmx_downloads';
$page_title = 'TMX Download';
$page_descr = 'Create and download your own <abbr title="Translation Memory eXchange">TMX</abbr> file containing the strings you need.';
$css_include = ['tmx.css'];
$controller = 'tmx_downloads';
$page_title = 'TMX Download';
$page_descr = 'Create and download your own <abbr title="Translation Memory eXchange">TMX</abbr> file containing the strings you need.';
$css_files[] = 'tmx.css';
$js_files[] = '/js/select_all.js';
break;
case 'gaia':
$view = 'gaia';
$view = 'gaia';
$page_title = 'Gaia Comparison';
$page_descr = 'Check the Status of your GAIA strings across repositories.';
break;
case 'news':
$controller = 'changelog';
$page_title = 'Transvision News and Release Notes';
$page_descr = '';
$css_include = ['changelog.css'];
$controller = 'changelog';
$page_title = 'Transvision News and Release Notes';
$page_descr = '';
$css_files[] = 'changelog.css';
break;
case 'productization':
$view = 'productization';
$page_title = 'Productization Overview';
$page_descr = 'Show productization aspects for this locale.';
$css_include = ['productization.css'];
$view = 'productization';
$page_title = 'Productization Overview';
$page_descr = 'Show productization aspects for this locale.';
$css_files[] = 'productization.css';
break;
case 'rss':
$controller = 'changelog';
$template = false;
$template = false;
break;
case 'showrepos':
$experimental = true;
$controller = 'health_status';
$page_title = 'Health status';
$page_descr = 'Check the health status of locales.';
$css_include = ['health.css'];
$controller = 'health_status';
$page_title = 'Health status';
$page_descr = 'Check the health status of locales.';
$css_files[] = 'health.css';
$js_files[] = '/js/show_hide_tabs.js';
break;
case 'stats':
$controller = 'showrepos';
$page_title = 'Status Overview';
$page_descr = 'Repository status overview.';
$js_files[] = '/js/sorttable.js';
break;
case 'string':
$controller = 'onestring';
@@ -98,12 +114,15 @@
$controller = 'unchanged_strings';
$page_title = 'Unchanged Strings';
$page_descr = 'Display a list of strings identical to English';
$js_files[] = '/js/component_filter.js';
$js_files[] = '/js/sorttable.js';
break;
case 'unlocalized':
$experimental = true;
$controller = 'unlocalized_words';
$page_title = 'Commonly Unlocalized Words';
$page_descr = 'Display the list of the most common untranslated words. Click on the table headers to sort results.';
$js_files[] = '/js/sorttable.js';
break;
case 'unlocalized-json':
$controller = 'unlocalized_words';
@@ -113,9 +132,11 @@
$controller = 'check_variables';
$page_title = 'Variables Overview';
$page_descr = 'Show potential errors related to missing or mispelled variables in your strings.';
$js_files[] = '/js/component_filter.js';
$js_files[] = '/js/sorttable.js';
break;
default:
$view = '404';
$view = '404';
$page_title = '404: Page Not Found';
$page_descr = '';
break;
@@ -148,12 +169,18 @@
$content = ob_get_contents();
ob_end_clean();
}
ob_start();
// Log script performance in the HTTP headers sent to the browser
Utils::addPerformancesHTTPHeader();
$perf_header = ob_get_contents();
// Log script performance in PHP integrated developement server console
Utils::logScriptPerformances();
ob_end_clean();
print $perf_header . $content;
die;
View
@@ -65,6 +65,3 @@
// Get RTL attribute for source and target locales
$locale_dir = $l10n->getDirection($locale);
$source_locale_dir = $l10n->getDirection($source_locale);
// Initialize list of JavaScript files to include
$javascript_include = [];
@@ -31,7 +31,6 @@
// Add component filter
if (in_array($repo, $desktop_repos)) {
// Build logic to filter components
$javascript_include = ['/js/component_filter.js'];
$components = Project::getComponents(array_flip($var_errors));
$filter_block = '';
foreach ($components as $value) {
@@ -87,7 +87,6 @@
} else {
if (Project::isDesktopRepository($search->getRepository())) {
// Build logic to filter components
$javascript_include[] = '/js/component_filter.js';
$filter_block = '';
foreach ($components as $value) {
$filter_block .= " <a href='#{$value}' id='{$value}' class='filter'>{$value}</a>";
@@ -44,7 +44,6 @@
if (in_array($repo, $desktop_repos)) {
// Build logic to filter components
$javascript_include = ['/js/component_filter.js'];
$components = Project::getComponents($unchanged_strings);
$filter_block = '';
foreach ($components as $value) {
View
@@ -3,7 +3,7 @@
require_once INC . 'l10n-init.php';
$strings[$repo] = Utils::getRepoStrings($locale, $repo);
$strings[$repo] = Utils::getRepoStrings($locale, $repo);
$strings_english[$repo] = Utils::getRepoStrings('en-US', $repo);
$channel_selector = Utils::getHtmlSelectOptions(
@@ -12,7 +12,8 @@
array_flip($desktop_repos)
),
$repo,
true);
true
);
// Get the locale list
$loc_list = Project::getRepositoryLocales($repo);
@@ -58,5 +59,5 @@ function ($entity) {
$ak_results,
$strings[$repo],
['Label entity', 'Label value', 'Access&nbsp;key', 'Access key entity'],
'collapsable'
'collapsable sortable'
);
@@ -38,12 +38,12 @@
<?php else: ?>
<h3>Locale: <?=$locale?></h3>
<table class='collapsable' id='modified_strings_table'>
<table class='collapsable sortable' id='modified_strings_table'>
<thead>
<tr class='column_headers'>
<th>Key</th>
<th class='select_header'><?=$chan1?><span>Select column</span></th>
<th class='select_header'><?=$chan2?><span>Select column</span></th>
<th class='select_header'><a href="#">Select column</a><?=$chan1?></th>
<th class='select_header'><a href="#">Select column</a><?=$chan2?></th>
</tr>
</thead>
<tbody>
@@ -63,7 +63,7 @@
<?php else : ?>
<h3 id="new_strings">New strings added in <em><?=$locale?></em> between <?=$repos_nice_names[$chan1]?> and <?=$repos_nice_names[$chan2]?></h3>
<table class='collapsable' id='new_strings_table'>
<table class='collapsable sortable' id='new_strings_table'>
<thead>
<tr class='column_headers'>
<th>Entity</th>
@@ -19,7 +19,7 @@
}
$content .= "
<table class='collapsable results_table {$search_id}'>
<table class='collapsable results_table sortable {$search_id}'>
<thead>
<tr class='column_headers'>
<th>Entity</th>
View
@@ -177,7 +177,7 @@
$section_description = count($divergences) . ' diverging translations across repositories';
$table = "
<p class='section_description'>{$section_description}</p>
<table id='{$anchor}' class='collapsable'>
<table id='{$anchor}' class='collapsable sortable'>
<thead>
<tr class='column_headers'>
<th style='width: {$width}%;'>Keys</th>";
@@ -222,7 +222,7 @@
$section_description = "Strings that have changed significantly in English between {$repo_one} and {$repo_two} but for which the entity name didn’t change";
$table = "
<p class='section_description'>{$section_description}</p>
<table id='englishchanges' class='collapsable'>
<table id='englishchanges' class='collapsable sortable'>
<thead>
<tr class='column_headers'>
<th>Key</th>
@@ -277,7 +277,7 @@
$section_description = "{$comparison_type} between {$repos_nice_names[$repo_one]} and {$repos_nice_names[$repo_two]}";
$table = "
<p class='section_description'>{$section_description}</p>
<table id='{$anchor}' class='{$cssclass}'>
<table id='{$anchor}' class='{$cssclass} sortable'>
<thead>
<tr class='column_headers'>
<th>Key</th>
@@ -1,10 +1,6 @@
<?php
namespace Transvision;
// Include JavaScript
$javascript_include[] = '/js/main_search.js';
$javascript_include[] = '/assets/jQuery-Autocomplete/dist/jquery.autocomplete.min.js';
/*
This function will mark a <select> option as selected if a cookie is set.
*/
Oops, something went wrong.

0 comments on commit 4fc1ad0

Please sign in to comment.