Skip to content
This repository was archived by the owner on Dec 25, 2021. It is now read-only.
Open
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
2 changes: 1 addition & 1 deletion libs/datatable/src/components/row/row.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[class.selected]="selected"
[class.clickable]="dataTable.selectOnRowClick">
<td [hide]="!dataTable.expandColumnVisible">
<button (click)="expanded = !expanded; $event.stopPropagation()" class="row-expand-button"
<button (click)="expandButtonClicked()" class="row-expand-button"
[attr.aria-expanded]="expanded"
[title]="dataTable.labels.expandRow.replace('{cell_content}', ''+item[dataTable.primaryColumn])"
[attr.aria-label]="dataTable.labels.expandRow.replace('{cell_content}', ''+item[dataTable.primaryColumn])">
Expand Down
6 changes: 6 additions & 0 deletions libs/datatable/src/components/row/row.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class DataTableRowComponent implements OnInit, OnDestroy {
private _selected: boolean;

@Output() selectedChange = new EventEmitter();
@Output() rowExpandEvent = new EventEmitter();

get selected() {
return this._selected;
Expand All @@ -42,6 +43,11 @@ export class DataTableRowComponent implements OnInit, OnDestroy {
this.selectedChange.emit(selected);
}

expandButtonClicked(){
this.expanded = !this.expanded;
this.rowExpandEvent.emit(this.expanded);
}

// other:
get displayIndex() {
if (this.dataTable.pagination) {
Expand Down
2 changes: 1 addition & 1 deletion libs/datatable/src/components/table/table.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
</tr>
</thead>
<tbody *ngFor="let item of items; let index=index" class="data-table-row-wrapper"
dataTableRow #row [item]="item" [index]="index" (selectedChange)="onRowSelectChanged(row)">
dataTableRow #row [item]="item" [index]="index" (selectedChange)="onRowSelectChanged(row)" (rowExpandEvent)="onRowExpandButtonClicked(row,$event)">
</tbody>
<tbody *ngIf="itemCount === 0 && noDataMessage">
<tr>
Expand Down
23 changes: 16 additions & 7 deletions libs/datatable/src/components/table/table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ export class DataTableComponent implements DataTableParams, OnInit, AfterContent
@Output() rowDoubleClick = new EventEmitter();
@Output() headerClick = new EventEmitter();
@Output() cellClick = new EventEmitter();
@Output() rowExpandButtonClick = new EventEmitter();

// UI state without input:
indexColumnVisible: boolean;
selectColumnVisible: boolean;
Expand Down Expand Up @@ -219,7 +221,7 @@ export class DataTableComponent implements DataTableParams, OnInit, AfterContent
this.limit = this.pageLimits[0];
}

this.labels = {...defaultTranslations, ...this.labels};
this.labels = { ...defaultTranslations, ...this.labels };

if (this.autoReload) {
this.reloadItems();
Expand Down Expand Up @@ -273,25 +275,25 @@ export class DataTableComponent implements DataTableParams, OnInit, AfterContent
constructor() { }

public rowClicked(row: DataTableRowComponent, event: Event) {
this.rowClick.emit({row, event});
this.rowClick.emit({ row, event });
}

public rowDoubleClicked(row: DataTableRowComponent, event: Event) {
this.rowDoubleClick.emit({row, event});
this.rowDoubleClick.emit({ row, event });
}

public headerClicked(column: DataTableColumnDirective, event: Event) {
if (!this._resizeInProgress) {
event.preventDefault();
event.stopPropagation();
this.headerClick.emit({column, event});
this.headerClick.emit({ column, event });
} else {
this._resizeInProgress = false; // this is because I can't prevent click from mousup of the drag end
}
}

private cellClicked(column: DataTableColumnDirective, row: DataTableRowComponent, event: MouseEvent) {
this.cellClick.emit({row, column, event});
this.cellClick.emit({ row, column, event });
}

// functions:
Expand Down Expand Up @@ -364,6 +366,7 @@ export class DataTableComponent implements DataTableParams, OnInit, AfterContent
}
}


// unselect all other rows:
if (row.selected && !this.multiSelect) {
this.rows.toArray().filter(row_ => row_.selected).forEach(row_ => {
Expand All @@ -374,10 +377,16 @@ export class DataTableComponent implements DataTableParams, OnInit, AfterContent
}
}


onRowExpandButtonClicked(row: DataTableRowComponent, statusOfRow: Boolean) {
this.rowExpandButtonClick.emit({ row: row, status: statusOfRow });
}


// other:

get substituteItems() {
return Array.from({length: this.displayParams.limit - this.items.length});
return Array.from({ length: this.displayParams.limit - this.items.length });
}

private resizeColumnStart(event: MouseEvent, column: DataTableColumnDirective, columnElement: HTMLElement) {
Expand All @@ -399,7 +408,7 @@ export class DataTableComponent implements DataTableParams, OnInit, AfterContent
that offsetWidth sometimes contains out-of-date values. */
if ((dx < 0 && (columnElement.offsetWidth + dx) <= this.resizeLimit) ||
!columnElement.nextElementSibling || // resizing doesn't make sense for the last visible column
(dx >= 0 && ((<HTMLElement> columnElement.nextElementSibling).offsetWidth + dx) <= this.resizeLimit)) {
(dx >= 0 && ((<HTMLElement>columnElement.nextElementSibling).offsetWidth + dx) <= this.resizeLimit)) {
return false;
}
return true;
Expand Down