Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.3] Add pagination to datasetmanager.php #2202

Open
wants to merge 15 commits into
base: Development
Choose a base branch
from

Conversation

Atticus29
Copy link
Collaborator

@Atticus29 Atticus29 commented Feb 10, 2025

Description

This PR closes #2200 . It also autoformats the invovled files quite a bit, so I added comments to the "Files changed" tab above where the meaningful changes were made.

Currently, the maximum number of records displayed per page is an arbitrary 200, but I'm happy to change it.

Before

Screenshot 2025-02-10 at 3 56 30 PM

After

Screenshot 2025-02-10 at 3 49 56 PM

Pull Request Checklist:

Pre-Approval

  • There is a description section in the pull request that details what the proposed changes do. It can be very brief if need be, but it ought to exist.
  • Hotfixes should be branched off of the master branch and PR'd using the merge option (not squashed) into the hotfix branch.
    • N/A
  • Features and backlog bugs should be merged into the Development branch, NOT master
  • All new text is preferably internationalized (i.e., no end-user-visible text is hard-coded on the PHP pages), and the spreadsheet tracking internationalizations has been updated either with a new row or with checkmarks to existing rows.
  • There are no linter errors
  • New features have responsive design (i.e., look aesthetically pleasing both full screen and with small or mobile screens)
    • N/A
  • Symbiota coding standards have been followed
  • If any files have been reformatted (e.g., by an autoformatter), the reformat is its own, separate commit in the PR
    • I did not do this, but I did note in the files changed where meaningful code changes were made.
  • Comment which GitHub issue(s), if any does this PR address
  • If this PR makes any changes that would require additional configuration of any Symbiota portals outside of the files tracked in this repository, make sure that those changes are detailed in this document.
    • N/A

Post-Approval

  • It is the code author's responsibility to merge their own pull request after it has been approved
  • If this PR represents a merge into the Development branch, remember to use the squash & merge option
  • If this PR represents a merge into the hotfix branch, remember to use the merge option (i.e., no squash).
  • If this PR represents a merge from the Development branch into the master branch, remember to use the merge option
  • If this PR represents a merge from the hotfix branch into the master branch use the squash & merge option
    • a subsequent PR from master into Development should be made with the merge option (i.e., no squash).
    • Immediately delete the hotfix branch and create a new hotfix branch
    • increment the Symbiota version number in the symbase.php file and commit to the hotfix branch.
  • If the dev team has agreed that this PR represents the last PR going into the Development branch before a tagged release (i.e., before an imminent merge into the master branch), make sure to notify the team and lock the Development branch to prevent accidental merges while QA takes place. Follow the release protocol here.
  • Don't forget to delete your feature branch upon merge. Ignore this step as required.

Thanks for contributing and keeping it clean!

checklists/checklist.php Outdated Show resolved Hide resolved

private $conn;
private $collArr = array();
private $datasetId = 0;
private $errorArr = array();
private $occurrenceCount = null;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new line.

return false;
}
return $status;
}

public function getOccurrences($datasetId){
public function setOccurrenceCount($datasetId)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new method

}
}

public function getOccurrences($datasetId, $pageNumber = 1, $retLimit = 500)
Copy link
Collaborator Author

@Atticus29 Atticus29 Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modified method

return $returnVal;
}

public function getOccurrenceCount($datasetId)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new method

if($occArr = $datasetManager->getOccurrences($datasetId)){
?>
$retLimit = 200;
if ($occArr = $datasetManager->getOccurrences($datasetId, $pageNumber, $retLimit)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated based on change in method signature.

<?php echo '<b>'.$LANG['COUNT'].': '.count($occArr).' '.$LANG['RECORDS'].'</b>'; ?>
<?php echo '<b>' . $LANG['COUNT'] . ': ' . count($occArr) . ' ' . $LANG['RECORDS'] . '</b>'; ?>
</div>
<div class="bottom-breathing-room-rel">
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the pagination div

@Atticus29 Atticus29 marked this pull request as ready for review February 10, 2025 23:58
@themerekat
Copy link
Collaborator

When you have lots of pages you get this monstrosity
image

Can we hide a bunch of these under a dropdown list, or three dots in the middle then the last page is it's own link? Here's how we do it in collections/list
image

Although I think I would rather have a dropdown list of all the in-between numbers and an actual number for the last page instead of just "Last".

Copy link
Collaborator

@themerekat themerekat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment

@Atticus29
Copy link
Collaborator Author

Atticus29 commented Feb 12, 2025

When you have lots of pages you get this monstrosity image

Can we hide a bunch of these under a dropdown list, or three dots in the middle then the last page is it's own link? Here's how we do it in collections/list image

Although I think I would rather have a dropdown list of all the in-between numbers and an actual number for the last page instead of just "Last".

Should be resolved now. Per chat on Teams, links to neighboring 10 pages (when available; fewer if not; occasionally 11 because this logic was weird and hurt my brain) provided in a "sliding window" plus always a link to first page and last page. An input field for a page number is available in between for quick access to any target page. Some form validation present for said input field (users can't enter page options that don't exist). When the screen size gets too small to fit all of this, only the first page and last page links (as well a jump to page input field) are provided.

@themerekat
Copy link
Collaborator

@Atticus29 I found one edge case between 1050 and about 880 pixels where the last page floats off the page
image

@Atticus29
Copy link
Collaborator Author

@Atticus29 I found one edge case between 1050 and about 880 pixels where the last page floats off the page image

Fixed in b2fc870 and 8cc5859. I added another behavior at intermediate screen sizes where only the odd page number links in the sliding window get shown.

@themerekat themerekat self-requested a review February 17, 2025 18:28
Copy link
Collaborator

@themerekat themerekat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's beautiful! Works locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants