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

Homogenize number of lines for table multiselect position (#7761) #7771

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

vlo-rte
Copy link
Contributor

@vlo-rte vlo-rte commented Dec 27, 2024

Nothing in release notes.

Copy link

coderabbitai bot commented Dec 27, 2024

Warning

Rate limit exceeded

@vlo-rte has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 3 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 663382b and ddf3f5e.

📒 Files selected for processing (14)
  • ui/main/src/app/modules/admin/admin.component.html (0 hunks)
  • ui/main/src/app/modules/admin/admin.component.ts (2 hunks)
  • ui/main/src/app/modules/admin/components/table/admin-table.directive.html (1 hunks)
  • ui/main/src/app/modules/admin/components/table/admin-table.directive.ts (3 hunks)
  • ui/main/src/app/modules/admin/components/table/businessData-table.component.ts (2 hunks)
  • ui/main/src/app/modules/admin/components/table/entities-table.component.ts (2 hunks)
  • ui/main/src/app/modules/admin/components/table/groups-table.component.ts (2 hunks)
  • ui/main/src/app/modules/admin/components/table/perimeters-table.component.ts (2 hunks)
  • ui/main/src/app/modules/admin/components/table/processes-table.component.ts (2 hunks)
  • ui/main/src/app/modules/admin/components/table/supervised-entities-table.component.ts (2 hunks)
  • ui/main/src/app/modules/admin/components/table/users-table.component.ts (2 hunks)
  • ui/main/src/app/modules/archives/archives.component.html (1 hunks)
  • ui/main/src/app/modules/logging/components/logging-table/logging-table.component.html (1 hunks)
  • ui/main/src/app/modules/logging/logging.component.html (1 hunks)
📝 Walkthrough

Walkthrough

The pull request introduces changes to the pagination functionality within the admin module by removing pagination controls from the AdminComponent and adding new pagination features to the AdminTableDirective. Specifically, the AdminComponent has had all pagination-related methods, properties, and HTML controls eliminated, while the AdminTableDirective has been enhanced with new properties and methods to manage pagination. Additionally, various table components have been updated to include the NgForOf directive, allowing for dynamic rendering of pagination options. The changes reflect a restructuring of pagination handling across multiple components.

Possibly related PRs

Suggested reviewers

  • quinarygio

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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.

@vlo-rte vlo-rte linked an issue Dec 27, 2024 that may be closed by this pull request
Copy link

@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: 1

🧹 Nitpick comments (3)
ui/main/src/app/modules/admin/components/table/admin-table.directive.html (2)

41-53: Enhance accessibility and maintainability of the pagination controls.

While the functionality is correct, consider the following improvements:

  1. Replace hardcoded width with responsive classes
  2. Use CSS classes for spacing instead of <br> tags
  3. Add explicit aria-label for better accessibility
  4. Use CSS variables for consistent spacing

Consider applying these changes:

-            <div style="width: 12%;margin-top: 14px">
+            <div class="opfab-pagination-size-selector">
                 <select (change)="onPageSizeChanged()" 
                         id="opfab-page-size-select"
+                        aria-label="{{ 'shared.pageSize' | translate }}"
+                        class="opfab-select">
                     <option
                             *ngFor="let option of paginationPageSizeOptions"
                             [value]="option"
                             [attr.selected]="option === paginationDefaultPageSize ? true : null">
                         {{ option }}
                     </option>
                 </select>
-                <label for="opfab-page-size-select" translate>&nbsp;shared.pageSize</label>
+                <label for="opfab-page-size-select" class="opfab-pagination-label" translate>shared.pageSize</label>
-                <br />
-                <br />
             </div>

Add these CSS classes to your stylesheet:

.opfab-pagination-size-selector {
    width: auto;
    min-width: 120px;
    margin: var(--opfab-spacing-m) 0;
}
.opfab-pagination-label {
    margin-left: var(--opfab-spacing-s);
}

40-54: Improve responsive layout and spacing consistency.

The current layout uses fixed widths and inconsistent margins which might cause issues on smaller screens. Consider implementing a more flexible and consistent layout.

Consider applying these changes:

-        <div *ngIf="gridApi" class="opfab-pagination">
+        <div *ngIf="gridApi" class="opfab-pagination opfab-pagination-container">
             <!-- page size selector as above -->
-            <div style="white-space: nowrap; margin-top: 17px">
+            <div class="opfab-pagination-results">
                 <span translate> shared.resultsNumber </span> : {{gridApi.paginationGetRowCount()}}
             </div>
-            <div style="width: 40%; margin-top: 5px">
+            <div class="opfab-pagination-navigation">
                 <ngb-pagination

Add these CSS classes to your stylesheet:

.opfab-pagination-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--opfab-spacing-m);
    padding: var(--opfab-spacing-m);
}

