[ADF-1368] Delete a document onto document list update even the file upload dialog (#2267)

* [ADF-1368] adding success action event even form file deleted on document actions

* [ADF-1368] reflecting delete changes on documentlist

* [ADF-1368] added event on upload service when a file is deleted from external source

* [ADF-1368] pinned version beta8 for material

* [ADF-1368] added test cases for success event on documentlist actions delete
This commit is contained in:
Vito
2017-08-31 10:16:09 -07:00
committed by Mario Romano
parent e0ffeb0ea5
commit 42ed604349
28 changed files with 93 additions and 35 deletions

View File

@@ -203,6 +203,7 @@
[disableWithNoPermission]="true"
(permissionEvent)="handlePermissionError($event)"
title="{{'DOCUMENT_LIST.ACTIONS.DOCUMENT.DELETE' | translate}}"
(success)="onDeleteActionSuccess($event)"
handler="delete">
</content-action>
</content-actions>

View File

@@ -206,6 +206,10 @@ export class FilesComponent implements OnInit {
this.notificationService.openSnackMessage(translatedMessage.value, 4000);
}
onDeleteActionSuccess(message) {
this.uploadService.fileDeleted.next(message);
}
onCreateFolderClicked(event: Event) {
let dialogRef = this.dialog.open(CreateFolderDialogComponent);
dialogRef.afterClosed().subscribe(folderName => {

View File

@@ -63,7 +63,7 @@
"@angular/core": "4.2.5",
"@angular/forms": "4.2.5",
"@angular/http": "4.2.5",
"@angular/material": "^2.0.0-beta.8",
"@angular/material": "2.0.0-beta.8",
"@angular/platform-browser": "4.2.5",
"@angular/platform-browser-dynamic": "4.2.5",
"@angular/router": "4.2.5",

View File

@@ -39,7 +39,7 @@
"@angular/core": "4.2.5",
"@angular/forms": "4.2.5",
"@angular/http": "4.2.5",
"@angular/material": "^2.0.0-beta.8",
"@angular/material": "2.0.0-beta.8",
"@angular/platform-browser": "4.2.5",
"@angular/platform-browser-dynamic": "4.2.5",
"@angular/router": "4.2.5",

View File

@@ -35,7 +35,7 @@
"@angular/core": "4.2.5",
"@angular/forms": "4.2.5",
"@angular/http": "4.2.5",
"@angular/material": "^2.0.0-beta.8",
"@angular/material": "2.0.0-beta.8",
"@angular/platform-browser": "4.2.5",
"@angular/platform-browser-dynamic": "4.2.5",
"@angular/router": "4.2.5",

View File

@@ -42,7 +42,7 @@
"@angular/core": "4.2.5",
"@angular/forms": "4.2.5",
"@angular/http": "4.2.5",
"@angular/material": "^2.0.0-beta.8",
"@angular/material": "2.0.0-beta.8",
"@angular/platform-browser": "4.2.5",
"@angular/platform-browser-dynamic": "4.2.5",
"@angular/router": "4.2.5",

View File

@@ -41,7 +41,7 @@
"@angular/core": "4.2.5",
"@angular/forms": "4.2.5",
"@angular/http": "4.2.5",
"@angular/material": "^2.0.0-beta.8",
"@angular/material": "2.0.0-beta.8",
"@angular/platform-browser": "4.2.5",
"@angular/platform-browser-dynamic": "4.2.5",
"@angular/router": "4.2.5",

View File

@@ -45,7 +45,7 @@
"@angular/core": "4.2.5",
"@angular/forms": "4.2.5",
"@angular/http": "4.2.5",
"@angular/material": "^2.0.0-beta.8",
"@angular/material": "2.0.0-beta.8",
"@angular/platform-browser": "4.2.5",
"@angular/platform-browser-dynamic": "4.2.5",
"@angular/router": "4.2.5",

View File

@@ -50,7 +50,7 @@
"@angular/core": "4.2.5",
"@angular/forms": "4.2.5",
"@angular/http": "4.2.5",
"@angular/material": "^2.0.0-beta.8",
"@angular/material": "2.0.0-beta.8",
"@angular/platform-browser": "4.2.5",
"@angular/platform-browser-dynamic": "4.2.5",
"@angular/router": "4.2.5",

View File

@@ -43,6 +43,7 @@ export class UploadService {
fileUploadError: Subject<FileUploadErrorEvent> = new Subject<FileUploadErrorEvent>();
fileUploadComplete: Subject<FileUploadCompleteEvent> = new Subject<FileUploadCompleteEvent>();
fileUploadDeleted: Subject<FileUploadDeleteEvent> = new Subject<FileUploadDeleteEvent>();
fileDeleted: Subject<string> = new Subject<string>();
constructor(private apiService: AlfrescoApiService, private appConfigService: AppConfigService) {
this.excludedFileList = <String[]> this.appConfigService.get('files.excluded');

View File

@@ -41,7 +41,7 @@
"@angular/core": "4.2.5",
"@angular/forms": "4.2.5",
"@angular/http": "4.2.5",
"@angular/material": "^2.0.0-beta.8",
"@angular/material": "2.0.0-beta.8",
"@angular/platform-browser": "4.2.5",
"@angular/platform-browser-dynamic": "4.2.5",
"@angular/router": "4.2.5",

View File

@@ -729,7 +729,7 @@ Events:
| --- | --- | --- |
| `execute` | All | Emitted when user clicks on the action. For combined handlers see below |
| `permissionEvent` | All | Emitted when a permission error happens |
| `success` | copy, move | Emitted on successful action with the success string message |
| `success` | copy, move, delete | Emitted on successful action with the success string message |
| `error` | copy, move | Emitted on unsuccessful action with the error event |
DocumentList supports declarative actions for Documents and Folders.

View File

@@ -49,7 +49,7 @@
"@angular/core": "4.2.5",
"@angular/forms": "4.2.5",
"@angular/http": "4.2.5",
"@angular/material": "^2.0.0-beta.8",
"@angular/material": "2.0.0-beta.8",
"@angular/platform-browser": "4.2.5",
"@angular/platform-browser-dynamic": "4.2.5",
"@angular/router": "4.2.5",

View File

@@ -267,4 +267,20 @@ describe('DocumentActionsService', () => {
expect(documentListService.deleteNode).toHaveBeenCalled();
expect(target.reload).toHaveBeenCalled();
});
it('should emit success event upon node deletion', (done) => {
service.success.subscribe((nodeId) => {
expect(nodeId).not.toBeNull();
done();
});
spyOn(documentListService, 'deleteNode').and.callThrough();
let target = jasmine.createSpyObj('obj', ['reload']);
let permission = 'delete';
let file = new FileNode();
let fileWithPermission: any = file;
fileWithPermission.entry.allowableOperations = [permission];
service.getHandler('delete')(fileWithPermission, target, permission);
});
});

View File

@@ -115,6 +115,7 @@ export class DocumentActionsService {
if (target && typeof target.reload === 'function') {
target.reload();
}
this.success.next(obj.entry.id);
});
return handlerObservable;
} else {

View File

@@ -249,4 +249,26 @@ describe('FolderActionsService', () => {
expect(documentListService.deleteNode).toHaveBeenCalled();
});
it('should emit success event upon node deletion', (done) => {
spyOn(documentListService, 'deleteNode').and.callFake(() => {
return new Observable<any>(observer => {
observer.next();
observer.complete();
});
});
service.success.subscribe((nodeId) => {
expect(nodeId).not.toBeNull();
done();
});
let permission = 'delete';
let target = jasmine.createSpyObj('obj', ['reload']);
let folder = new FolderNode();
let folderWithPermission: any = folder;
folderWithPermission.entry.allowableOperations = [permission];
service.getHandler('delete')(folderWithPermission, target, permission);
});
});

View File

@@ -100,6 +100,7 @@ export class FolderActionsService {
if (target && typeof target.reload === 'function') {
target.reload();
}
this.success.next(obj.entry.id);
});
return handlerObservable;
} else {

View File

@@ -53,7 +53,7 @@
"@angular/core": "4.2.5",
"@angular/forms": "4.2.5",
"@angular/http": "4.2.5",
"@angular/material": "^2.0.0-beta.8",
"@angular/material": "2.0.0-beta.8",
"@angular/platform-browser": "4.2.5",
"@angular/platform-browser-dynamic": "4.2.5",
"@angular/router": "4.2.5",

View File

@@ -49,7 +49,7 @@
"@angular/core": "4.2.5",
"@angular/forms": "4.2.5",
"@angular/http": "4.2.5",
"@angular/material": "^2.0.0-beta.8",
"@angular/material": "2.0.0-beta.8",
"@angular/platform-browser": "4.2.5",
"@angular/platform-browser-dynamic": "4.2.5",
"@angular/router": "4.2.5",

View File

@@ -29,7 +29,7 @@
"@angular/core": "4.2.5",
"@angular/forms": "4.2.5",
"@angular/http": "4.2.5",
"@angular/material": "^2.0.0-beta.8",
"@angular/material": "2.0.0-beta.8",
"@angular/platform-browser": "4.2.5",
"@angular/platform-browser-dynamic": "4.2.5",
"@angular/router": "4.2.5",

View File

@@ -29,7 +29,7 @@
"@angular/core": "4.2.5",
"@angular/forms": "4.2.5",
"@angular/http": "4.2.5",
"@angular/material": "^2.0.0-beta.8",
"@angular/material": "2.0.0-beta.8",
"@angular/platform-browser": "4.2.5",
"@angular/platform-browser-dynamic": "4.2.5",
"@angular/router": "4.2.5",

View File

@@ -201,6 +201,7 @@ Provides access to various APIs related to file upload features.
| fileUploadError | FileUploadEvent | Raised when an error occurs to file upload. |
| fileUploadComplete | FileUploadCompleteEvent | Raised when file upload is complete. |
| fileUploadDelete | FileUploadDeleteEvent | Raised when uploaded file is removed from server. |
| fileDeleted | string | This can be invoked when a file is deleted from an external source to upload the file dialog status. |
### Details

View File

@@ -50,7 +50,7 @@
"@angular/core": "4.2.5",
"@angular/forms": "4.2.5",
"@angular/http": "4.2.5",
"@angular/material": "^2.0.0-beta.8",
"@angular/material": "2.0.0-beta.8",
"@angular/platform-browser": "4.2.5",
"@angular/platform-browser-dynamic": "4.2.5",
"@angular/router": "4.2.5",

View File

@@ -17,7 +17,7 @@
import { ChangeDetectorRef, Component, Input, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { FileModel, FileUploadCompleteEvent, FileUploadDeleteEvent,
FileUploadErrorEvent, UploadService } from 'ng2-alfresco-core';
FileUploadErrorEvent, FileUploadStatus, UploadService } from 'ng2-alfresco-core';
import { Observable, Subscription } from 'rxjs/Rx';
import { FileUploadingListComponent } from './file-uploading-list.component';
@@ -78,6 +78,18 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy {
.fileUpload.subscribe(() => {
this.changeDetecor.detectChanges();
});
this.uploadService.fileDeleted.subscribe((objId) => {
if (this.filesUploadingList) {
let file = this.filesUploadingList.find((item) => {
return item.data.entry.id === objId;
});
if (file) {
file.status = FileUploadStatus.Cancelled;
this.changeDetecor.detectChanges();
}
}
});
}
/**

View File

@@ -29,7 +29,7 @@
"@angular/core": "4.2.5",
"@angular/forms": "4.2.5",
"@angular/http": "4.2.5",
"@angular/material": "^2.0.0-beta.8",
"@angular/material": "2.0.0-beta.8",
"@angular/platform-browser": "4.2.5",
"@angular/platform-browser-dynamic": "4.2.5",
"@angular/router": "4.2.5",

View File

@@ -44,7 +44,7 @@
"@angular/core": "4.2.5",
"@angular/forms": "4.2.5",
"@angular/http": "4.2.5",
"@angular/material": "^2.0.0-beta.8",
"@angular/material": "2.0.0-beta.8",
"@angular/platform-browser": "4.2.5",
"@angular/platform-browser-dynamic": "4.2.5",
"@angular/router": "4.2.5",

View File

@@ -29,7 +29,7 @@
"@angular/core": "4.2.5",
"@angular/forms": "4.2.5",
"@angular/http": "4.2.5",
"@angular/material": "^2.0.0-beta.8",
"@angular/material": "2.0.0-beta.8",
"@angular/platform-browser": "4.2.5",
"@angular/platform-browser-dynamic": "4.2.5",
"@angular/router": "4.2.5",

View File

@@ -7,8 +7,7 @@
"clean": "rimraf node_modules",
"clean-lock": "rimraf package-lock.json",
"rimraf": "rimraf",
"build": "npm run build-style && npm run toc && npm run markdownlint && npm run webpack -- --config config/webpack.build.js --progress --profile --bail",
"build-style": "npm run webpack -- --config config/webpack.style.js --progress --profile --bail",
"build": "npm run toc && npm run markdownlint && npm run webpack -- --config config/webpack.build.js --progress --profile --bail",
"test": "node node_modules/karma/bin/karma start --reporters mocha,coverage --single-run --component .",
"test-browser": "node node_modules/karma/bin/karma start karma.conf.js --reporters kjhtml",
"coverage": "",
@@ -69,32 +68,32 @@
"@angular/core": "4.2.5",
"@angular/forms": "4.2.5",
"@angular/http": "4.2.5",
"@angular/material": "^2.0.0-beta.8",
"@angular/material": "2.0.0-beta.8",
"@angular/platform-browser": "4.2.5",
"@angular/platform-browser-dynamic": "4.2.5",
"@angular/router": "4.2.5",
"@ngx-translate/core": "7.0.0",
"alfresco-js-api": "^1.8.0-9feb5d0164d6c5f994df8758e41ed126a8f69db2",
"chart.js": "2.5.0",
"alfresco-js-api": "1.7.0",
"core-js": "2.4.1",
"hammerjs": "2.0.8",
"material-design-icons": "2.2.3",
"material-design-lite": "1.2.1",
"minimatch": "3.0.4",
"moment": "2.15.1",
"ng2-activiti-diagrams": "1.7.0",
"ng2-activiti-form": "1.7.0",
"ng2-activiti-tasklist": "1.7.0",
"ng2-alfresco-core": "1.7.0",
"ng2-alfresco-datatable": "1.7.0",
"ng2-alfresco-documentlist": "1.7.0",
"ng2-charts": "1.6.0",
"pdfjs-dist": "1.5.404",
"raphael": "2.2.7",
"reflect-metadata": "0.1.10",
"rxjs": "5.1.0",
"systemjs": "0.19.27",
"zone.js": "0.6.26"
"zone.js": "0.6.26",
"ng2-alfresco-core": "1.7.0",
"raphael": "2.2.7",
"chart.js": "2.5.0",
"ng2-activiti-diagrams": "1.7.0",
"ng2-charts": "1.6.0",
"ng2-activiti-form": "1.7.0",
"ng2-alfresco-datatable": "1.7.0",
"ng2-activiti-tasklist": "1.7.0",
"ng2-alfresco-documentlist": "1.7.0",
"minimatch": "3.0.4",
"pdfjs-dist": "1.5.404"
},
"devDependencies": {
"@types/hammerjs": "2.0.34",