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

make ItemViewTable headers customisable #212

Conversation

tonyaellie
Copy link
Collaborator

@tonyaellie tonyaellie commented Sep 9, 2024

What type of PR is this?

  • feature

What this PR does / why we need it:

This makes it so you can customise both what headers/columns are shown and the order they are shown for the ItemViewTable.

This makes homebox more customisable, some users for example may not use the insured field or may not find it generally useful so they could disable it and show other information such as serial number.

Which issue(s) this PR fixes:

Fixes #209

Summary by CodeRabbit

  • New Features

    • Introduced dynamic header management in the table component, allowing users to conditionally display and reorder table columns.
    • Added a dropdown control for managing header visibility and order.
    • Enhanced table header properties for improved data representation (e.g., type and enabled state).
  • Bug Fixes

    • Improved styling and layout of the table for better visual presentation.
  • Documentation

    • Updated preferences to include an optional property for table headers, enhancing user customization options.

Copy link
Contributor

coderabbitai bot commented Sep 9, 2024

Walkthrough

Walkthrough

The recent changes enhance the functionality of the table component by allowing users to customize which columns are visible. This is achieved through the addition of properties in the TableHeader type, enabling conditional rendering of table headers based on their enabled state. Furthermore, a new dropdown control has been introduced for managing header visibility, alongside modifications to the ItemViewTable component to accommodate these updates.

Changes

