mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-523] Fix delete operation in the search component (#2020)
* Search delete permission notification fix * Support content deletion inside search results * Forgotten broken test fix. * Update alfresco-document-list READDME.md * Update alfresco-document-list READDME.md II * Adding TOC to README.md * Build fix * Fix the build for now and ever!
This commit is contained in:
committed by
Eugenio Romano
parent
ee871ba578
commit
843afdbcc6
@@ -50,7 +50,9 @@
|
||||
<content-action
|
||||
target="folder"
|
||||
title="{{'SEARCH.DOCUMENT_LIST.ACTIONS.FOLDER.DELETE' | translate}}"
|
||||
handler="delete">
|
||||
permission="delete"
|
||||
handler="delete"
|
||||
(permissionEvent)="handlePermission($event)">
|
||||
</content-action>
|
||||
<!-- document actions -->
|
||||
<content-action
|
||||
@@ -61,7 +63,10 @@
|
||||
<content-action
|
||||
target="document"
|
||||
title="{{'SEARCH.DOCUMENT_LIST.ACTIONS.DOCUMENT.DELETE' | translate}}"
|
||||
handler="delete">
|
||||
permission="delete"
|
||||
handler="delete"
|
||||
(execute)="onContentDelete($event)"
|
||||
(permissionEvent)="handlePermission($event)">
|
||||
</content-action>
|
||||
</content-actions>
|
||||
</adf-document-list>
|
||||
|
@@ -22,8 +22,9 @@ import { Observable } from 'rxjs/Rx';
|
||||
import { AlfrescoSearchComponent } from './alfresco-search.component';
|
||||
import { TranslationMock } from './../assets/translation.service.mock';
|
||||
import { AlfrescoSearchService } from '../services/alfresco-search.service';
|
||||
import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core';
|
||||
import { AlfrescoTranslationService, CoreModule, NotificationService } from 'ng2-alfresco-core';
|
||||
import { DocumentListModule } from 'ng2-alfresco-documentlist';
|
||||
import { PermissionModel } from 'ng2-alfresco-documentlist';
|
||||
|
||||
describe('AlfrescoSearchComponent', () => {
|
||||
|
||||
@@ -104,7 +105,8 @@ describe('AlfrescoSearchComponent', () => {
|
||||
declarations: [AlfrescoSearchComponent], // declare the test component
|
||||
providers: [
|
||||
AlfrescoSearchService,
|
||||
{ provide: AlfrescoTranslationService, useClass: TranslationMock }
|
||||
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
|
||||
{ provide: NotificationService, useClass: NotificationService }
|
||||
]
|
||||
}).compileComponents().then(() => {
|
||||
fixture = TestBed.createComponent(AlfrescoSearchComponent);
|
||||
@@ -126,7 +128,7 @@ describe('AlfrescoSearchComponent', () => {
|
||||
{provide: ActivatedRoute, useValue: {params: Observable.from([{q: 'exampleTerm692'}])}}
|
||||
]);
|
||||
|
||||
let search = new AlfrescoSearchComponent(null, null, injector.get(ActivatedRoute));
|
||||
let search = new AlfrescoSearchComponent(null, null, null, injector.get(ActivatedRoute));
|
||||
|
||||
search.ngOnInit();
|
||||
|
||||
@@ -142,11 +144,20 @@ describe('AlfrescoSearchComponent', () => {
|
||||
expect(translationService.addTranslationFolder).toHaveBeenCalledWith('ng2-alfresco-search', 'assets/ng2-alfresco-search');
|
||||
});
|
||||
|
||||
it('should show the Notification snackbar on permission error', () => {
|
||||
const notoficationService = TestBed.get(NotificationService);
|
||||
spyOn(notoficationService, 'openSnackMessage');
|
||||
|
||||
component.handlePermission(new PermissionModel());
|
||||
|
||||
expect(notoficationService.openSnackMessage).toHaveBeenCalledWith('PERMISSON.LACKOF', 3000);
|
||||
});
|
||||
|
||||
describe('Search results', () => {
|
||||
|
||||
it('should call search service with the correct parameters', (done) => {
|
||||
let searchTerm = 'searchTerm63688', options = {
|
||||
include: ['path'],
|
||||
include: ['path', 'allowableOperations'],
|
||||
skipCount: 0,
|
||||
rootNodeId: '-my-',
|
||||
nodeType: 'my:type',
|
||||
|
@@ -18,7 +18,8 @@
|
||||
import { Component, EventEmitter, Input, Output, Optional, OnChanges, SimpleChanges, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Params } from '@angular/router';
|
||||
import { AlfrescoSearchService, SearchOptions } from './../services/alfresco-search.service';
|
||||
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
||||
import { AlfrescoTranslationService, NotificationService } from 'ng2-alfresco-core';
|
||||
import { PermissionModel } from 'ng2-alfresco-documentlist';
|
||||
import { NodePaging, Pagination } from 'alfresco-js-api';
|
||||
|
||||
@Component({
|
||||
@@ -66,6 +67,7 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
|
||||
|
||||
constructor(private searchService: AlfrescoSearchService,
|
||||
private translateService: AlfrescoTranslationService,
|
||||
private notificationService: NotificationService,
|
||||
@Optional() private route: ActivatedRoute) {
|
||||
}
|
||||
|
||||
@@ -107,7 +109,7 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
|
||||
private displaySearchResults(searchTerm) {
|
||||
if (searchTerm && this.searchService) {
|
||||
let searchOpts: SearchOptions = {
|
||||
include: ['path'],
|
||||
include: ['path', 'allowableOperations'],
|
||||
skipCount: this.skipCount,
|
||||
rootNodeId: this.rootNodeId,
|
||||
nodeType: this.resultType,
|
||||
@@ -147,4 +149,13 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
|
||||
this.skipCount = event.skipCount;
|
||||
this.displaySearchResults(this.searchTerm);
|
||||
}
|
||||
|
||||
public onContentDelete(entry: any) {
|
||||
this.displaySearchResults(this.searchTerm);
|
||||
}
|
||||
|
||||
public handlePermission(permission: PermissionModel): void {
|
||||
let permissionErrorMessage: any = this.translateService.get('PERMISSON.LACKOF', permission);
|
||||
this.notificationService.openSnackMessage(permissionErrorMessage.value, 3000);
|
||||
}
|
||||
}
|
||||
|
@@ -42,5 +42,8 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"PERMISSON": {
|
||||
"LACKOF": "You don't have the {{permission}} permission to {{action}} the {{type}}"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user