[ADF-3854] destination picker - exclude site content after rowFilter reset (#4158)

* [ADF-3854] exclude set site content after rowFilter reset

* [ADF-3854] fix duplicated call

* [ADF-3854] add test

* fix unrelated failing test

* improve type definition
add set get filtering node selector

* remove comma

* [ADF-3854] demo-shell - case when rowFilter is not set for adf-content-node-selector-panel
This commit is contained in:
Suzana Dirla
2019-02-04 14:10:52 +02:00
committed by Eugenio Romano
parent cf922dd46e
commit 08cdb2f7c3
5 changed files with 120 additions and 18 deletions

View File

@@ -60,18 +60,35 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
@Input()
dropdownSiteList: SitePaging = null;
_rowFilter: RowFilter = defaultValidation;
/** Custom row filter function. See the
* [Document List component](document-list.component.md#custom-row-filter)
* for more information.
*/
@Input()
rowFilter: RowFilter = null;
set rowFilter(rowFilter: RowFilter) {
this.createRowFilter(rowFilter);
}
get rowFilter(): RowFilter {
return this._rowFilter;
}
_excludeSiteContent: string[] = [];
/** Custom list of site content componentIds.
* Used to filter out the corresponding items from the displayed nodes
*/
@Input()
excludeSiteContent: string[] = [];
set excludeSiteContent(excludeSiteContent: string[]) {
this._excludeSiteContent = excludeSiteContent;
this.createRowFilter(this._rowFilter);
}
get excludeSiteContent(): string[] {
return this._excludeSiteContent;
}
/** Custom image resolver function. See the
* [Document List component](document-list.component.md#custom-row-filter)
@@ -164,27 +181,25 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
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;
private createRowFilter(filter?: RowFilter) {
if (!filter) {
filter = () => true;
}
return (value: ShareDataRow, index: number, array: ShareDataRow[]) => {
return initialFilterFunction(value, index, array) &&
this._rowFilter = (value: ShareDataRow, index: number, array: ShareDataRow[]) => {
return filter(value, index, array) &&
!this.isExcludedSiteContent(value);
};
}
private isExcludedSiteContent(row: ShareDataRow): boolean {
const entry = row.node.entry;
if (this.excludeSiteContent.length &&
if (this._excludeSiteContent.length &&
entry &&
entry.properties &&
entry.properties['st:componentId']) {
const excludedItem = this.excludeSiteContent.find(
const excludedItem = this._excludeSiteContent.find(
(id: string) => entry.properties['st:componentId'] === id
);
return !!excludedItem;