mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2682][ADF-2714][ADF-2719] fix issues folder navigation and messages releated (#3196)
* [ADF-2687] No message is displayed when deleting a folder from content action [ADF-2714] Not able to download a version of a file [ADF-2682] Number of page doesn't change when navigating to another folder Expand lock documentation * fix test init
This commit is contained in:
@@ -63,8 +63,8 @@ describe('ContentAction', () => {
|
||||
beforeEach(() => {
|
||||
contentService = TestBed.get(ContentService);
|
||||
nodeActionsService = new NodeActionsService(null, null, null);
|
||||
documentActions = new DocumentActionsService(nodeActionsService, null, null);
|
||||
folderActions = new FolderActionsService(nodeActionsService, null, contentService);
|
||||
documentActions = new DocumentActionsService(nodeActionsService, null, null, null);
|
||||
folderActions = new FolderActionsService(nodeActionsService, null, contentService, null);
|
||||
|
||||
documentList = (TestBed.createComponent(DocumentListComponent).componentInstance as DocumentListComponent);
|
||||
actionList = new ContentActionListComponent(documentList);
|
||||
|
@@ -465,7 +465,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
}
|
||||
|
||||
updateFolderData(node: MinimalNodeEntity): void {
|
||||
this.folderNode = null;
|
||||
this.resetNewFolderPagination();
|
||||
this.currentFolderId = node.entry.id;
|
||||
this.reload();
|
||||
this.folderChange.emit(new NodeEntryEvent(node.entry));
|
||||
|
@@ -118,7 +118,7 @@ export class DocumentActionsService {
|
||||
);
|
||||
}
|
||||
|
||||
private deleteNode(node: any, target?: any, permission?: string): Observable<any> {
|
||||
private deleteNode(node: MinimalNodeEntity, target?: any, permission?: string): Observable<any> {
|
||||
let handlerObservable;
|
||||
|
||||
if (this.canExecuteAction(node)) {
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { AlfrescoApiServiceMock, AppConfigService, StorageService, ContentService } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiServiceMock, AppConfigService, StorageService, ContentService, TranslationMock } from '@alfresco/adf-core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { FileNode, FolderNode } from '../../mock';
|
||||
import { ContentActionHandler } from '../models/content-action.model';
|
||||
@@ -35,7 +35,7 @@ describe('FolderActionsService', () => {
|
||||
let contentService = new ContentService(null, null, null, null);
|
||||
let alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
||||
documentListService = new DocumentListService(null, contentService, alfrescoApiService, null, null);
|
||||
service = new FolderActionsService(null, documentListService, contentService);
|
||||
service = new FolderActionsService(null, documentListService, contentService, new TranslationMock());
|
||||
});
|
||||
|
||||
it('should register custom action handler', () => {
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ContentService } from '@alfresco/adf-core';
|
||||
import { ContentService, TranslationService } from '@alfresco/adf-core';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MinimalNodeEntity } from 'alfresco-js-api';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
@@ -37,7 +37,8 @@ export class FolderActionsService {
|
||||
|
||||
constructor(private nodeActionsService: NodeActionsService,
|
||||
private documentListService: DocumentListService,
|
||||
private contentService: ContentService) {
|
||||
private contentService: ContentService,
|
||||
private translation: TranslationService) {
|
||||
this.setupActionHandlers();
|
||||
}
|
||||
|
||||
@@ -113,18 +114,24 @@ export class FolderActionsService {
|
||||
);
|
||||
}
|
||||
|
||||
private deleteNode(obj: any, target?: any, permission?: string): Observable<any> {
|
||||
private deleteNode(node: MinimalNodeEntity, target?: any, permission?: string): Observable<any> {
|
||||
let handlerObservable: Observable<any>;
|
||||
|
||||
if (this.canExecuteAction(obj)) {
|
||||
if (this.contentService.hasPermission(obj.entry, permission)) {
|
||||
handlerObservable = this.documentListService.deleteNode(obj.entry.id);
|
||||
if (this.canExecuteAction(node)) {
|
||||
if (this.contentService.hasPermission(node.entry, permission)) {
|
||||
handlerObservable = this.documentListService.deleteNode(node.entry.id);
|
||||
handlerObservable.subscribe(() => {
|
||||
if (target && typeof target.reload === 'function') {
|
||||
target.reload();
|
||||
}
|
||||
this.success.next(obj.entry.id);
|
||||
|
||||
let message = this.translation.instant('CORE.DELETE_NODE.SINGULAR', { name: node.entry.name });
|
||||
this.success.next(message);
|
||||
}, () => {
|
||||
let message = this.translation.instant('CORE.DELETE_NODE.ERROR_SINGULAR', { name: node.entry.name });
|
||||
this.error.next(message);
|
||||
});
|
||||
|
||||
return handlerObservable;
|
||||
} else {
|
||||
this.permissionEvent.next(new PermissionModel({type: 'folder', action: 'delete', permission: permission}));
|
||||
|
Reference in New Issue
Block a user