[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 { AlfrescoApiService, TranslationService, NotificationService, CoreModule } from '@alfresco/adf-core';
import { NodePermanentDeleteDirective } from './node-permanent-delete.directive'; import { NodePermanentDeleteDirective } from './node-permanent-delete.directive';
import { MatDialogModule, MatDialog } from '@angular/material';
@Component({ @Component({
template: `<div [app-permanent-delete-node]="selection"></div>` template: `<div [app-permanent-delete-node]="selection"></div>`
@ -47,11 +48,13 @@ describe('NodePermanentDeleteDirective', () => {
let notificationService: NotificationService; let notificationService: NotificationService;
let nodesService; let nodesService;
let directiveInstance; let directiveInstance;
let dialog: MatDialog;
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
CoreModule CoreModule,
MatDialogModule
], ],
declarations: [ declarations: [
NodePermanentDeleteDirective, NodePermanentDeleteDirective,
@ -65,6 +68,7 @@ describe('NodePermanentDeleteDirective', () => {
element = fixture.debugElement.query(By.directive(NodePermanentDeleteDirective)); element = fixture.debugElement.query(By.directive(NodePermanentDeleteDirective));
directiveInstance = element.injector.get(NodePermanentDeleteDirective); directiveInstance = element.injector.get(NodePermanentDeleteDirective);
dialog = TestBed.get(MatDialog);
alfrescoService = TestBed.get(AlfrescoApiService); alfrescoService = TestBed.get(AlfrescoApiService);
translation = TestBed.get(TranslationService); translation = TestBed.get(TranslationService);
notificationService = TestBed.get(NotificationService); notificationService = TestBed.get(NotificationService);
@ -76,6 +80,12 @@ describe('NodePermanentDeleteDirective', () => {
spyOn(translation, 'get').and.returnValue(Observable.of('message')); spyOn(translation, 'get').and.returnValue(Observable.of('message'));
spyOn(notificationService, 'openSnackMessage').and.returnValue({}); spyOn(notificationService, 'openSnackMessage').and.returnValue({});
spyOn(dialog, 'open').and.returnValue({
afterClosed() {
return Observable.of(true)
}
});
}); });
it('does not purge nodes if no selection', () => { 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 { TranslationService, AlfrescoApiService, NotificationService } from '@alfresco/adf-core';
import { MinimalNodeEntity } from 'alfresco-js-api'; import { MinimalNodeEntity } from 'alfresco-js-api';
import { MatDialog } from '@angular/material';
import { ConfirmDialogComponent } from '@alfresco/adf-content-services';
@Directive({ @Directive({
// tslint:disable-next-line:directive-selector // tslint:disable-next-line:directive-selector
@ -41,14 +43,27 @@ export class NodePermanentDeleteDirective {
@HostListener('click') @HostListener('click')
onClick() { 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( constructor(
private alfrescoApiService: AlfrescoApiService, private alfrescoApiService: AlfrescoApiService,
private translation: TranslationService, private translation: TranslationService,
private notification: NotificationService, private notification: NotificationService,
private el: ElementRef private el: ElementRef,
private dialog: MatDialog
) {} ) {}
private purge() { private purge() {

View File

@ -106,6 +106,12 @@
"DETAILS": "View details", "DETAILS": "View details",
"VERSIONS": "Manage Versions" "VERSIONS": "Manage Versions"
}, },
"DIALOGS": {
"CONFIRM_PURGE": {
"TITLE": "Delete",
"MESSAGE": "Permanently delete item(s) from the trash?"
}
},
"DOCUMENT_LIST": { "DOCUMENT_LIST": {
"COLUMNS": { "COLUMNS": {
"NAME": "Name", "NAME": "Name",