mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[ACA-2176] prevent Esc click event bubble into the Viewer (#6378)
* prevent Esc click event bubble into the Viewer * fix tests
This commit is contained in:
parent
567ea6cb0d
commit
a3fabf632c
@ -232,8 +232,13 @@ export class ContentNodeDialogService {
|
|||||||
return select;
|
return select;
|
||||||
}
|
}
|
||||||
|
|
||||||
private openContentNodeDialog(data: ContentNodeSelectorComponentData, currentPanelClass: string, chosenWidth: string) {
|
private openContentNodeDialog(data: ContentNodeSelectorComponentData, panelClass: string, width: string) {
|
||||||
this.dialog.open(ContentNodeSelectorComponent, { data, panelClass: currentPanelClass, width: chosenWidth });
|
this.dialog.open(ContentNodeSelectorComponent, {
|
||||||
|
data,
|
||||||
|
panelClass,
|
||||||
|
width,
|
||||||
|
disableClose: true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private imageResolver(row: ShareDataRow): string | null {
|
private imageResolver(row: ShareDataRow): string | null {
|
||||||
|
@ -15,12 +15,11 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
|
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||||
import { CUSTOM_ELEMENTS_SCHEMA, EventEmitter } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA, EventEmitter } from '@angular/core';
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { ContentNodeSelectorComponent } from './content-node-selector.component';
|
import { ContentNodeSelectorComponent } from './content-node-selector.component';
|
||||||
import { Node, NodeEntry } from '@alfresco/js-api';
|
import { Node, NodeEntry } from '@alfresco/js-api';
|
||||||
import { ContentNodeSelectorPanelComponent, UploadModule } from '@alfresco/adf-content-services';
|
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { setupTestBed, SitesService, ContentService } from '@alfresco/adf-core';
|
import { setupTestBed, SitesService, ContentService } from '@alfresco/adf-core';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
@ -29,16 +28,24 @@ import { DocumentListService } from '../document-list/services/document-list.ser
|
|||||||
import { DocumentListComponent } from '../document-list/components/document-list.component';
|
import { DocumentListComponent } from '../document-list/components/document-list.component';
|
||||||
import { ShareDataRow } from '../document-list';
|
import { ShareDataRow } from '../document-list';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { UploadModule } from '../upload';
|
||||||
|
import { ContentNodeSelectorPanelComponent } from './content-node-selector-panel.component';
|
||||||
|
|
||||||
describe('ContentNodeSelectorComponent', () => {
|
describe('ContentNodeSelectorComponent', () => {
|
||||||
|
|
||||||
let component: ContentNodeSelectorComponent;
|
let component: ContentNodeSelectorComponent;
|
||||||
let fixture: ComponentFixture<ContentNodeSelectorComponent>;
|
let fixture: ComponentFixture<ContentNodeSelectorComponent>;
|
||||||
|
|
||||||
|
const dialogRef = {
|
||||||
|
keydownEvents: () => of(null),
|
||||||
|
backdropClick: () => of(null),
|
||||||
|
close: jasmine.createSpy('close')
|
||||||
|
};
|
||||||
|
|
||||||
const data: any = {
|
const data: any = {
|
||||||
title: 'Choose along citizen...',
|
title: 'Choose along citizen...',
|
||||||
actionName: 'choose',
|
actionName: 'choose',
|
||||||
select: new EventEmitter<Node>(),
|
select: new EventEmitter<Node>(),
|
||||||
rowFilter: (shareDataRow: ShareDataRow) => shareDataRow.node.entry.name === 'impossible-name',
|
rowFilter: (shareDataRow) => shareDataRow.node.entry.name === 'impossible-name',
|
||||||
imageResolver: () => 'piccolo',
|
imageResolver: () => 'piccolo',
|
||||||
currentFolderId: 'cat-girl-nuku-nuku',
|
currentFolderId: 'cat-girl-nuku-nuku',
|
||||||
selectionMode: 'multiple',
|
selectionMode: 'multiple',
|
||||||
@ -61,10 +68,12 @@ describe('ContentNodeSelectorComponent', () => {
|
|||||||
imports: [
|
imports: [
|
||||||
TranslateModule.forRoot(),
|
TranslateModule.forRoot(),
|
||||||
ContentTestingModule,
|
ContentTestingModule,
|
||||||
|
MatDialogModule,
|
||||||
UploadModule
|
UploadModule
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: MAT_DIALOG_DATA, useValue: data }
|
{ provide: MAT_DIALOG_DATA, useValue: data },
|
||||||
|
{ provide: MatDialogRef, useValue: dialogRef }
|
||||||
],
|
],
|
||||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||||
});
|
});
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, Inject, ViewEncapsulation } from '@angular/core';
|
import { Component, Inject, OnInit, ViewEncapsulation } from '@angular/core';
|
||||||
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||||
import { TranslationService, NotificationService, AllowableOperationsEnum, ContentService } from '@alfresco/adf-core';
|
import { TranslationService, NotificationService, AllowableOperationsEnum, ContentService } from '@alfresco/adf-core';
|
||||||
import { Node } from '@alfresco/js-api';
|
import { Node } from '@alfresco/js-api';
|
||||||
|
|
||||||
import { ContentNodeSelectorComponentData } from './content-node-selector.component-data.interface';
|
import { ContentNodeSelectorComponentData } from './content-node-selector.component-data.interface';
|
||||||
import { NodeEntryEvent } from '../document-list/components/node.event';
|
import { NodeEntryEvent } from '../document-list/components/node.event';
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ import { NodeEntryEvent } from '../document-list/components/node.event';
|
|||||||
styleUrls: ['./content-node-selector.component.scss'],
|
styleUrls: ['./content-node-selector.component.scss'],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class ContentNodeSelectorComponent {
|
export class ContentNodeSelectorComponent implements OnInit {
|
||||||
title: string;
|
title: string;
|
||||||
action: string;
|
action: string;
|
||||||
buttonActionName: string;
|
buttonActionName: string;
|
||||||
@ -41,6 +42,7 @@ export class ContentNodeSelectorComponent {
|
|||||||
constructor(private translation: TranslationService,
|
constructor(private translation: TranslationService,
|
||||||
private contentService: ContentService,
|
private contentService: ContentService,
|
||||||
private notificationService: NotificationService,
|
private notificationService: NotificationService,
|
||||||
|
private dialog: MatDialogRef<ContentNodeSelectorComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: ContentNodeSelectorComponentData) {
|
@Inject(MAT_DIALOG_DATA) public data: ContentNodeSelectorComponentData) {
|
||||||
this.action = data.actionName ? data.actionName.toUpperCase() : 'CHOOSE';
|
this.action = data.actionName ? data.actionName.toUpperCase() : 'CHOOSE';
|
||||||
this.buttonActionName = `NODE_SELECTOR.${this.action}`;
|
this.buttonActionName = `NODE_SELECTOR.${this.action}`;
|
||||||
@ -48,6 +50,21 @@ export class ContentNodeSelectorComponent {
|
|||||||
this.currentDirectoryId = data.currentFolderId;
|
this.currentDirectoryId = data.currentFolderId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.dialog.keydownEvents().subscribe(event => {
|
||||||
|
// Esc
|
||||||
|
if (event.keyCode === 27) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopImmediatePropagation();
|
||||||
|
this.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.dialog.backdropClick().subscribe(() => {
|
||||||
|
this.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
this.data.select.complete();
|
this.data.select.complete();
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "../dist/content-services/",
|
"outDir": "../dist/content-services/",
|
||||||
"baseUrl": "src",
|
"baseUrl": "src",
|
||||||
"types": [],
|
|
||||||
"paths": {
|
"paths": {
|
||||||
"@alfresco/adf-extensions": ["../../dist/extensions"],
|
"@alfresco/adf-extensions": ["../../dist/extensions"],
|
||||||
"@alfresco/adf-extensions/*": ["../../dist/extensions/*"],
|
"@alfresco/adf-extensions/*": ["../../dist/extensions/*"],
|
||||||
|
@ -580,6 +580,10 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
@HostListener('document:keyup', ['$event'])
|
@HostListener('document:keyup', ['$event'])
|
||||||
handleKeyboardEvent(event: KeyboardEvent) {
|
handleKeyboardEvent(event: KeyboardEvent) {
|
||||||
|
if (event && event.defaultPrevented) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const key = event.keyCode;
|
const key = event.keyCode;
|
||||||
|
|
||||||
// Esc
|
// Esc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user