.opfab-pagination-results {
    white-space: nowrap;
}

.opfab-pagination-navigation {
    flex: 1;
    min-width: 200px;
}
ui/main/src/app/modules/admin/components/table/admin-table.directive.ts (1)

104-106: Introduce configurability for page size options and defaults.

Currently, the pagination page size options and default value are hardcoded. Consider externalizing these values (e.g. through environment config or a higher-level configuration service) to allow greater flexibility across different deployments or user preferences.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1d5a522 and cce1887.

📒 Files selected for processing (11)
  • ui/main/src/app/modules/admin/admin.component.html (0 hunks)
  • ui/main/src/app/modules/admin/admin.component.ts (2 hunks)
  • ui/main/src/app/modules/admin/components/table/admin-table.directive.html (1 hunks)
  • ui/main/src/app/modules/admin/components/table/admin-table.directive.ts (3 hunks)
  • ui/main/src/app/modules/admin/components/table/businessData-table.component.ts (2 hunks)
  • ui/main/src/app/modules/admin/components/table/entities-table.component.ts (2 hunks)
  • ui/main/src/app/modules/admin/components/table/groups-table.component.ts (2 hunks)
  • ui/main/src/app/modules/admin/components/table/perimeters-table.component.ts (2 hunks)
  • ui/main/src/app/modules/admin/components/table/processes-table.component.ts (2 hunks)
  • ui/main/src/app/modules/admin/components/table/supervised-entities-table.component.ts (2 hunks)
  • ui/main/src/app/modules/admin/components/table/users-table.component.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • ui/main/src/app/modules/admin/admin.component.html
🔇 Additional comments (19)
ui/main/src/app/modules/admin/components/table/admin-table.directive.html (1)

40-54: Changes align with PR objectives for table control homogenization.

The addition of consistent pagination controls aligns well with the PR's goal of homogenizing table controls. The implementation provides a standardized approach to page size selection and navigation.

ui/main/src/app/modules/admin/admin.component.ts (3)

11-11: Revised imports are consistent with OnPush strategy

Adding or pruning imports aligns well with the shift of pagination logic out of this component. This is consistent with a more modular approach. No issues spotted.


25-25: Removed OnInit interface

The removal of OnInit indicates that initialization logic specific to this component is no longer required. Ensure that any previously handled initialization (e.g., pagination) is fully migrated to other directives or services.


28-28: Constructor now excludes pagination dependencies

Removal of extra dependencies (e.g., dataHandlingService) is an improvement for component-focused responsibilities, reducing coupling. This is a positive simplification that fosters better maintainability.

ui/main/src/app/modules/admin/components/table/businessData-table.component.ts (2)

15-15: Imported NgForOf for dynamic lists

The addition of NgForOf allows flexible list rendering within the template. Ensure you properly leverage it for any table-based UI repetition needs in conjunction with the existing pagination logic managed elsewhere.


27-27: Updated imports array

Including NgForOf in the imports array centralizes all structural directives the component uses. Good practice to keep your module imports consistent for maintainability.

ui/main/src/app/modules/admin/components/table/processes-table.component.ts (2)

