[ACA-1270] confirm permanent deletion (#292)

* confirm permanent deletion

* fix tests
This commit is contained in:
Denys Vuika 2018-04-09 10:26:58 +01:00 committed by GitHub
parent 922aab058d
commit d8d788e00b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 3 deletions

View File

@ -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: `<div [app-permanent-delete-node]="selection"></div>`
@ -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', () => {

View File

@ -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() {

View File

@ -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",