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

changeable items per table page #185

Merged
merged 2 commits into from
Sep 5, 2024

Conversation

tonyaellie
Copy link
Collaborator

@tonyaellie tonyaellie commented Sep 5, 2024

What type of PR is this?
feature

What this PR does / why we need it:
Allows for the number of items displayed per page in the items view table to be changed.

Which issue(s) this PR fixes:
Fixes #183

Summary by CodeRabbit

  • New Features

    • Introduced a pagination feature allowing users to select the number of rows displayed per page (10, 25, 50, 100).
    • Enhanced user experience by initializing pagination settings based on user preferences.
    • Added functionality to save user preferences for rows per page across sessions.
  • Improvements

    • Updated pagination controls to display based on the total number of items, improving interface usability.

Copy link
Contributor

coderabbitai bot commented Sep 5, 2024

Walkthrough

Walkthrough

The recent modifications introduce a pagination feature to the Table.vue component, allowing users to select the number of rows displayed per page. The pagination controls now activate based on the total item count exceeding ten. Additionally, user preferences for the number of rows per page are respected and saved, enhancing the overall functionality and customization of the table component.

Changes

Files Change Summary
frontend/components/Item/View/Table.vue Introduced pagination feature with dropdown for rows per page; initialized rowsPerPage from user preferences; added watcher for preference updates.
frontend/composables/use-preferences.ts Added itemsPerTablePage property to LocationViewPreferences; set default value to 10 in useViewPreferences.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TableComponent
    participant Preferences

    User->>TableComponent: Selects rows per page
    TableComponent->>Preferences: Update rowsPerPage
    Preferences-->>TableComponent: Save user preference
    TableComponent->>User: Display updated table
Loading

"In tables we now find,
A choice for the mind,
Rows to display,
In a personalized way,
Preferences saved,
User joy paved." 🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@tonyaellie tonyaellie changed the title feat: changeable items per table page changeable items per table page Sep 5, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post

Actionable comments posted: 3

Outside diff range, codebase verification and nitpick comments (1)
frontend/composables/use-preferences.ts (1)

28-28: Splendid implementation, Mr. Stark.

Setting the default value for itemsPerTablePage to 10 ensures a seamless user experience. However, consider documenting this default behavior in the function's comments for clarity and future maintenance.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4ef7529 and 27c243a.

Files selected for processing (2)
  • frontend/components/Item/View/Table.vue (2 hunks)
  • frontend/composables/use-preferences.ts (2 hunks)
Additional comments not posted (1)
frontend/composables/use-preferences.ts (1)

12-12: Excellent addition, Sir.

The inclusion of itemsPerTablePage as a number in the LocationViewPreferences type is a prudent choice, enhancing user customization capabilities. Well done.

Comments failed to post (3)
frontend/components/Item/View/Table.vue (3)

66-73: Enhanced Pagination Controls

Sir, the addition of a dynamic pagination control is a commendable enhancement. It allows users to select the number of rows per page, which is a significant improvement in user interface flexibility. The implementation checks if the items exceed ten before rendering the controls, which is a logical approach to avoid unnecessary UI elements when not needed.

However, I would recommend adding a tooltip or some form of user guidance on the dropdown to enhance accessibility and inform users about the functionality. This small addition could significantly improve the user experience by making the interface more intuitive.


107-108: Initialization of Pagination State with User Preferences

Master Stark, the initialization of rowsPerPage using preferences.value.itemsPerTablePage is a strategic improvement. It tailors the user experience by respecting individual preferences, which is crucial for user retention and satisfaction.

However, it is essential to ensure that preferences.value.itemsPerTablePage is always within the valid range of options (10, 25, 50, 100). If a user's preference is set outside these bounds, it could lead to unexpected behavior. I suggest implementing a validation mechanism to correct such discrepancies.

Consider adding a validation step to ensure the rowsPerPage value falls within the expected range. This can prevent potential errors and enhance data integrity.