15-15: Added NgForOf to support structural directives

This follows the same pattern seen in other table components, promoting uniformity across the admin module. Looks good for consistent usage of *ngFor.


27-27: Refined imports array for modular clarity

Explicitly listing NgForOf ensures that only necessary Angular features are included, which helps keep the codebase clean and optimized.

ui/main/src/app/modules/admin/components/table/groups-table.component.ts (2)

16-16: NgForOf import added

Similar to other table components, adding NgForOf ensures consistent table rendering patterns across the admin module. No issues here.


28-28: Synchronized imports for structural directives

Maintaining a unified structure for imports across all table components sustains uniform design patterns and makes the codebase more cohesive and discoverable.

ui/main/src/app/modules/admin/components/table/entities-table.component.ts (2)

16-16: Consistent usage of NgForOf import.
Importing NgForOf from @angular/common appears consistent with the rest of the admin module components. If the associated template renders repeated elements dynamically, this import is appropriate.


28-28: Validate the new import in the imports array.
Make sure any usage of NgForOf in the component template is properly tested and verified. If you find no usage, consider removing the import to reduce overhead.

ui/main/src/app/modules/admin/components/table/users-table.component.ts (2)

16-16: NgForOf import addition is aligned with typical Angular patterns.
This addition enables more robust iteration over collections in the template. Confirm that the template references use *ngFor.


28-28: Consider verifying usage of NgForOf in the template.
If the users-table.component.html leverages *ngFor, this import is essential. Otherwise, removing it helps maintain a lean imports list.

ui/main/src/app/modules/admin/components/table/supervised-entities-table.component.ts (2)

17-17: NgForOf import looks consistent.
Importing NgForOf is fully in line with Angular best practices for templating, and parallels the approach in other components.


29-29: Ensure actual usage of NgForOf.
Validate that the corresponding template leverages *ngFor; if it doesn’t, consider removing the import to keep the component’s import list concise.

ui/main/src/app/modules/admin/components/table/perimeters-table.component.ts (2)

17-17: NgForOf import addition is acceptable.
This ensures that the component can use structural directives like *ngFor for iterating over data.


29-29: Confirm usage of NgForOf in the template.
If no iteration using *ngFor is present, consider removing the import for cleanliness.

ui/main/src/app/modules/admin/components/table/admin-table.directive.ts (1)

167-167: Confirm consistent usage of paginationDefaultPageSize.

Invoking changePaginationPageSize(this.paginationDefaultPageSize) on init is appropriate, but ensure you update any references and UI elements that assume a different default. Also confirm that this aligns with the new pagination controls introduced in the directive.

