Use template for getHtmlForShowAll method

Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
This commit is contained in:
Maurício Meneghini Fauth 2017-12-28 14:25:06 -02:00
parent 46a6d98d3d
commit 1a4d65a58c
3 changed files with 12 additions and 12 deletions

View File

@ -285,16 +285,11 @@ class BrowseForeigners
*/
public static function getHtmlForShowAll($showAll, $maxRows, $foreignData)
{
$return = '';
if (is_array($foreignData['disp_row'])) {
if ($showAll && ($foreignData['the_total'] > $maxRows)) {
$return = '<input type="submit" id="foreign_showAll" '
. 'name="foreign_showAll" '
. 'value="' . __('Show all') . '" />';
}
}
return $return;
return Template::get('table/browse_foreigners/show_all')->render([
'foreign_data' => $foreignData,
'show_all' => $showAll,
'max_rows' => $maxRows,
]);
}
/**

View File

@ -0,0 +1,5 @@
{% if foreign_data.disp_row is iterable and
(show_all and foreign_data.the_total > max_rows) %}
<input type="submit" id="foreign_showAll" name="foreign_showAll" value="
{%- trans 'Show all' %}">
{% endif %}

View File

@ -125,10 +125,10 @@ class BrowseForeignersTest extends TestCase
$foreignData['the_total'] = 30;
$this->assertEquals(
$this->assertContains(
'<input type="submit" id="foreign_showAll" '
. 'name="foreign_showAll" '
. 'value="' . 'Show all' . '" />',
. 'value="' . 'Show all' . '">',
BrowseForeigners::getHtmlForShowAll(
$GLOBALS['cfg']['ShowAll'],
$GLOBALS['cfg']['MaxRows'],