mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
@@ -1,7 +1,7 @@
|
|||||||
<table data-automation-id="autocomplete_results" *ngIf="results && results.length && searchTerm"
|
<table data-automation-id="autocomplete_results" *ngIf="results && results.length && searchTerm"
|
||||||
class="mdl-data-table mdl-js-data-table mdl-shadow--2dp full-width">
|
class="mdl-data-table mdl-js-data-table mdl-shadow--2dp full-width">
|
||||||
<tbody>
|
<tbody (focusout)="onFocusOut()">
|
||||||
<tr id="result_row_{{idx}}" *ngFor="let result of results; let idx = index" (click)="onItemClick(result, $event)"
|
<tr id="result_row_{{idx}}" *ngFor="let result of results; let idx = index" tabindex="0" (blur)="onRowBlur(result)" (focus)="onRowFocus(result)" (click)="onItemClick(result, $event)" (keyup.enter)="onRowEnter(result, $event)"
|
||||||
attr.data-automation-id="autocomplete_result_for_{{result.entry.name}}">
|
attr.data-automation-id="autocomplete_result_for_{{result.entry.name}}">
|
||||||
<td class="img-td"><img src="{{getMimeTypeIcon(result)}}" alt="{{getMimeTypeKey(result)|translate}}"/></td>
|
<td class="img-td"><img src="{{getMimeTypeIcon(result)}}" alt="{{getMimeTypeKey(result)|translate}}"/></td>
|
||||||
<td>
|
<td>
|
||||||
|
@@ -43,6 +43,9 @@ export class AlfrescoSearchAutocompleteComponent implements OnInit, OnChanges {
|
|||||||
@Output()
|
@Output()
|
||||||
preview: EventEmitter<any> = new EventEmitter();
|
preview: EventEmitter<any> = new EventEmitter();
|
||||||
|
|
||||||
|
@Output()
|
||||||
|
blurEmitter: EventEmitter<any> = new EventEmitter();
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
resultsEmitter = new EventEmitter();
|
resultsEmitter = new EventEmitter();
|
||||||
|
|
||||||
@@ -129,4 +132,33 @@ export class AlfrescoSearchAutocompleteComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onRowBlur(node): void {
|
||||||
|
window.setTimeout(() => {
|
||||||
|
let focusedEl = document.activeElement;
|
||||||
|
if (focusedEl && focusedEl.id && focusedEl.id.indexOf('result_row_') === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.blurEmitter.emit(node);
|
||||||
|
}, 100);
|
||||||
|
console.log('row blur', node);
|
||||||
|
}
|
||||||
|
|
||||||
|
onRowFocus(node): void {
|
||||||
|
console.log('row focus', node);
|
||||||
|
}
|
||||||
|
|
||||||
|
onRowEnter(node): void {
|
||||||
|
if (node && node.entry) {
|
||||||
|
if (node.entry.isFile) {
|
||||||
|
this.preview.emit({
|
||||||
|
value: node
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onFocusOut(): void {
|
||||||
|
console.log('onfocusout');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -24,4 +24,4 @@
|
|||||||
</form>
|
</form>
|
||||||
<alfresco-search-autocomplete *ngIf="autocompleteEnabled"
|
<alfresco-search-autocomplete *ngIf="autocompleteEnabled"
|
||||||
[searchTerm]="autocompleteSearchTerm" [ngClass]="{active: searchActive, valid: searchValid}"
|
[searchTerm]="autocompleteSearchTerm" [ngClass]="{active: searchActive, valid: searchValid}"
|
||||||
(preview)="onFileClicked($event)"></alfresco-search-autocomplete>
|
(preview)="onFileClicked($event)" (blurEmitter)="onAutoCompleteBlur($event)"></alfresco-search-autocomplete>
|
||||||
|
@@ -138,6 +138,10 @@ export class AlfrescoSearchControlComponent implements OnInit {
|
|||||||
|
|
||||||
onBlur(): void {
|
onBlur(): void {
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
|
let focusedEl = document.activeElement;
|
||||||
|
if (focusedEl && focusedEl.id && focusedEl.id.indexOf('result_row_') === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.searchActive = false;
|
this.searchActive = false;
|
||||||
}, 200);
|
}, 200);
|
||||||
if (this.expandable && (this.searchControl.value === '' || this.searchControl.value === undefined)) {
|
if (this.expandable && (this.searchControl.value === '' || this.searchControl.value === undefined)) {
|
||||||
@@ -155,4 +159,8 @@ export class AlfrescoSearchControlComponent implements OnInit {
|
|||||||
this.searchActive = true;
|
this.searchActive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onAutoCompleteBlur(): void {
|
||||||
|
this.searchActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
<tr id="result_row_{{idx}}" *ngFor="let result of results; let idx = index" (click)="onItemClick(result, $event)">
|
<tr id="result_row_{{idx}}" tabindex="0" *ngFor="let result of results; let idx = index" (click)="onItemClick(result, $event)" (keyup.enter)="onItemClick(result, $event)">
|
||||||
<td class="col-mimetype-icon"><img src="{{getMimeTypeIcon(result)}}" alt="{{getMimeTypeKey(result)|translate}}" /></td>
|
<td class="col-mimetype-icon"><img src="{{getMimeTypeIcon(result)}}" alt="{{getMimeTypeKey(result)|translate}}" /></td>
|
||||||
<td id="result_name_{{idx}}" class="mdl-data-table__cell--non-numeric col-display-name"
|
<td id="result_name_{{idx}}" class="mdl-data-table__cell--non-numeric col-display-name"
|
||||||
attr.data-automation-id=file_{{result.entry.name}} >{{result.entry.name}}</td>
|
attr.data-automation-id=file_{{result.entry.name}} >{{result.entry.name}}</td>
|
||||||
|
Reference in New Issue
Block a user