TabularData: take control of juxtapositing pager and form

This commit is contained in:
Aaron van Geffen 2025-09-23 15:04:57 +02:00
parent 77fa33730a
commit 2af4e865e0
7 changed files with 22 additions and 16 deletions

View File

@ -18,8 +18,7 @@ class ManageAlbums extends HTMLController
'form' => [ 'form' => [
'action' => BASEURL . '/editalbum/', 'action' => BASEURL . '/editalbum/',
'method' => 'get', 'method' => 'get',
'class' => 'col-md-6 text-end', 'controls' => [
'buttons' => [
'add' => [ 'add' => [
'type' => 'submit', 'type' => 'submit',
'caption' => 'Add new album', 'caption' => 'Add new album',
@ -58,7 +57,6 @@ class ManageAlbums extends HTMLController
'title' => 'Manage albums', 'title' => 'Manage albums',
'no_items_label' => 'No albums meet the requirements of the current filter.', 'no_items_label' => 'No albums meet the requirements of the current filter.',
'items_per_page' => 9999, 'items_per_page' => 9999,
'index_class' => 'col-md-6',
'base_url' => BASEURL . '/managealbums/', 'base_url' => BASEURL . '/managealbums/',
'get_data' => function($offset, $limit, $order, $direction) { 'get_data' => function($offset, $limit, $order, $direction) {
return Tag::getOffset($offset, $limit, $order, $direction, true); return Tag::getOffset($offset, $limit, $order, $direction, true);

View File

@ -23,7 +23,6 @@ class ManageAssets extends HTMLController
'form' => [ 'form' => [
'action' => BASEURL . '/manageassets/?' . Session::getSessionTokenKey() . '=' . Session::getSessionToken(), 'action' => BASEURL . '/manageassets/?' . Session::getSessionTokenKey() . '=' . Session::getSessionToken(),
'method' => 'post', 'method' => 'post',
'class' => 'col-md-6 text-end',
'is_embed' => true, 'is_embed' => true,
'controls' => [ 'controls' => [
'deleteChecked' => [ 'deleteChecked' => [
@ -113,7 +112,6 @@ class ManageAssets extends HTMLController
'title' => 'Manage assets', 'title' => 'Manage assets',
'no_items_label' => 'No assets meet the requirements of the current filter.', 'no_items_label' => 'No assets meet the requirements of the current filter.',
'items_per_page' => 30, 'items_per_page' => 30,
'index_class' => 'col-md-6',
'base_url' => BASEURL . '/manageassets/', 'base_url' => BASEURL . '/manageassets/',
'get_data' => 'Asset::getOffset', 'get_data' => 'Asset::getOffset',
'get_count' => 'Asset::getCount', 'get_count' => 'Asset::getCount',

View File

@ -29,7 +29,6 @@ class ManageErrors extends HTMLController
'form' => [ 'form' => [
'action' => BASEURL . '/manageerrors/?' . Session::getSessionTokenKey() . '=' . Session::getSessionToken(), 'action' => BASEURL . '/manageerrors/?' . Session::getSessionTokenKey() . '=' . Session::getSessionToken(),
'method' => 'post', 'method' => 'post',
'class' => 'col-md-6 text-end',
'controls' => [ 'controls' => [
'clear' => [ 'clear' => [
'type' => 'submit', 'type' => 'submit',
@ -95,7 +94,6 @@ class ManageErrors extends HTMLController
'sort_direction' => $_GET['dir'] ?? '', 'sort_direction' => $_GET['dir'] ?? '',
'no_items_label' => "No errors to display -- we're all good!", 'no_items_label' => "No errors to display -- we're all good!",
'items_per_page' => 20, 'items_per_page' => 20,
'index_class' => 'col-md-6',
'base_url' => BASEURL . '/manageerrors/', 'base_url' => BASEURL . '/manageerrors/',
'get_count' => 'ErrorLog::getCount', 'get_count' => 'ErrorLog::getCount',
'get_data' => 'ErrorLog::getOffset', 'get_data' => 'ErrorLog::getOffset',

View File

@ -20,7 +20,6 @@ class ManageTags extends HTMLController
'form' => [ 'form' => [
'action' => BASEURL . '/edittag/', 'action' => BASEURL . '/edittag/',
'method' => 'get', 'method' => 'get',
'class' => 'col-md-6 text-end',
'controls' => [ 'controls' => [
'add' => [ 'add' => [
'type' => 'submit', 'type' => 'submit',
@ -70,8 +69,7 @@ class ManageTags extends HTMLController
'sort_direction' => $_GET['dir'] ?? '', 'sort_direction' => $_GET['dir'] ?? '',
'title' => 'Manage tags', 'title' => 'Manage tags',
'no_items_label' => 'No tags meet the requirements of the current filter.', 'no_items_label' => 'No tags meet the requirements of the current filter.',
'items_per_page' => 30, 'items_per_page' => 9999,
'index_class' => 'col-md-6',
'base_url' => BASEURL . '/managetags/', 'base_url' => BASEURL . '/managetags/',
'get_data' => function($offset, $limit, $order, $direction) { 'get_data' => function($offset, $limit, $order, $direction) {
return Tag::getOffset($offset, $limit, $order, $direction, false); return Tag::getOffset($offset, $limit, $order, $direction, false);

View File

@ -20,7 +20,6 @@ class ManageUsers extends HTMLController
'form' => [ 'form' => [
'action' => BASEURL . '/edituser/', 'action' => BASEURL . '/edituser/',
'method' => 'get', 'method' => 'get',
'class' => 'col-md-6 text-end',
'controls' => [ 'controls' => [
'add' => [ 'add' => [
'type' => 'submit', 'type' => 'submit',
@ -86,7 +85,6 @@ class ManageUsers extends HTMLController
'title' => 'Manage users', 'title' => 'Manage users',
'no_items_label' => 'No users meet the requirements of the current filter.', 'no_items_label' => 'No users meet the requirements of the current filter.',
'items_per_page' => 30, 'items_per_page' => 30,
'index_class' => 'col-md-6',
'base_url' => BASEURL . '/manageusers/', 'base_url' => BASEURL . '/manageusers/',
'get_data' => 'Member::getOffset', 'get_data' => 'Member::getOffset',
'get_count' => 'Member::getCount', 'get_count' => 'Member::getCount',

View File

@ -12,10 +12,10 @@ class InlineFormView
{ {
if (!isset($form['is_embed'])) if (!isset($form['is_embed']))
echo ' echo '
<form action="', $form['action'], '" method="', $form['method'], '" class="', $form['class'], '">'; <form action="', $form['action'], '" method="', $form['method'], '" class="', $form['class'] ?? '', '">';
else else
echo ' echo '
<div class="', $form['class'], '">'; <div class="', $form['class'] ?? '', '">';
if (!empty($form['is_group'])) if (!empty($form['is_group']))
echo ' echo '

View File

@ -68,23 +68,39 @@ class TabularData extends SubTemplate
} }
} }
protected function renderPaginationForm($pager, $form, $class='row') protected function renderPaginationForm($pager, $form)
{ {
echo ' echo '
<div class="', $class, ' clearfix justify-content-end">'; <div class="row clearfix justify-content-end">';
// Page index? // Page index?
if (!empty($pager)) if (!empty($pager))
{
echo '
<div class="col-md">';
PageIndexWidget::paginate($pager); PageIndexWidget::paginate($pager);
echo '
</div>';
}
// Form controls? // Form controls?
if (isset($form)) if (isset($form))
{
echo '
<div class="col-md-auto">';
InlineFormView::renderInlineForm($form); InlineFormView::renderInlineForm($form);
echo ' echo '
</div>'; </div>';
} }
echo '
</div>';
}
protected function renderTableHead(array $headers) protected function renderTableHead(array $headers)
{ {
echo ' echo '