diff --git a/src/app/common/directives/node-permanent-delete.directive.spec.ts b/src/app/common/directives/node-permanent-delete.directive.spec.ts index 50031e950..f08ffd5d8 100644 --- a/src/app/common/directives/node-permanent-delete.directive.spec.ts +++ b/src/app/common/directives/node-permanent-delete.directive.spec.ts @@ -30,6 +30,7 @@ import { Observable } from 'rxjs/Rx'; import { AlfrescoApiService, TranslationService, NotificationService, CoreModule } from '@alfresco/adf-core'; import { NodePermanentDeleteDirective } from './node-permanent-delete.directive'; +import { MatDialogModule, MatDialog } from '@angular/material'; @Component({ template: `
` @@ -47,11 +48,13 @@ describe('NodePermanentDeleteDirective', () => { let notificationService: NotificationService; let nodesService; let directiveInstance; + let dialog: MatDialog; beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ - CoreModule + CoreModule, + MatDialogModule ], declarations: [ NodePermanentDeleteDirective, @@ -65,6 +68,7 @@ describe('NodePermanentDeleteDirective', () => { element = fixture.debugElement.query(By.directive(NodePermanentDeleteDirective)); directiveInstance = element.injector.get(NodePermanentDeleteDirective); + dialog = TestBed.get(MatDialog); alfrescoService = TestBed.get(AlfrescoApiService); translation = TestBed.get(TranslationService); notificationService = TestBed.get(NotificationService); @@ -76,6 +80,12 @@ describe('NodePermanentDeleteDirective', () => { spyOn(translation, 'get').and.returnValue(Observable.of('message')); spyOn(notificationService, 'openSnackMessage').and.returnValue({}); + + spyOn(dialog, 'open').and.returnValue({ + afterClosed() { + return Observable.of(true) + } + }); }); it('does not purge nodes if no selection', () => { diff --git a/src/app/common/directives/node-permanent-delete.directive.ts b/src/app/common/directives/node-permanent-delete.directive.ts index 1c0339ec7..9a395b84d 100644 --- a/src/app/common/directives/node-permanent-delete.directive.ts +++ b/src/app/common/directives/node-permanent-delete.directive.ts @@ -28,6 +28,8 @@ import { Observable } from 'rxjs/Rx'; import { TranslationService, AlfrescoApiService, NotificationService } from '@alfresco/adf-core'; import { MinimalNodeEntity } from 'alfresco-js-api'; +import { MatDialog } from '@angular/material'; +import { ConfirmDialogComponent } from '@alfresco/adf-content-services'; @Directive({ // tslint:disable-next-line:directive-selector @@ -41,14 +43,27 @@ export class NodePermanentDeleteDirective { @HostListener('click') onClick() { - this.purge(); + const dialogRef = this.dialog.open(ConfirmDialogComponent, { + data: { + title: 'APP.DIALOGS.CONFIRM_PURGE.TITLE', + message: 'APP.DIALOGS.CONFIRM_PURGE.MESSAGE' + }, + minWidth: '250px' + }); + + dialogRef.afterClosed().subscribe(result => { + if (result === true) { + this.purge(); + } + }); } constructor( private alfrescoApiService: AlfrescoApiService, private translation: TranslationService, private notification: NotificationService, - private el: ElementRef + private el: ElementRef, + private dialog: MatDialog ) {} private purge() { diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 1aac072ab..c4576be3e 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -106,6 +106,12 @@ "DETAILS": "View details", "VERSIONS": "Manage Versions" }, + "DIALOGS": { + "CONFIRM_PURGE": { + "TITLE": "Delete", + "MESSAGE": "Permanently delete item(s) from the trash?" + } + }, "DOCUMENT_LIST": { "COLUMNS": { "NAME": "Name",