mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3854] Destination picker - exclude site content option (#4130)
This commit is contained in:
committed by
Eugenio Romano
parent
6be1cf56e3
commit
c17241fedc
@@ -112,6 +112,39 @@
|
||||
</adf-content-node-selector-panel>
|
||||
</div>
|
||||
</mat-expansion-panel>
|
||||
<mat-expansion-panel>
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
<h2>Exclude Site Content</h2>
|
||||
</mat-panel-title>
|
||||
<mat-panel-description>
|
||||
<label class="adf-content-node-selector-demo-basic-label">
|
||||
The exclude site content is filtered out from the list
|
||||
</label>
|
||||
</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
<div>
|
||||
<label>Case when the excludeSiteContent is set as : <b>{{ excludeSiteContentList.join(', ') }}</b></label>
|
||||
</div>
|
||||
<div>
|
||||
<label>Navigate into a site having the top content along the 'documentLibrary' to see that such items are not displayed.</label>
|
||||
</div>
|
||||
<br />
|
||||
<mat-slide-toggle color="primary" [(ngModel)]="showFiles" (click)="recreateRowFilterFunction()">
|
||||
Show Files
|
||||
</mat-slide-toggle>
|
||||
<mat-slide-toggle color="primary" [(ngModel)]="showFolders" (click)="recreateRowFilterFunction()">
|
||||
Show Folders
|
||||
</mat-slide-toggle>
|
||||
|
||||
<div class="adf-content-node-selector-demo-basic-table">
|
||||
<adf-content-node-selector-panel
|
||||
[rowFilter]="rowFilterFunction"
|
||||
[excludeSiteContent]="excludeSiteContentList"
|
||||
[currentFolderId]="'-root-'">
|
||||
</adf-content-node-selector-panel>
|
||||
</div>
|
||||
</mat-expansion-panel>
|
||||
<mat-expansion-panel>
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import { Component, ViewEncapsulation } from '@angular/core';
|
||||
import { SitePaging, SiteEntry, MinimalNodeEntryEntity } from '@alfresco/js-api';
|
||||
import { ShareDataRow } from '@alfresco/adf-content-services';
|
||||
import { ContentNodeDialogService, ShareDataRow } from '@alfresco/adf-content-services';
|
||||
import { DataRow, DataColumn, ThumbnailService } from '@alfresco/adf-core';
|
||||
|
||||
@Component({
|
||||
@@ -41,6 +41,7 @@ export class ContentNodeSelectorComponent {
|
||||
actualPageSize = 2;
|
||||
|
||||
rowFilterFunction: any = null;
|
||||
excludeSiteContentList: string[] = ContentNodeDialogService.nonDocumentSiteContent;
|
||||
customImageResolver: any = null;
|
||||
|
||||
defaultSites: SiteEntry[] = [
|
||||
|
@@ -38,6 +38,7 @@ Opens a Content Node Selector in its own dialog window.
|
||||
| isSelectionValid | `ValidationFunction` | defaultValidation | Function used to decide if the selected node has permission to be selected. Default value is a function that always returns true. |
|
||||
| pageSize | `number` | | Number of items shown per page in the list. |
|
||||
| rowFilter | `RowFilter` | null | Custom row filter function. See the [Document List component](document-list.component.md#custom-row-filter) for more information. |
|
||||
| excludeSiteContent | string[] | [] | Custom list of site content componentIds that is used to filter out their corresponding items from the displayed nodes. |
|
||||
|
||||
### Events
|
||||
|
||||
|
@@ -32,6 +32,14 @@ import { switchMap } from 'rxjs/operators';
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ContentNodeDialogService {
|
||||
static nonDocumentSiteContent = [
|
||||
'blog',
|
||||
'calendar',
|
||||
'dataLists',
|
||||
'discussions',
|
||||
'links',
|
||||
'wiki'
|
||||
];
|
||||
|
||||
/** Emitted when an error occurs. */
|
||||
@Output()
|
||||
@@ -117,9 +125,10 @@ export class ContentNodeDialogService {
|
||||
* @param action Name of the action (eg, "Copy" or "Move") to show in the title
|
||||
* @param contentEntry Item to be copied or moved
|
||||
* @param permission Permission for the operation
|
||||
* @param excludeSiteContent The site content that should be filtered out
|
||||
* @returns Information about files that were copied/moved
|
||||
*/
|
||||
openCopyMoveDialog(action: string, contentEntry: Node, permission?: string): Observable<Node[]> {
|
||||
openCopyMoveDialog(action: string, contentEntry: Node, permission?: string, excludeSiteContent?: string[]): Observable<Node[]> {
|
||||
if (this.contentService.hasPermission(contentEntry, permission)) {
|
||||
|
||||
const select = new Subject<Node[]>();
|
||||
@@ -136,6 +145,7 @@ export class ContentNodeDialogService {
|
||||
imageResolver: this.imageResolver.bind(this),
|
||||
rowFilter: this.rowFilter.bind(this, contentEntry.id),
|
||||
isSelectionValid: this.isCopyMoveSelectionValid.bind(this),
|
||||
excludeSiteContent: excludeSiteContent || ContentNodeDialogService.nonDocumentSiteContent,
|
||||
select: select
|
||||
};
|
||||
|
||||
|
@@ -107,6 +107,21 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
|
||||
component.chosenNode = expectedNode;
|
||||
});
|
||||
|
||||
it('should be able to filter out the exclude site content', () => {
|
||||
component.excludeSiteContent = ['blog'];
|
||||
fixture.detectChanges();
|
||||
|
||||
const testSiteContent = new Node({id: 'blog-id', properties: { 'st:componentId': 'blog' }});
|
||||
expect(component.rowFilter(<any> {node: {entry: testSiteContent}}, null, null)).toBe(false);
|
||||
});
|
||||
|
||||
it('should NOT filter out any site content by default', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
const testSiteContent = new Node({id: 'blog-id', properties: { 'st:componentId': 'blog' }});
|
||||
expect(component.rowFilter(<any> {node: {entry: testSiteContent}}, null, null)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Breadcrumbs', () => {
|
||||
|
@@ -29,6 +29,7 @@ import { ContentNodeSelectorService } from './content-node-selector.service';
|
||||
import { debounceTime } from 'rxjs/operators';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { CustomResourcesService } from '../document-list/services/custom-resources.service';
|
||||
import { ShareDataRow } from '../document-list';
|
||||
|
||||
export type ValidationFunction = (entry: Node) => boolean;
|
||||
|
||||
@@ -68,6 +69,12 @@ export class ContentNodeSelectorPanelComponent implements OnInit, PaginatedCompo
|
||||
@Input()
|
||||
rowFilter: RowFilter = null;
|
||||
|
||||
/** Custom list of site content componentIds.
|
||||
* Used to filter out the corresponding items from the displayed nodes
|
||||
*/
|
||||
@Input()
|
||||
excludeSiteContent: string[] = [];
|
||||
|
||||
/** Custom image resolver function. See the
|
||||
* [Document List component](document-list.component.md#custom-row-filter)
|
||||
* for more information.
|
||||
@@ -159,6 +166,32 @@ export class ContentNodeSelectorPanelComponent implements OnInit, PaginatedCompo
|
||||
|
||||
this.breadcrumbTransform = this.breadcrumbTransform ? this.breadcrumbTransform : null;
|
||||
this.isSelectionValid = this.isSelectionValid ? this.isSelectionValid : defaultValidation;
|
||||
this.excludeSiteContent = this.excludeSiteContent ? this.excludeSiteContent : [];
|
||||
this.rowFilter = this.getRowFilter(this.rowFilter);
|
||||
}
|
||||
|
||||
private getRowFilter(initialFilterFunction): RowFilter {
|
||||
if (!initialFilterFunction) {
|
||||
initialFilterFunction = () => true;
|
||||
}
|
||||
return (value: ShareDataRow, index: number, array: ShareDataRow[]) => {
|
||||
return initialFilterFunction(value, index, array) &&
|
||||
!this.isExcludedSiteContent(value);
|
||||
};
|
||||
}
|
||||
|
||||
private isExcludedSiteContent(row: ShareDataRow): boolean {
|
||||
const entry = row.node.entry;
|
||||
if (this.excludeSiteContent.length &&
|
||||
entry &&
|
||||
entry.properties &&
|
||||
entry.properties['st:componentId']) {
|
||||
const excludedItem = this.excludeSiteContent.find(
|
||||
(id: string) => entry.properties['st:componentId'] === id
|
||||
);
|
||||
return !!excludedItem;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -28,5 +28,6 @@ export interface ContentNodeSelectorComponentData {
|
||||
imageResolver?: any;
|
||||
isSelectionValid?: (entry: Node) => boolean;
|
||||
breadcrumbTransform?: (node) => any;
|
||||
excludeSiteContent?: string[];
|
||||
select: Subject<Node[]>;
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@
|
||||
[imageResolver]="imageResolver || data?.imageResolver"
|
||||
[isSelectionValid]="data?.isSelectionValid"
|
||||
[breadcrumbTransform]="data?.breadcrumbTransform"
|
||||
[excludeSiteContent]="data?.excludeSiteContent"
|
||||
(select)="onSelect($event)">
|
||||
</adf-content-node-selector-panel>
|
||||
</mat-dialog-content>
|
||||
|
@@ -54,7 +54,7 @@ describe('ContentNodeSelectorDialogComponent', () => {
|
||||
const documentListService: DocumentListService = TestBed.get(DocumentListService);
|
||||
const sitesService: SitesService = TestBed.get(SitesService);
|
||||
spyOn(documentListService, 'getFolder').and.returnValue(of({ list: [] }));
|
||||
spyOn(documentListService, 'getFolderNode').and.returnValue(of({}));
|
||||
spyOn(documentListService, 'getFolderNode').and.returnValue(of({ entry: {} }));
|
||||
spyOn(sitesService, 'getSites').and.returnValue(of({ list: { entries: [] } }));
|
||||
|
||||
fixture = TestBed.createComponent(ContentNodeSelectorComponent);
|
||||
|
Reference in New Issue
Block a user