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

35 ganze zeile klickbar machen #36

Merged
merged 3 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<button
[matMenuTriggerData]="{ element: element }"
[matMenuTriggerFor]="menu"
(click)="$event.stopPropagation()"
aria-label="Actions"
mat-icon-button>
<fa-icon icon="ellipsis-vertical"></fa-icon>
Expand All @@ -53,7 +54,12 @@
<tr *matHeaderRowDef="displayedColumns; sticky: true" mat-header-row></tr>
<tr *matHeaderRowDef="['loading']; sticky: true" mat-header-row style="height: auto;"></tr>

<tr *matRowDef="let row; columns: displayedColumns;" mat-row></tr>
<tr
*matRowDef="let row; columns: displayedColumns;"
[style]="rowClickedObserved ? 'cursor: pointer' : ''"
(click)="rowClickedObserved && rowClicked.emit(row)"
mat-row>
</tr>
</table>
<div class="tw-flex-1"></div>
@if (paging && dataset) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ export class InnerTableComponent<T> implements OnChanges, AfterViewInit {
@Input() editIcon: IconName = 'address-card';
@Input() edit = false;
@Input() delete = false;
@Input() rowClickedObserved = false;
@Input() progress = false;
@Input() loading = true;
@Input() pageSizeOptions = [10, 20, 50];

@Output() readonly deleteEvent = new EventEmitter<T>();
@Output() readonly editEvent = new EventEmitter<T>();
@Output() readonly rowClicked = new EventEmitter<T>();

@ViewChild(MatPaginator) private readonly paginator !: MatPaginator;
@ViewChild(MatSort) private readonly sort !: MatSort;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[paging]="paging"
[edit]="edit"
[delete]="delete"
[rowClickedObserved]="rowClickedObserved"
[translateKey]="translateKey"
[dataset]="innerData"
[displayedColumns]="displayedColumns"
Expand All @@ -14,6 +15,7 @@
[pageSizeOptions]="pageSizeOptions"
(deleteEvent)="deleteAction($event)"
(editEvent)="editAction($event)"
(rowClicked)="rowClicked.emit($event)"
class="tw-flex tw-flex-col tw-flex-1">
<ng-content></ng-content>
</bpa-inner-table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ export class TableComponent<T> implements OnChanges {
@Input() editIcon: IconName = 'address-card';
@Input() pageSizeOptions = [10, 20, 50];

@Output() readonly rowClicked = new EventEmitter<T>();
@Output() readonly deleteEvent = new EventEmitter<T>();
@Output() readonly editEvent = new EventEmitter<T>();

protected loading = true;
protected edit = false;
protected delete = false;

protected rowClickedObserved = false;
protected displayedColumns!: string[];
protected innerData: T[] | undefined | null = [];

Expand All @@ -42,6 +43,7 @@ export class TableComponent<T> implements OnChanges {
ngOnChanges(): void {
this.delete = this.deleteEvent.observed;
this.edit = this.editEvent.observed;
this.rowClickedObserved = this.rowClicked.observed;

this.displayedColumns = [...this.columns];
if (this.delete || this.edit) {
Expand Down
1 change: 1 addition & 0 deletions src/app/components/table/table.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ <h3 translate>content.headline.static_data</h3>
[dataset]="data"
[pageSizeOptions]="[7, 14, 21]"
(deleteEvent)="die($event)"
(rowClicked)="view($event)"
(editEvent)="view($event)"
translateKey="hero.components.hero-list.">
</bpa-table>
Expand Down
Loading