Skip to content

feat(angular-material): improve responsiveness of tablerenderer #2312

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

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 91 additions & 79 deletions packages/angular-material/src/library/other/table.renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,91 +51,103 @@ import {
@Component({
selector: 'TableRenderer',
template: `
<table
mat-table
[dataSource]="data"
class="mat-elevation-z8"
[trackBy]="trackElement"
>
<ng-container matColumnDef="action">
<tr>
<th mat-header-cell *matHeaderCellDef>
<button
mat-button
color="primary"
(click)="add()"
[disabled]="!isEnabled()"
[matTooltip]="translations.addTooltip"
>
<mat-icon>add</mat-icon>
</button>
</th>
</tr>
<tr>
<td
mat-cell
*matCellDef="
let row;
let i = index;
let first = first;
let last = last
"
>
<button
*ngIf="uischema?.options?.showSortButtons"
class="item-up"
mat-button
[disabled]="first"
(click)="up(i)"
[matTooltip]="translations.upAriaLabel"
matTooltipPosition="right"
>
<mat-icon>arrow_upward</mat-icon>
</button>
<button
*ngIf="uischema?.options?.showSortButtons"
class="item-down"
mat-button
[disabled]="last"
(click)="down(i)"
[matTooltip]="translations.downAriaLabel"
matTooltipPosition="right"
<div class="table-container">
<table
mat-table
[dataSource]="data"
class="mat-elevation-z8"
[trackBy]="trackElement"
>
<ng-container matColumnDef="action" stickyEnd>
<tr>
<th
mat-header-cell
*matHeaderCellDef
[ngClass]="{ 'sort-column': uischema?.options?.showSortButtons }"
>
<mat-icon>arrow_downward</mat-icon>
</button>
<button
mat-button
color="warn"
(click)="remove(i)"
[disabled]="!isEnabled()"
matTooltipPosition="right"
[matTooltip]="translations.removeTooltip"
<button
mat-button
color="primary"
(click)="add()"
[disabled]="!isEnabled()"
[matTooltip]="translations.addTooltip"
>
<mat-icon>add</mat-icon>
</button>
</th>
</tr>
<tr>
<td
[ngClass]="{ 'sort-column': uischema?.options?.showSortButtons }"
mat-cell
*matCellDef="
let row;
let i = index;
let first = first;
let last = last
"
>
<mat-icon>delete</mat-icon>
</button>
</td>
</tr>
<button
*ngIf="uischema?.options?.showSortButtons"
class="item-up"
mat-icon-button
[disabled]="first"
(click)="up(i)"
[matTooltip]="translations.upAriaLabel"
matTooltipPosition="right"
>
<mat-icon>arrow_upward</mat-icon>
</button>
<button
*ngIf="uischema?.options?.showSortButtons"
class="item-down"
mat-icon-button
[disabled]="last"
(click)="down(i)"
[matTooltip]="translations.downAriaLabel"
matTooltipPosition="right"
>
<mat-icon>arrow_downward</mat-icon>
</button>
<button
mat-icon-button
color="warn"
(click)="remove(i)"
[disabled]="!isEnabled()"
matTooltipPosition="right"
[matTooltip]="translations.removeTooltip"
>
<mat-icon>delete</mat-icon>
</button>
</td>
</tr>

<tr></tr
></ng-container>
<tr></tr
></ng-container>

<ng-container
*ngFor="let item of items"
matColumnDef="{{ item.property }}"
>
<th mat-header-cell *matHeaderCellDef>{{ item.header }}</th>
<td mat-cell *matCellDef="let index = index">
<jsonforms-outlet
[renderProps]="index | getProps : item.props"
></jsonforms-outlet>
</td>
</ng-container>
<ng-container
*ngFor="let item of items"
matColumnDef="{{ item.property }}"
>
<th mat-header-cell *matHeaderCellDef>{{ item.header }}</th>
<td mat-cell *matCellDef="let index = index">
<jsonforms-outlet
[renderProps]="index | getProps : item.props"
></jsonforms-outlet>
</td>
</ng-container>

<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
</table>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
</table>
</div>
`,
styles: ['table {width: 100%;}', '.cdk-column-action { width: 15%}'],
styles: [
'table {width: 100%;}',
'.cdk-column-action { width: 15%;}',
'.sort-column { min-width: 12vw;}',
'.table-container {max-width: 100%; overflow: auto;}',
],
})
export class TableRenderer extends JsonFormsArrayControl implements OnInit {
detailUiSchema: UISchemaElement;
Expand Down
Loading