Comment on lines +467 to +471
onPageSizeChanged() {
// Cast to get rid of "Property 'value' does not exist on type 'HTMLElement'."
const value = (<HTMLInputElement>document.getElementById('opfab-page-size-select')).value;
this.dataHandlingService.changePaginationPageSize(Number(value));
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use Angular event binding or template references instead of direct DOM access.

Accessing the DOM element by document.getElementById('opfab-page-size-select') is brittle in Angular. Prefer the following approaches for better maintainability and to adhere to Angular best practices:

  1. Use a bound template reference variable and retrieve its value via event binding.
  2. Use two-way data binding on a component property to track selected values directly.

@vlo-rte vlo-rte force-pushed the FE-7761-HomongenizeNumberOfLinesPerTableMultiselectPosition branch from cce1887 to 663382b Compare December 27, 2024 18:03
Copy link

@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: 1

♻️ Duplicate comments (1)
ui/main/src/app/modules/admin/components/table/admin-table.directive.ts (1)

467-471: 🛠️ Refactor suggestion

Replace direct DOM access with Angular template binding.

Using document.getElementById() is not recommended in Angular as it:

  • Breaks component encapsulation
  • Makes testing more difficult
  • Is prone to runtime errors

Consider refactoring to use Angular's template-driven approach:

  1. Add a property to track the selected value:
public selectedPageSize: number = this.paginationDefaultPageSize;
  1. Update the template to use two-way binding:
<select [(ngModel)]="selectedPageSize" (ngModelChange)="onPageSizeChanged($event)">
  <option *ngFor="let size of paginationPageSizeOptions" [value]="size">
    {{size}}
  </option>
</select>
  1. Update the method to use the bound value:
onPageSizeChanged(value: number) {
  this.dataHandlingService.changePaginationPageSize(value);
}
🧹 Nitpick comments (3)
ui/main/src/app/modules/archives/archives.component.html (2)

191-201: Improve accessibility and HTML semantics of the page size selector

The page size selector implementation has a few areas for improvement:

  1. The <select> element is missing an id attribute that matches its label's for attribute
  2. The label appears after the select element, which is unconventional
  3. The margin-top values (14px) might need to be aligned with other elements in the pagination section

Consider applying these improvements:

 <div style="width: 12%; margin-top: 14px">
+    <label for="opfab-page-size-select" translate>shared.pageSize</label>
     <select 
+        id="opfab-page-size-select"
         (change)="onPageSizeChanged($event.target)" 
         #pageSizeSelect>
         <option
             *ngFor="let option of paginationPageSizeOptions"
             [value]="option"
             [attr.selected]="option === pageSize ? true : null">
             {{ option }}
         </option>
     </select>
-    <label for="opfab-page-size-select" translate>&nbsp;shared.pageSize</label>
 </div>

This refactor:

  • Adds proper label-input association
  • Moves the label before the select element
  • Removes the non-breaking space from the label as it's no longer needed

190-202: Consider standardizing spacing in pagination section

The pagination section uses different margin-top values for its elements:

  • Page size selector: 14px
  • Results number: 17px
  • Pagination controls: 5px

This inconsistency might affect visual alignment. Consider standardizing these values for better visual harmony.

Consider using CSS classes instead of inline styles for better maintainability and consistency across pagination sections:

-<div style="width: 12%; margin-top: 14px">
+<div class="opfab-pagination-size-selector">

Then define the class in your CSS:

.opfab-pagination-size-selector {
    width: 12%;
    margin-top: 10px; /* standardized margin */
}
ui/main/src/app/modules/logging/components/logging-table/logging-table.component.html (1)

24-24: Consider using responsive units for width.

Using a fixed width of 12% might not be optimal for all screen sizes. Consider using more responsive units or a flex-based layout.

-        <div style="width: 12%; margin-top: 14px">
+        <div style="min-width: fit-content; margin-top: 14px">
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cce1887 and 663382b.

📒 Files selected for processing (14)
  • ui/main/src/app/modules/admin/admin.component.html (0 hunks)
  • ui/main/src/app/modules/admin/admin.component.ts (2 hunks)
  • ui/main/src/app/modules/admin/components/table/admin-table.directive.html (1 hunks)
  • ui/main/src/app/modules/admin/components/table/admin-table.directive.ts (3 hunks)
  • ui/main/src/app/modules/admin/components/table/businessData-table.component.ts (2 hunks)
  • ui/main/src/app/modules/admin/components/table/entities-table.component.ts (2 hunks)
  • ui/main/src/app/modules/admin/components/table/groups-table.component.ts (2 hunks)
  • ui/main/src/app/modules/admin/components/table/perimeters-table.component.ts (2 hunks)
  • ui/main/src/app/modules/admin/components/table/processes-table.component.ts (2 hunks)
  • ui/main/src/app/modules/admin/components/table/supervised-entities-table.component.ts (2 hunks)
  • ui/main/src/app/modules/admin/components/table/users-table.component.ts (2 hunks)
  • ui/main/src/app/modules/archives/archives.component.html (1 hunks)
  • ui/main/src/app/modules/logging/components/logging-table/logging-table.component.html (1 hunks)
  • ui/main/src/app/modules/logging/logging.component.html (1 hunks)
💤 Files with no reviewable changes (1)
  • ui/main/src/app/modules/admin/admin.component.html
✅ Files skipped from review due to trivial changes (1)
  • ui/main/src/app/modules/logging/logging.component.html
🚧 Files skipped from review as they are similar to previous changes (8)
  • ui/main/src/app/modules/admin/components/table/admin-table.directive.html
  • ui/main/src/app/modules/admin/components/table/perimeters-table.component.ts
  • ui/main/src/app/modules/admin/components/table/users-table.component.ts
  • ui/main/src/app/modules/admin/components/table/processes-table.component.ts
  • ui/main/src/app/modules/admin/components/table/entities-table.component.ts
  • ui/main/src/app/modules/admin/components/table/businessData-table.component.ts
  • ui/main/src/app/modules/admin/components/table/supervised-entities-table.component.ts
  • ui/main/src/app/modules/admin/components/table/groups-table.component.ts
🔇 Additional comments (4)
ui/main/src/app/modules/admin/admin.component.ts (1)

Line range hint 11-26: LGTM! Good separation of concerns.

The removal of pagination logic from AdminComponent and its relocation to AdminTableDirective improves code organization by:

  • Simplifying the component's responsibilities
  • Centralizing pagination logic in a more appropriate location
  • Reducing coupling between components
ui/main/src/app/modules/admin/components/table/admin-table.directive.ts (2)

104-105: LGTM! Well-defined pagination options.

The pagination configuration is well-structured with reasonable default values and common page size options.


167-167: LGTM! Proper initialization of pagination.

The default page size is correctly set during service initialization.

ui/main/src/app/modules/logging/components/logging-table/logging-table.component.html (1)

23-35: LGTM on pagination structure.

The overall pagination structure looks good:

  • Proper conditional rendering with *ngIf="gridApi"
  • Clear separation of pagination controls
  • Consistent spacing with other elements

Comment on lines 25 to 32
<select (change)="onPageSizeChanged($event.target)" #pageSizeSelect>
<option
*ngFor="let option of paginationPageSizeOptions"
[value]="option"
[attr.selected]="option === pageSize ? true : null">
{{ option }}
</option>
</select>
<label for="opfab-page-size-select" translate>&nbsp;shared.pageSize</label>
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix accessibility and type safety issues in the page size selector.

  1. The <select> element should have an id matching its label's for attribute.
  2. The event handling should use type-safe methods.

Apply this diff to fix the issues:

-            <select (change)="onPageSizeChanged($event.target)" #pageSizeSelect>
+            <select 
+                id="opfab-page-size-select"
+                (change)="onPageSizeChanged($event.target as HTMLSelectElement)" 
+                #pageSizeSelect>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<select (change)="onPageSizeChanged($event.target)" #pageSizeSelect>
<option
*ngFor="let option of paginationPageSizeOptions"
[value]="option"
[attr.selected]="option === pageSize ? true : null">
{{ option }}
</option>
</select>
<label for="opfab-page-size-select" translate>&nbsp;shared.pageSize</label>
<select
id="opfab-page-size-select"
(change)="onPageSizeChanged($event.target as HTMLSelectElement)"
#pageSizeSelect>
<option
*ngFor="let option of paginationPageSizeOptions"
[value]="option"
[attr.selected]="option === pageSize ? true : null">
{{ option }}
</option>
</select>
<label for="opfab-page-size-select" translate>&nbsp;shared.pageSize</label>

@vlo-rte vlo-rte force-pushed the FE-7761-HomongenizeNumberOfLinesPerTableMultiselectPosition branch from 663382b to f97d5e7 Compare December 27, 2024 18:10
@vlo-rte vlo-rte force-pushed the FE-7761-HomongenizeNumberOfLinesPerTableMultiselectPosition branch from f97d5e7 to ddf3f5e Compare December 27, 2024 18:12
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.

Homogenize number of lines for table multiselect position
1 participant