From b931c4a85c3904798c4d1d1838aea9ba2841dc10 Mon Sep 17 00:00:00 2001 From: Cilibiu Bogdan Date: Wed, 15 Jan 2020 11:51:57 +0200 Subject: [PATCH] [ADF-5062] Content Node Selector - show inputs based on configuration (#5368) * toggle search and dropdown list by configuration * update docs * tests * fix inputs setter * rename --- .../content-node-selector.component.md | 2 ++ ...content-node-selector-panel.component.html | 3 ++- ...tent-node-selector-panel.component.spec.ts | 26 ++++++++++++++++++ .../content-node-selector-panel.component.ts | 27 +++++++++++++++++++ ...-node-selector.component-data.interface.ts | 2 ++ .../content-node-selector.component.html | 2 ++ 6 files changed, 61 insertions(+), 1 deletion(-) diff --git a/docs/content-services/components/content-node-selector.component.md b/docs/content-services/components/content-node-selector.component.md index dd10959e43..d0afe95867 100644 --- a/docs/content-services/components/content-node-selector.component.md +++ b/docs/content-services/components/content-node-selector.component.md @@ -62,6 +62,8 @@ The properties are described in the table below: | isSelectionValid | [`ValidationFunction`](../../../lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts) | `defaultValidation` | Function used to decide if the selected node has permission to be selected. Default value is a function that always returns true. | | breadcrumbTransform | `(node: any) => any` | | Transformation to be performed on the chosen/folder node before building the breadcrumb UI. Can be useful when custom formatting is needed for the breadcrumb. You can change the path elements from the node that are used to build the breadcrumb using this function. | | select | [`Subject`](https://github.com/Alfresco/alfresco-js-api/blob/development/src/api/content-rest-api/docs/Node.md) | | Event emitted with the current node selection when the dialog closes | +| showSearch | `boolean` | `true` | Render search input | +| showDropdownSiteList | `boolean` | `true` | Render sites list dropdown menu | If you don't want to manage the dialog yourself then it is easier to use the [Content Node Selector Panel component](content-node-selector-panel.component.md), or the diff --git a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.html b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.html index 2cbefbe197..aa4879df31 100644 --- a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.html +++ b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.html @@ -1,5 +1,5 @@
- + { const testSiteContent = new Node({ id: 'blog-id', properties: { 'st:componentId': 'blog' } }); expect(component.rowFilter( { node: { entry: testSiteContent } }, null, null)).toBe(true); }); + + it('should render search input by default', () => { + fixture.detectChanges(); + expect(fixture.debugElement.nativeElement.querySelector('.adf-content-node-selector-content-input')) + .not.toBe(null); + }); + + it('should not render search input if `showSearch` is false', () => { + component.showSearch = false; + fixture.detectChanges(); + expect(fixture.debugElement.nativeElement.querySelector('.adf-content-node-selector-content-input')) + .toBe(null); + }); + + it('should render sites list dropdown by default', () => { + fixture.detectChanges(); + expect(fixture.debugElement.nativeElement.querySelector('adf-sites-dropdown')) + .not.toBe(null); + }); + + it('should not render sites list dropdown if `showDropdownSiteList` is false', () => { + component.showDropdownSiteList = false; + fixture.detectChanges(); + expect(fixture.debugElement.nativeElement.querySelector('adf-sites-dropdown')) + .toBe(null); + }); }); describe('Breadcrumbs', () => { diff --git a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts index c548752560..fd6f0547fb 100644 --- a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts +++ b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts @@ -54,6 +54,9 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy { hasMoreItems: false }); + private showSiteList = true; + private showSearchField = true; + /** Node ID of the folder currently listed. */ @Input() currentFolderId: string = null; @@ -136,6 +139,30 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy { @Input() breadcrumbTransform: (node) => any; + /** Toggle search input rendering */ + @Input() + set showSearch(value: boolean) { + if (value !== undefined && value !== null) { + this.showSearchField = value; + } + } + + get showSearch(): boolean { + return this.showSearchField; + } + + /** Toggle sites list dropdown rendering */ + @Input() + set showDropdownSiteList(value: boolean) { + if (value !== undefined && value !== null) { + this.showSiteList = value; + } + } + + get showDropdownSiteList(): boolean { + return this.showSiteList; + } + /** Emitted when the user has chosen an item. */ @Output() select: EventEmitter = new EventEmitter(); diff --git a/lib/content-services/src/lib/content-node-selector/content-node-selector.component-data.interface.ts b/lib/content-services/src/lib/content-node-selector/content-node-selector.component-data.interface.ts index e2bfb9af37..a3501f8610 100644 --- a/lib/content-services/src/lib/content-node-selector/content-node-selector.component-data.interface.ts +++ b/lib/content-services/src/lib/content-node-selector/content-node-selector.component-data.interface.ts @@ -31,4 +31,6 @@ export interface ContentNodeSelectorComponentData { breadcrumbTransform?: (node) => any; excludeSiteContent?: string[]; select: Subject; + showSearch?: boolean; + showDropdownSiteList?: boolean; } diff --git a/lib/content-services/src/lib/content-node-selector/content-node-selector.component.html b/lib/content-services/src/lib/content-node-selector/content-node-selector.component.html index eca2e082a0..9058be217c 100644 --- a/lib/content-services/src/lib/content-node-selector/content-node-selector.component.html +++ b/lib/content-services/src/lib/content-node-selector/content-node-selector.component.html @@ -15,6 +15,8 @@ [breadcrumbTransform]="data?.breadcrumbTransform" [excludeSiteContent]="data?.excludeSiteContent" [where]="data?.where" + [showSearch]="data?.showSearch" + [showDropdownSiteList]="data?.showDropdownSiteList" (select)="onSelect($event)">