mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
raise keyboard events, improve task list keyboard handling (#2401)
This commit is contained in:
parent
9f0e40a6e8
commit
e756db03cd
@ -169,6 +169,7 @@ These events bubble up the component tree and can be handled by any parent compo
|
|||||||
| row-dblclick | Raised when user double-clicks a row |
|
| row-dblclick | Raised when user double-clicks a row |
|
||||||
| row-select | Raised after user selects a row |
|
| row-select | Raised after user selects a row |
|
||||||
| row-unselect | Raised after user unselects a row |
|
| row-unselect | Raised after user unselects a row |
|
||||||
|
| row-keyup | Raised on the 'keyup' event for the focused row. |
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
@ -288,6 +289,18 @@ Note: the `<loading-content-template>` and `<no-content-template>` can be used t
|
|||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
|
#### row-keyup DOM event
|
||||||
|
|
||||||
|
Raised on the 'keyup' event for the focused row.
|
||||||
|
|
||||||
|
This is an instance of the `CustomEvent` with the `details` property containing the following object:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
row: DataRow,
|
||||||
|
keyboardEvent: KeyboardEvent,
|
||||||
|
sender: any
|
||||||
|
```
|
||||||
|
|
||||||
#### rowClick event
|
#### rowClick event
|
||||||
|
|
||||||
Emitted when user clicks a row.
|
Emitted when user clicks a row.
|
||||||
|
@ -8,7 +8,8 @@
|
|||||||
[selectionMode]="selectionMode"
|
[selectionMode]="selectionMode"
|
||||||
(row-select)="onRowSelect($event)"
|
(row-select)="onRowSelect($event)"
|
||||||
(row-unselect)="onRowUnselect($event)"
|
(row-unselect)="onRowUnselect($event)"
|
||||||
(rowClick)="onRowClick($event)">
|
(rowClick)="onRowClick($event)"
|
||||||
|
(row-keyup)="onRowKeyUp($event)">
|
||||||
<loading-content-template>
|
<loading-content-template>
|
||||||
<ng-template>
|
<ng-template>
|
||||||
<!--Add your custom loading template here-->
|
<!--Add your custom loading template here-->
|
||||||
|
@ -270,12 +270,7 @@ export class TaskListComponent implements OnChanges, OnInit, AfterContentInit {
|
|||||||
(this.data && this.data.getRows() && this.data.getRows().length === 0);
|
(this.data && this.data.getRows() && this.data.getRows().length === 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
onRowClick(item: DataRowEvent) {
|
||||||
* Emit the event rowClick passing the current task id when the row is clicked
|
|
||||||
* @param event
|
|
||||||
*/
|
|
||||||
onRowClick(event: DataRowEvent) {
|
|
||||||
const item = event;
|
|
||||||
this.currentInstanceId = item.value.getValue('id');
|
this.currentInstanceId = item.value.getValue('id');
|
||||||
this.rowClick.emit(this.currentInstanceId);
|
this.rowClick.emit(this.currentInstanceId);
|
||||||
}
|
}
|
||||||
@ -290,6 +285,14 @@ export class TaskListComponent implements OnChanges, OnInit, AfterContentInit {
|
|||||||
this.rowsSelected.emit(this.selectedInstances);
|
this.rowsSelected.emit(this.selectedInstances);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onRowKeyUp(event: CustomEvent) {
|
||||||
|
if (event.detail.keyboardEvent.key === 'Enter') {
|
||||||
|
event.preventDefault();
|
||||||
|
this.currentInstanceId = event.detail.row.getValue('id');
|
||||||
|
this.rowClick.emit(this.currentInstanceId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optimize name field
|
* Optimize name field
|
||||||
* @param istances
|
* @param istances
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
[adf-upload]="allowDropFiles && rowAllowsDrop(row)" [adf-upload-data]="row"
|
[adf-upload]="allowDropFiles && rowAllowsDrop(row)" [adf-upload-data]="row"
|
||||||
[ngStyle]="rowStyle"
|
[ngStyle]="rowStyle"
|
||||||
[ngClass]="getRowStyle(row)"
|
[ngClass]="getRowStyle(row)"
|
||||||
(keyup.enter)="onKeyboardNavigate(row, $event)">
|
(keyup)="onRowKeyUp(row, $event)">
|
||||||
|
|
||||||
<!-- Actions (left) -->
|
<!-- Actions (left) -->
|
||||||
<td *ngIf="actions && actionsPosition === 'left'">
|
<td *ngIf="actions && actionsPosition === 'left'">
|
||||||
|
@ -73,19 +73,19 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck
|
|||||||
showHeader: boolean = true;
|
showHeader: boolean = true;
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
rowClick: EventEmitter<DataRowEvent> = new EventEmitter<DataRowEvent>();
|
rowClick = new EventEmitter<DataRowEvent>();
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
rowDblClick: EventEmitter<DataRowEvent> = new EventEmitter<DataRowEvent>();
|
rowDblClick = new EventEmitter<DataRowEvent>();
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
showRowContextMenu: EventEmitter<DataCellEvent> = new EventEmitter<DataCellEvent>();
|
showRowContextMenu = new EventEmitter<DataCellEvent>();
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
showRowActionsMenu: EventEmitter<DataCellEvent> = new EventEmitter<DataCellEvent>();
|
showRowActionsMenu = new EventEmitter<DataCellEvent>();
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
executeRowAction: EventEmitter<DataRowActionEvent> = new EventEmitter<DataRowActionEvent>();
|
executeRowAction = new EventEmitter<DataRowActionEvent>();
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
loading: boolean = false;
|
loading: boolean = false;
|
||||||
@ -282,10 +282,32 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck
|
|||||||
this.clickObserver.next(dataRowEvent);
|
this.clickObserver.next(dataRowEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
onKeyboardNavigate(row: DataRow, e: KeyboardEvent) {
|
onRowKeyUp(row: DataRow, e: KeyboardEvent) {
|
||||||
|
const event = new CustomEvent('row-keyup', {
|
||||||
|
detail: {
|
||||||
|
row: row,
|
||||||
|
keyboardEvent: e,
|
||||||
|
sender: this
|
||||||
|
},
|
||||||
|
bubbles: true
|
||||||
|
});
|
||||||
|
|
||||||
|
this.elementRef.nativeElement.dispatchEvent(event);
|
||||||
|
|
||||||
|
if (event.defaultPrevented) {
|
||||||
|
e.preventDefault();
|
||||||
|
} else {
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
this.onKeyboardNavigate(row, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private onKeyboardNavigate(row: DataRow, e: KeyboardEvent) {
|
||||||
if (e) {
|
if (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
const event = new DataRowEvent(row, e, this);
|
const event = new DataRowEvent(row, e, this);
|
||||||
|
|
||||||
this.rowDblClick.emit(event);
|
this.rowDblClick.emit(event);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user