MDL-68463 user: Show count link should always exist in DOM

This commit is contained in:
Andrew Nicols 2020-05-19 12:18:15 +08:00
parent 07c9106476
commit 50ba817fda
4 changed files with 35 additions and 25 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -153,7 +153,10 @@ export const init = ({
if (totalRowCount <= defaultPageSize) {
// There are fewer than the default page count numbers of rows.
showCountLink.classList.add('hidden');
checkCountButton.classList.add('hidden');
if (checkCountButton) {
checkCountButton.classList.add('hidden');
}
} else if (totalRowCount <= currentPageSize) {
// The are fewer than the current page size.
pageCountStrings.push({
@ -172,8 +175,10 @@ export const init = ({
showCountLink.classList.remove('hidden');
showCountLink.dataset.targetPageSize = defaultPageSize;
// The 'Check all [x]' button is only visible when there are values to set.
checkCountButton.classList.add('hidden');
if (checkCountButton) {
// The 'Check all [x]' button is only visible when there are values to set.
checkCountButton.classList.add('hidden');
}
} else {
pageCountStrings.push({
key: 'showall',
@ -190,7 +195,10 @@ export const init = ({
// Show both the 'Show [x]' link, and the 'Check all [x]' button.
showCountLink.classList.remove('hidden');
showCountLink.dataset.targetPageSize = totalRowCount;
checkCountButton.classList.remove('hidden');
if (checkCountButton) {
checkCountButton.classList.remove('hidden');
}
}
Str.get_strings(pageCountStrings)
@ -202,7 +210,7 @@ export const init = ({
showCountLink.innerHTML = showCountString;
}
if (selectCountString) {
if (selectCountString && checkCountButton) {
checkCountButton.value = selectCountString;
}

View File

@ -310,30 +310,32 @@ echo $participanttablehtml;
$perpageurl = clone($baseurl);
$perpageurl->remove_params('perpage');
$perpagesize = DEFAULT_PAGE_SIZE;
$perpagevisible = false;
if ($perpage == SHOW_ALL_PAGE_SIZE && $participanttable->totalrows > DEFAULT_PAGE_SIZE) {
$perpageurl->param('perpage', DEFAULT_PAGE_SIZE);
echo $OUTPUT->container(html_writer::link(
$perpageurl,
get_string('showperpage', '', DEFAULT_PAGE_SIZE),
[
'data-action' => 'showcount',
'data-target-page-size' => DEFAULT_PAGE_SIZE,
]
), [], 'showall');
$perpagevisible = true;
} else if ($participanttable->get_page_size() < $participanttable->totalrows) {
$perpageurl->param('perpage', SHOW_ALL_PAGE_SIZE);
echo $OUTPUT->container(html_writer::link(
$perpageurl,
get_string('showall', '', $participanttable->totalrows),
[
'data-action' => 'showcount',
'data-target-page-size' => SHOW_ALL_PAGE_SIZE,
]
),
[], 'showall');
$pagesize = SHOW_ALL_PAGE_SIZE;
$perpagevisible = true;
}
$perpageclasses = '';
if (!$perpagevisible) {
$perpageclasses = 'hidden';
}
echo $OUTPUT->container(html_writer::link(
$perpageurl,
get_string('showperpage', '', DEFAULT_PAGE_SIZE),
[
'data-action' => 'showcount',
'data-target-page-size' => $perpagesize,
'class' => $perpageclasses,
]
), [], 'showall');
if ($bulkoperations) {
echo '<br /><div class="buttons"><div class="form-inline">';