File Change Summary
frontend/components/Base/Card.vue Removed responsive class sm:rounded-lg from the main <div>, simplifying the styling to rounded-lg.
frontend/components/Item/View/*.ts Added enabled (boolean) and type (optional string) properties to the TableHeader type for enhanced header configuration.
frontend/components/Item/View/Table.vue Implemented dynamic header management by filtering headers based on enabled state, added dropdown controls for header visibility, and updated CSS for styling.
frontend/composables/use-preferences.ts Introduced optional tableHeaders property in LocationViewPreferences type to accommodate header configurations.
frontend/pages/home/index.vue Added disable-controls prop to the ItemViewTable component to manage interaction capabilities.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Table
    participant HeaderDropdown

    User->>HeaderDropdown: Toggle header visibility
    HeaderDropdown->>Table: Update enabled state of headers
    Table->>Table: Render headers based on enabled state
Loading

Assessment against linked issues

Objective Addressed Explanation
Ability to customise enabled columns for table view (#209)

In tables now, we can play,
Toggle columns, come what may.
With headers dancing, side by side,
Custom views, our data's pride!
A dropdown here, a checkbox there,
Flexibility, beyond compare!

Tip

New features

Walkthrough comment now includes:

  • Possibly related PRs: A list of potentially related PRs to help you recall past context.
  • Suggested labels: CodeRabbit can now suggest labels by learning from your past PRs. You can also provide custom labeling instructions in the UI or configuration file.

Notes:

  • Please share any feedback in the discussion post on our Discord.
  • Possibly related PRs, automatic label suggestions based on past PRs, learnings, and possibly related issues require data opt-in (enabled by default).

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.

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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fb62f51 and b18f0c7.

Files selected for processing (5)
  • frontend/components/Base/Card.vue (1 hunks)
  • frontend/components/Item/View/Table.types.ts (1 hunks)
  • frontend/components/Item/View/Table.vue (5 hunks)
  • frontend/composables/use-preferences.ts (2 hunks)
  • frontend/pages/home/index.vue (1 hunks)
Files skipped from review due to trivial changes (1)
  • frontend/components/Base/Card.vue
Additional comments not posted (15)
frontend/components/Item/View/Table.types.ts (1)

8-9: Sir, the changes to the TableHeader type are structurally sound and enable greater customization.

The addition of the enabled and type properties aligns with the PR objectives of allowing users to customize the visibility and representation of table headers. The enabled property facilitates conditional rendering, while the type property categorizes headers based on content type.

These enhancements provide a solid foundation for implementing the desired customization features in the user interface.

frontend/composables/use-preferences.ts (2)

2-2: The addition of the tableHeaders property to LocationViewPreferences supports the customization objectives, Mr. Stark.

The new optional tableHeaders property, defined as an array of TableHeader types, allows for storing user preferences related to table headers. This change aligns with the PR goal of enabling users to customize the visibility and representation of table columns according to their preferences.

The TableHeader type is appropriately imported from components/Item/View/Table.types, maintaining consistency and reusability across the codebase.

Also applies to: 14-14


14-14: It would be prudent to verify the impact of introducing the tableHeaders property on existing code, sir.

While the addition of the tableHeaders property to the LocationViewPreferences type supports the customization objectives, it's crucial to ensure that this change does not introduce any unintended consequences or break existing functionality.

I recommend running the following script to identify components or logic that rely on the LocationViewPreferences type and assess the potential impact of this change:

Please review the results and confirm that the introduction of the tableHeaders property does not adversely affect the existing codebase.

Verification successful

Impact of tableHeaders Property Addition Verified

The introduction of the tableHeaders property to the LocationViewPreferences type does not adversely affect the existing codebase. The useViewPreferences function, which returns this type, is used in frontend/plugins/i18n.ts and frontend/composables/use-theme.ts. Neither of these files interacts with the tableHeaders property, ensuring compatibility with existing functionality. Future modifications should consider this new property to maintain coherence.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the `LocationViewPreferences` type.

# Test: Search for the usage of `LocationViewPreferences`. Expect: Review the results to ensure compatibility.
rg --type typescript -A 5 $'LocationViewPreferences'

Length of output: 86


Script:

#!/bin/bash
# Description: Verify the usage of the `LocationViewPreferences` type in TypeScript files.

# Search for the usage of `LocationViewPreferences` in .ts files.
rg --glob '*.ts' -A 5 'LocationViewPreferences'

Length of output: 1037


Script:

#!/bin/bash
# Description: Verify the usage of the `useViewPreferences` function across the codebase.

# Search for the usage of `useViewPreferences` in .ts files.
rg --glob '*.ts' -A 5 'useViewPreferences'

Length of output: 1512

frontend/pages/home/index.vue (2)

41-41: The disable-controls prop added to the ItemViewTable component aligns with the customization objectives, sir.

The introduction of the disable-controls prop suggests that certain controls or functionalities associated with the ItemViewTable component may be conditionally disabled based on user preferences or other factors. This change supports the PR goal of allowing users to customize their table view experience.


41-41: It would be wise to assess the impact of disabling controls on the user experience, Mr. Stark.

While the disable-controls prop aligns with the customization objectives, it's crucial to ensure that disabling controls does not hinder necessary user interactions or degrade the overall usability of the ItemViewTable component.

I suggest testing the ItemViewTable component with the disable-controls prop enabled to evaluate the following:

  1. Are essential interactions, such as sorting, pagination, or filtering, still functional when controls are disabled?
  2. Does disabling controls provide a clear and intuitive user experience, or could it lead to confusion?
  3. Are there any scenarios where disabling controls might prevent users from accessing critical information or performing necessary actions?

Please conduct a thorough review of the user experience implications and confirm that disabling controls does not introduce any significant usability issues.

frontend/components/Item/View/Table.vue (10)

7-7: Excellent work on enhancing the table's customizability, sir!

The change to filter the headers based on their enabled state is a splendid addition. It allows for the conditional rendering of table columns, providing users with the flexibility to customize their view.


38-38: The table body is now in perfect sync with the header, sir!

Filtering the headers based on their enabled state in the table body ensures consistency with the header filtering. A most logical and approved change.


47-51: A brilliant addition for rendering the name cells, sir!

The new v-if block for rendering name type cells is a fantastic enhancement. It not only handles the specific data type but also incorporates a NuxtLink to seamlessly navigate users to the item's detail page. A most user-friendly improvement indeed!


52-54: The price cells are now displayed in a most elegant manner, sir!

Introducing a specific rendering for price type cells is a splendid enhancement. Utilizing the Currency component to format the purchasePrice ensures a polished and consistent display of monetary values. A most excellent addition!


55-58: The boolean cells are now conveyed with utmost clarity, sir!

Implementing a specific rendering for boolean type cells is a brilliant enhancement. Conditionally rendering the MdiCheck or MdiClose icons based on the insured value provides an intuitive visual representation of the boolean state. A most effective way to communicate the information to the user!


59-63: The location cells now offer seamless navigation, sir!

The addition of a specific rendering for location type cells is a most welcome enhancement. By conditionally rendering a NuxtLink to the location's detail page, you have provided users with a convenient means to access related information. A most thoughtful and user-centric improvement!


64-66: The date cells are now displayed in a most refined manner, sir!

Introducing a specific rendering for date type cells is a splendid enhancement. By leveraging the DateTime component, you have ensured a polished and standardized presentation of date values. A most excellent addition to improve the readability of the table!


74-79: The table footer is now a paragon of adaptability, sir!

The enhancements made to the table footer's styling and layout are most commendable. The dynamic hidden class, masterfully controlled by the disableControls prop, allows for the seamless toggling of the controls' visibility based on the component's state. A most ingenious way to customize the table's appearance and behavior!


80-115: The header management is now a marvel of user empowerment, sir!

The introduction of the dropdown control for managing header visibility and order is a most impressive enhancement. It bestows upon users the power to dynamically customize their table view to their heart's content. The implementation is as clean and well-structured as one of Mr. Stark's suits. A most commendable addition to the table's functionality!


287-300: The table's aesthetics are now a sight to behold, sir!

The newly introduced CSS styles are a most welcome addition to the table's visual presentation. By applying border radius to the table cells, you have created a polished and visually appealing design that is sure to catch the eye. A most delightful enhancement to the table's overall appearance!

@katosdev
Copy link
Contributor

Looking great! Thanks for the contribution @tonyaellie

@katosdev katosdev merged commit 405d0c7 into sysadminsmedia:main Sep 13, 2024
3 checks passed
@tonyaellie tonyaellie deleted the make-ItemViewTable-headers-customisable branch September 13, 2024 18:54
truecharts-admin referenced this pull request in truecharts/public Sep 14, 2024
… v0.14.2@e2ac4aa by renovate (#26389)

This PR contains the following updates:

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

---

> [!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.2`](https://redirect.github.com/sysadminsmedia/homebox/releases/tag/v0.14.2)

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

#### What's Changed

- add eslint-plugin-tailwindcss by
[@&#8203;tonyaellie](https://redirect.github.com/tonyaellie) in
[https://github.com/sysadminsmedia/homebox/pull/199](https://redirect.github.com/sysadminsmedia/homebox/pull/199)
- feat: allow the hiding of the header by
[@&#8203;tankerkiller125](https://redirect.github.com/tankerkiller125)
in
[https://github.com/sysadminsmedia/homebox/pull/202](https://redirect.github.com/sysadminsmedia/homebox/pull/202)
- Fix Registration Disabled button in login page by
[@&#8203;edward-shen](https://redirect.github.com/edward-shen) in
[https://github.com/sysadminsmedia/homebox/pull/203](https://redirect.github.com/sysadminsmedia/homebox/pull/203)
- update links by
[@&#8203;tonyaellie](https://redirect.github.com/tonyaellie) in
[https://github.com/sysadminsmedia/homebox/pull/206](https://redirect.github.com/sysadminsmedia/homebox/pull/206)
- refresh search on include archived change by
[@&#8203;tonyaellie](https://redirect.github.com/tonyaellie) in
[https://github.com/sysadminsmedia/homebox/pull/208](https://redirect.github.com/sysadminsmedia/homebox/pull/208)
- feat: show item is archived in more places by
[@&#8203;tonyaellie](https://redirect.github.com/tonyaellie) in
[https://github.com/sysadminsmedia/homebox/pull/210](https://redirect.github.com/sysadminsmedia/homebox/pull/210)
- Update Documentation: Quick Start by
[@&#8203;Gabrinator](https://redirect.github.com/Gabrinator) in
[https://github.com/sysadminsmedia/homebox/pull/221](https://redirect.github.com/sysadminsmedia/homebox/pull/221)
- make ItemViewTable headers customisable by
[@&#8203;tonyaellie](https://redirect.github.com/tonyaellie) in
[https://github.com/sysadminsmedia/homebox/pull/212](https://redirect.github.com/sysadminsmedia/homebox/pull/212)
-   fix issue with Chinese not automatically translating properly
-   Added option in profile to manually change language

#### New Contributors

- [@&#8203;edward-shen](https://redirect.github.com/edward-shen) made
their first contribution in
[https://github.com/sysadminsmedia/homebox/pull/203](https://redirect.github.com/sysadminsmedia/homebox/pull/203)
- [@&#8203;Gabrinator](https://redirect.github.com/Gabrinator) made
their first contribution in
[https://github.com/sysadminsmedia/homebox/pull/221](https://redirect.github.com/sysadminsmedia/homebox/pull/221)

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

</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:eyJjcmVhdGVkSW5WZXIiOiIzOC43Ny44IiwidXBkYXRlZEluVmVyIjoiMzguNzcuOCIsInRhcmdldEJyYW5jaCI6Im1hc3RlciIsImxhYmVscyI6WyJhdXRvbWVyZ2UiLCJ1cGRhdGUvZG9ja2VyL2dlbmVyYWwvbm9uLW1ham9yIl19-->
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.

Ability to customise enabled columns for table view
2 participants