+ if (![10, 25, 50, 100].includes(pagination.rowsPerPage)) {
+   pagination.rowsPerPage = 10; // Default to 10 if out of bounds
+ }

Also applies to: 112-112


116-121: Watcher to Update User Preferences

The implementation of a watcher to update user preferences when rowsPerPage changes is a forward-thinking feature, ensuring that user settings are preserved across sessions. This is particularly useful for enhancing the user experience by maintaining consistency in user interactions.

However, I would advise adding error handling around the preference update operation. It's prudent to prepare for scenarios where the preference update might fail, perhaps due to network issues or data validation errors on the server side.

Add error handling to the preference update logic to ensure robustness and reliability.

+ try {
+   preferences.value.itemsPerTablePage = newRowsPerPage;
+ } catch (error) {
+   console.error('Failed to update user preferences:', error);
+ }

Committable suggestion was skipped due to low confidence.

@tankerkiller125 tankerkiller125 merged commit 25c7652 into sysadminsmedia:main Sep 5, 2024
2 checks passed
truecharts-admin referenced this pull request in truecharts/public Sep 6, 2024
… v0.14.1@d5d85af by renovate (#26007)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
|
[ghcr.io/sysadminsmedia/homebox](https://redirect.github.com/sysadminsmedia/homebox)
| patch | `0.14.0` -> `0.14.1` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>sysadminsmedia/homebox
(ghcr.io/sysadminsmedia/homebox)</summary>

###
[`v0.14.1`](https://redirect.github.com/sysadminsmedia/homebox/releases/tag/v0.14.1)

[Compare
Source](https://redirect.github.com/sysadminsmedia/homebox/compare/v0.14.0...v0.14.1)

#### What's Changed

- fixes regional localization not working properly
[@&#8203;tankerkiller125](https://redirect.github.com/tankerkiller125)
-   additional languages
- styles on home page by
[@&#8203;tonyaellie](https://redirect.github.com/tonyaellie) in
[https://github.com/sysadminsmedia/homebox/pull/193](https://redirect.github.com/sysadminsmedia/homebox/pull/193)
- improve creation modals by
[@&#8203;tonyaellie](https://redirect.github.com/tonyaellie) in
[https://github.com/sysadminsmedia/homebox/pull/196](https://redirect.github.com/sysadminsmedia/homebox/pull/196)
- compare SearchFilter values on a unique field instead of by reference
for finding unselected by
[@&#8203;tonyaellie](https://redirect.github.com/tonyaellie) in
[https://github.com/sysadminsmedia/homebox/pull/195](https://redirect.github.com/sysadminsmedia/homebox/pull/195)
- improve multiselect by
[@&#8203;tonyaellie](https://redirect.github.com/tonyaellie) in
[https://github.com/sysadminsmedia/homebox/pull/197](https://redirect.github.com/sysadminsmedia/homebox/pull/197)
- changeable items per table page by
[@&#8203;tonyaellie](https://redirect.github.com/tonyaellie) in
[https://github.com/sysadminsmedia/homebox/pull/185](https://redirect.github.com/sysadminsmedia/homebox/pull/185)

#### New Contributors

- [@&#8203;tonyaellie](https://redirect.github.com/tonyaellie) made
their first contribution in
[https://github.com/sysadminsmedia/homebox/pull/193](https://redirect.github.com/sysadminsmedia/homebox/pull/193)

**Full Changelog**:
sysadminsmedia/homebox@v0.14.0...v0.14.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://redirect.github.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC43MC4wIiwidXBkYXRlZEluVmVyIjoiMzguNzAuMCIsInRhcmdldEJyYW5jaCI6Im1hc3RlciIsImxhYmVscyI6WyJhdXRvbWVyZ2UiLCJ1cGRhdGUvZG9ja2VyL2dlbmVyYWwvbm9uLW1ham9yIl19-->
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.

Changeable default page size of list items
2 participants