-
Notifications
You must be signed in to change notification settings - Fork 28
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
base: develop
Are you sure you want to change the base?
Homogenize number of lines for table multiselect position (#7761) #7771
Conversation
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 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. 📒 Files selected for processing (14)
📝 WalkthroughWalkthroughThe pull request introduces changes to the pagination functionality within the admin module by removing pagination controls from the Possibly related PRs
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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:
- Replace hardcoded width with responsive classes
- Use CSS classes for spacing instead of
<br>
tags- Add explicit aria-label for better accessibility
- 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> 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-paginationAdd 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
📒 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.
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)); | ||
} |
There was a problem hiding this comment.
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:
- Use a bound template reference variable and retrieve its value via event binding.
- Use two-way data binding on a component property to track selected values directly.
cce1887
to
663382b
Compare
There was a problem hiding this 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 suggestionReplace 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:
- Add a property to track the selected value:
public selectedPageSize: number = this.paginationDefaultPageSize;
- 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>
- 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 selectorThe page size selector implementation has a few areas for improvement:
- The
<select>
element is missing anid
attribute that matches its label'sfor
attribute- The label appears after the select element, which is unconventional
- 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> 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 sectionThe 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
📒 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
<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> shared.pageSize</label> |
There was a problem hiding this comment.
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.
- The
<select>
element should have an id matching its label'sfor
attribute. - 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.
<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> 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> shared.pageSize</label> |
663382b
to
f97d5e7
Compare
Signed-off-by: vlo-rte <[email protected]>
f97d5e7
to
ddf3f5e
Compare
Quality Gate passedIssues Measures |
Nothing in release notes.