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 aee1d180b2..3db0bcd541 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 @@ -21,9 +21,6 @@ - - - - + +
+ + +
@@ -105,4 +112,6 @@ {{ 'ADF-DOCUMENT-LIST.LAYOUT.LOAD_MORE' | translate }}
+
+ diff --git a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.scss b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.scss index f4059df8be..0b0cd9f043 100644 --- a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.scss +++ b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.scss @@ -16,6 +16,14 @@ .adf-content-node-selector { + &-search-panel-container { + display: flex; + } + + &-document-list-container { + width: 100%; + } + &-content { padding-top: 0; @@ -86,7 +94,7 @@ } &-list { - height: 200px; + height: 300px; overflow: auto; border: 1px solid mat-color($foreground, base, 0.07); border-top: 0; diff --git a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.spec.ts b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.spec.ts index 11843d181b..0ecc9c3bfb 100644 --- a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.spec.ts +++ b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.spec.ts @@ -32,6 +32,8 @@ import { NodeEntryEvent, ShareDataRow } from '../document-list'; import { TranslateModule } from '@ngx-translate/core'; import { SearchQueryBuilderService } from '../search'; import { mockQueryBody } from '../mock/search-query.mock'; +import { ContentNodeSelectorPanelService } from './content-node-selector-panel.service'; +import { mockContentModelProperty } from '../mock/content-model.mock'; const fakeResultSetPaging: ResultSetPaging = { list: { @@ -62,6 +64,7 @@ describe('ContentNodeSelectorPanelComponent', () => { const fakeNodeEntry = new Node({ id: 'fakeId' }); const nodeEntryEvent = new NodeEntryEvent(fakeNodeEntry); let searchQueryBuilderService: SearchQueryBuilderService; + let contentNodeSelectorPanelService: ContentNodeSelectorPanelService; function typeToSearchBox(searchTerm = 'string-to-search') { const searchInput = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-input"]')); @@ -91,6 +94,7 @@ describe('ContentNodeSelectorPanelComponent', () => { nodeService = TestBed.inject(NodesApiService); sitesService = TestBed.inject(SitesService); + contentNodeSelectorPanelService = TestBed.inject(ContentNodeSelectorPanelService); searchQueryBuilderService = component.queryBuilderService; spyOn(nodeService, 'getNode').and.returnValue(of({ id: 'fake-node', path: { elements: [{ nodeType: 'st:site', name: 'fake-site'}] } })); @@ -1167,5 +1171,53 @@ describe('ContentNodeSelectorPanelComponent', () => { }); }); + + describe('Search panel', () => { + + beforeEach(() => { + contentNodeSelectorPanelService.customModels = undefined; + }); + + it ('should search panel be collapsed by default and expand when clicking the filter button', async() => { + contentNodeSelectorPanelService.customModels = [mockContentModelProperty]; + fixture.detectChanges(); + + expect(component.searchPanelExpanded).toEqual(false); + + const toggleFiltersPanelButton = fixture.debugElement.query(By.css('[data-automation-id="adf-toggle-search-panel-button"]')); + toggleFiltersPanelButton.nativeElement.click(); + + fixture.detectChanges(); + await fixture.whenStable(); + + expect(component.searchPanelExpanded).toEqual(true); + }); + + it ('should search panel be present when the filter section is expanded', () => { + component.searchPanelExpanded = true; + fixture.detectChanges(); + + const searchPanelContainer = fixture.debugElement.query(By.css('[data-automation-id="adf-search-panel-container"]')); + + expect(searchPanelContainer).not.toBe(null); + }); + + it('should filter button be present only when there are custom models', () => { + contentNodeSelectorPanelService.customModels = [mockContentModelProperty]; + fixture.detectChanges(); + + const toggleFiltersPanelButton = fixture.debugElement.query(By.css('[data-automation-id="adf-toggle-search-panel-button"]')); + + expect(toggleFiltersPanelButton).not.toEqual(null); + }); + + it('should filter button not be present when there are no custom models', () => { + fixture.detectChanges(); + + const toggleFiltersPanelButton = fixture.debugElement.query(By.css('[data-automation-id="adf-toggle-search-panel-button"]')); + + expect(toggleFiltersPanelButton).toEqual(null); + }); + }); }); }); 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 03e970666f..909f6e00bf 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 @@ -47,6 +47,7 @@ import { NodeEntryEvent, ShareDataRow } from '../document-list'; import { Subject } from 'rxjs'; import { SEARCH_QUERY_SERVICE_TOKEN } from '../search/search-query-service.token'; import { SearchQueryBuilderService } from '../search/search-query-builder.service'; +import { ContentNodeSelectorPanelService } from './content-node-selector-panel.service'; export type ValidationFunction = (entry: Node) => boolean; @@ -240,6 +241,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy { target: PaginatedComponent; preselectNodes: NodeEntry[] = []; + searchPanelExpanded: boolean = false; + private onDestroy$ = new Subject(); constructor(private customResourcesService: CustomResourcesService, @@ -247,7 +250,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy { private userPreferencesService: UserPreferencesService, private nodesApiService: NodesApiService, private uploadService: UploadService, - private sitesService: SitesService) { + private sitesService: SitesService, + private contentNodeSelectorPanelService: ContentNodeSelectorPanelService) { } set chosenNode(value: Node[]) { @@ -317,6 +321,14 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy { this.onDestroy$.complete(); } + toggleSearchPanel() { + this.searchPanelExpanded = !this.searchPanelExpanded; + } + + hasCustomModels(): boolean { + return this.contentNodeSelectorPanelService?.customModels?.length > 0; + } + private onFileUploadEvent() { this.uploadService.fileUploadComplete .pipe( diff --git a/lib/content-services/src/lib/mock/content-model.mock.ts b/lib/content-services/src/lib/mock/content-model.mock.ts new file mode 100644 index 0000000000..6ad3586380 --- /dev/null +++ b/lib/content-services/src/lib/mock/content-model.mock.ts @@ -0,0 +1,32 @@ +/*! + * @license + * Copyright 2019 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const mockContentModelProperty = { + name: 'name', + prefixedName: 'account:name', + title: 'name', + description: '', + dataType: 'd:text', + multiValued: false, + mandatory: false, + defaultValue: '', + mandatoryEnforced: false, + indexed: false, + facetable: 'FALSE', + indexTokenisationMode: '', + constraints: [] +}; diff --git a/lib/content-services/src/lib/search/components/search-panel/search-panel.component.html b/lib/content-services/src/lib/search/components/search-panel/search-panel.component.html index 34bd845192..33e1ebb6d2 100644 --- a/lib/content-services/src/lib/search/components/search-panel/search-panel.component.html +++ b/lib/content-services/src/lib/search/components/search-panel/search-panel.component.html @@ -1,5 +1,5 @@ -
- + diff --git a/lib/content-services/src/lib/search/components/search-panel/search-panel.component.scss b/lib/content-services/src/lib/search/components/search-panel/search-panel.component.scss index 291d0a645c..d390ee94b7 100644 --- a/lib/content-services/src/lib/search/components/search-panel/search-panel.component.scss +++ b/lib/content-services/src/lib/search/components/search-panel/search-panel.component.scss @@ -1,4 +1,4 @@ .adf-search-panel-scrollable { - overflow: scroll; - max-height: 200px; + overflow: scroll; + max-height: 300px; } diff --git a/lib/content-services/src/lib/search/components/search-panel/search-panel.component.ts b/lib/content-services/src/lib/search/components/search-panel/search-panel.component.ts index 293d041d49..bd99f3ab43 100644 --- a/lib/content-services/src/lib/search/components/search-panel/search-panel.component.ts +++ b/lib/content-services/src/lib/search/components/search-panel/search-panel.component.ts @@ -30,11 +30,15 @@ import { SEARCH_QUERY_SERVICE_TOKEN } from '../../search-query-service.token'; }) export class SearchPanelComponent implements OnInit { - constructor(public contentNodeSelectorSearchPanelService: ContentNodeSelectorPanelService, + constructor(private contentNodeSelectorPanelService: ContentNodeSelectorPanelService, @Inject(SEARCH_QUERY_SERVICE_TOKEN) private queryBuilderService: SearchQueryBuilderService) { } ngOnInit(): void { - this.queryBuilderService.categories = this.contentNodeSelectorSearchPanelService.convertCustomModelPropertiesToSearchCategories(); + this.queryBuilderService.categories = this.contentNodeSelectorPanelService.convertCustomModelPropertiesToSearchCategories(); + } + + hasCustomModels(): boolean { + return this.contentNodeSelectorPanelService?.customModels?.length > 0; } } diff --git a/lib/process-services-cloud/src/lib/form/services/content-cloud-node-selector.service.ts b/lib/process-services-cloud/src/lib/form/services/content-cloud-node-selector.service.ts index 666984a7bd..a4a2cdfac0 100644 --- a/lib/process-services-cloud/src/lib/form/services/content-cloud-node-selector.service.ts +++ b/lib/process-services-cloud/src/lib/form/services/content-cloud-node-selector.service.ts @@ -49,7 +49,7 @@ export class ContentCloudNodeSelectorService { showDropdownSiteList: false, showLocalUploadButton: isAllFileSources }; - this.openContentNodeDialog(data, 'adf-content-node-selector-dialog', '630px'); + this.openContentNodeDialog(data, 'adf-content-node-selector-dialog', '66%'); return select; }