Merge recent_favorite_table_no_tables template

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
Maurício Meneghini Fauth 2024-04-11 18:38:31 -03:00
parent 01de54571f
commit 89619f386b
No known key found for this signature in database
GPG Key ID: 6A16FD38AFC89CC8
4 changed files with 51 additions and 56 deletions

View File

@ -1,15 +1,19 @@
{% for table in tables %}
<li class="warp_link">
<a
class="ajax favorite_table_anchor"
href="{{ url('/database/structure/favorite-table', table.remove_parameters) }}"
title="{% trans 'Remove from Favorites' %}"
data-favtargetn="{{ table.table_parameters.md5 }}"
>
{{ get_icon('b_favorite') }}
</a>
<a class="disableAjax" href="{{ url('/table/recent-favorite', table.table_parameters) }}">
`{{ table.table_parameters.db }}`.`{{ table.table_parameters.table }}`
</a>
</li>
{% endfor %}
{% if tables is empty %}
{{ 'There are no favorite tables.'|trans }}
{% else %}
{% for table in tables %}
<li class="warp_link">
<a
class="ajax favorite_table_anchor"
href="{{ url('/database/structure/favorite-table', table.remove_parameters) }}"
title="{% trans 'Remove from Favorites' %}"
data-favtargetn="{{ table.table_parameters.md5 }}"
>
{{ get_icon('b_favorite') }}
</a>
<a class="disableAjax" href="{{ url('/table/recent-favorite', table.table_parameters) }}">
`{{ table.table_parameters.db }}`.`{{ table.table_parameters.table }}`
</a>
</li>
{% endfor %}
{% endif %}

View File

@ -1,7 +0,0 @@
<li class="warp_link">
{% if is_recent %}
{% trans 'There are no recent tables.' %}
{% else %}
{% trans 'There are no favorite tables.' %}
{% endif %}
</li>

View File

@ -1,7 +1,11 @@
{% for table in tables %}
<li class="warp_link">
<a class="disableAjax" href="{{ url('/table/recent-favorite', table) }}">
`{{ table.db }}`.`{{ table.table }}`
</a>
</li>
{% endfor %}
{% if tables is empty %}
{{ 'There are no recent tables.'|trans }}
{% else %}
{% for table in tables %}
<li class="warp_link">
<a class="disableAjax" href="{{ url('/table/recent-favorite', table) }}">
`{{ table.db }}`.`{{ table.table }}`
</a>
</li>
{% endfor %}
{% endif %}

View File

@ -189,39 +189,33 @@ class RecentFavoriteTables
*/
public function getHtmlList(): string
{
if ($this->tables !== []) {
if ($this->tableType === TableType::Recent) {
$tables = [];
foreach ($this->tables as $table) {
$tables[] = $table->toArray();
}
return $this->template->render('recent_favorite_table_recent', ['tables' => $tables]);
}
if ($this->tableType === TableType::Recent) {
$tables = [];
foreach ($this->tables as $table) {
$removeParameters = [
'db' => $table->db->getName(),
'favorite_table' => $table->table->getName(),
'ajax_request' => true,
'remove_favorite' => true,
];
$tableParameters = [
'db' => $table->db->getName(),
'table' => $table->table->getName(),
'md5' => md5($table->db . '.' . $table->table),
];
$tables[] = ['remove_parameters' => $removeParameters, 'table_parameters' => $tableParameters];
$tables[] = $table->toArray();
}
return $this->template->render('recent_favorite_table_favorite', ['tables' => $tables]);
return $this->template->render('recent_favorite_table_recent', ['tables' => $tables]);
}
return $this->template->render('recent_favorite_table_no_tables', [
'is_recent' => $this->tableType === TableType::Recent,
]);
$tables = [];
foreach ($this->tables as $table) {
$removeParameters = [
'db' => $table->db->getName(),
'favorite_table' => $table->table->getName(),
'ajax_request' => true,
'remove_favorite' => true,
];
$tableParameters = [
'db' => $table->db->getName(),
'table' => $table->table->getName(),
'md5' => md5($table->db . '.' . $table->table),
];
$tables[] = ['remove_parameters' => $removeParameters, 'table_parameters' => $tableParameters];
}
return $this->template->render('recent_favorite_table_favorite', ['tables' => $tables]);
}
/**