From cd4fb8d06d31c29fff9bd756ad9af9387b66aa8b Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Mon, 11 Feb 2019 11:14:05 +0000 Subject: [PATCH] [ADF-4056][ADF-4060][ADF-3930] Content Node Selector fix (#4293) * remove target when search * content panel component infinite pagiantion and dropdown integration * fix insight karma --- ...content-node-selector-panel.component.html | 3 +- ...content-node-selector-panel.component.scss | 1 + ...tent-node-selector-panel.component.spec.ts | 51 ++++++++++++++++++ .../content-node-selector-panel.component.ts | 13 +++-- lib/content-services/karma.conf.js | 6 ++- lib/core/karma.conf.js | 1 - .../infinite-pagination.component.html | 1 + .../infinite-pagination.component.spec.ts | 20 +++---- .../infinite-pagination.component.ts | 53 ++++++++++++------- lib/insights/karma.conf.js | 1 - lib/process-services/karma.conf.js | 1 - 11 files changed, 116 insertions(+), 35 deletions(-) diff --git a/lib/content-services/content-node-selector/content-node-selector-panel.component.html b/lib/content-services/content-node-selector/content-node-selector-panel.component.html index 2d618aa486..3b8d8f4733 100644 --- a/lib/content-services/content-node-selector/content-node-selector-panel.component.html +++ b/lib/content-services/content-node-selector/content-node-selector-panel.component.html @@ -65,6 +65,7 @@ [contextMenuActions]="false" [contentActions]="false" [allowDropFiles]="false" + [sorting]="'server'" [where]="where" (folderChange)="onFolderChange()" (ready)="onFolderLoaded()" @@ -89,7 +90,7 @@ diff --git a/lib/content-services/content-node-selector/content-node-selector-panel.component.scss b/lib/content-services/content-node-selector/content-node-selector-panel.component.scss index 95d4c656f5..274c0a8ea9 100644 --- a/lib/content-services/content-node-selector/content-node-selector-panel.component.scss +++ b/lib/content-services/content-node-selector/content-node-selector-panel.component.scss @@ -84,6 +84,7 @@ height: 200px; overflow: auto; border: 1px solid mat-color($foreground, base, 0.07); + padding: 1px; .adf-highlight { color: mat-color($primary); diff --git a/lib/content-services/content-node-selector/content-node-selector-panel.component.spec.ts b/lib/content-services/content-node-selector/content-node-selector-panel.component.spec.ts index 41ad440962..e0be62b50e 100644 --- a/lib/content-services/content-node-selector/content-node-selector-panel.component.spec.ts +++ b/lib/content-services/content-node-selector/content-node-selector-panel.component.spec.ts @@ -116,6 +116,10 @@ describe('ContentNodeSelectorComponent', () => { fixture.detectChanges(); }); + it('should the document list use the server ordering', () => { + expect(component.documentList.sorting).toBe('server'); + }); + it('should trigger the select event when selection has been made', (done) => { const expectedNode = {}; component.select.subscribe((nodes) => { @@ -350,6 +354,13 @@ describe('ContentNodeSelectorComponent', () => { const expectedDefaultFolderNode = { entry: { path: { elements: [] } } }; spyOn(documentListService, 'getFolderNode').and.returnValue(of(expectedDefaultFolderNode)); + spyOn(documentListService, 'getFolder').and.returnValue(of({ + list: { + pagination: {}, + entries: [], + source: {} + } + })); const sitesService = TestBed.get(SitesService); spyOn(sitesService, 'getSites').and.returnValue(of({ list: { entries: [] } })); @@ -364,6 +375,8 @@ describe('ContentNodeSelectorComponent', () => { }); component.currentFolderId = 'cat-girl-nuku-nuku'; + component.documentList.ngOnInit(); + fixture.detectChanges(); }); @@ -775,6 +788,44 @@ describe('ContentNodeSelectorComponent', () => { const paginationLoading = fixture.debugElement.query(spinnerSelector); expect(paginationLoading).not.toBeNull(); })); + + it('Should infinite pagination target be null when we use it for search ', fakeAsync(() => { + component.showingSearchResults = true; + + typeToSearchBox('shenron'); + + tick(debounceSearch); + + fixture.detectChanges(); + + tick(debounceSearch); + + expect(component.target).toBeNull(); + })); + + it('Should infinite pagination target be present when search finish', fakeAsync(() => { + component.showingSearchResults = true; + + typeToSearchBox('shenron'); + + tick(debounceSearch); + + fixture.detectChanges(); + + typeToSearchBox(''); + + tick(debounceSearch); + + fixture.detectChanges(); + + expect(component.target).not.toBeNull(); + })); + + it('Should infinite pagination target on init be the document list', fakeAsync(() => { + component.showingSearchResults = true; + + expect(component.target).toEqual(component.documentList); + })); }); }); diff --git a/lib/content-services/content-node-selector/content-node-selector-panel.component.ts b/lib/content-services/content-node-selector/content-node-selector-panel.component.ts index 5ea1408007..fc8326e684 100644 --- a/lib/content-services/content-node-selector/content-node-selector-panel.component.ts +++ b/lib/content-services/content-node-selector/content-node-selector-panel.component.ts @@ -21,7 +21,7 @@ import { UserPreferencesService, PaginationModel, UserPreferenceValues, - InfinitePaginationComponent + InfinitePaginationComponent, PaginatedComponent } from '@alfresco/adf-core'; import { FormControl } from '@angular/forms'; import { Node, NodePaging, Pagination, SiteEntry, SitePaging } from '@alfresco/js-api'; @@ -163,6 +163,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit { debounceSearch: number = 200; searchInput: FormControl = new FormControl(); + target: PaginatedComponent; + constructor(private contentNodeSelectorService: ContentNodeSelectorService, private customResourcesService: CustomResourcesService, private userPreferencesService: UserPreferencesService) { @@ -194,6 +196,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit { } ngOnInit() { + this.target = this.documentList; this.folderIdToShow = this.currentFolderId; this.breadcrumbTransform = this.breadcrumbTransform ? this.breadcrumbTransform : null; @@ -232,6 +235,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit { siteChanged(chosenSite: SiteEntry): void { this.siteId = chosenSite.entry.guid; this.updateResults(); + } /** @@ -274,7 +278,6 @@ export class ContentNodeSelectorPanelComponent implements OnInit { this.searchTerm = ''; this.nodePaging = null; this.pagination.maxItems = this.pageSize; - this.infinitePaginationComponent.reset(); this.chosenNode = null; this.showingSearchResults = false; } @@ -283,6 +286,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit { * Update the result list depending on the criteria */ private updateResults(): void { + this.target = this.searchTerm.length > 0 ? null : this.documentList; + if (this.searchTerm.length === 0) { this.clear(); } else { @@ -296,7 +301,9 @@ export class ContentNodeSelectorPanelComponent implements OnInit { private startNewSearch(): void { this.nodePaging = null; this.pagination.maxItems = this.pageSize; - this.infinitePaginationComponent.reset(); + if (this.target) { + this.infinitePaginationComponent.reset(); + } this.chosenNode = null; this.folderIdToShow = null; this.querySearch(); diff --git a/lib/content-services/karma.conf.js b/lib/content-services/karma.conf.js index 4b5465ea05..27ed3a197b 100644 --- a/lib/content-services/karma.conf.js +++ b/lib/content-services/karma.conf.js @@ -22,10 +22,13 @@ module.exports = function (config) { watched: false }, - {pattern: 'node_modules/alfresco-js-api/dist/alfresco-js-api.min.js', included: true, watched: false}, {pattern: 'node_modules/moment/min/moment.min.js', included: true, watched: false}, + {pattern: 'node_modules/pdfjs-dist/build/pdf.worker.js.map', included: false, served: true, watched: false}, + {pattern: 'node_modules/pdfjs-dist/build/pdf.js.map', included: false, served: true, watched: false}, + {pattern: 'node_modules/pdfjs-dist/web/pdf_viewer.js.map', included: false, served: true, watched: false}, {pattern: 'lib/content-services/i18n/**/en.json', included: false, served: true, watched: false}, + {pattern: 'lib/core/assets/images/ft_ic_folder.svg', included: false, served: true, watched: false}, {pattern: 'lib/core/i18n/**/en.json', included: false, served: true, watched: false}, {pattern: 'lib/content-services/**/*.ts', included: false, served: true, watched: false}, {pattern: 'lib/config/app.config.json', included: false, served: true, watched: false}, @@ -35,6 +38,7 @@ module.exports = function (config) { proxies: { '/base/assets/': '/base/lib/content-services/assets/', + '/base/lib/content-services/assets/images/ft_ic_folder.svg': '/base/lib/core/assets/images/ft_ic_folder.svg', '/assets/': '/base/lib/content-services/assets/', '/assets/adf-content-services/i18n/en.json': '/base/lib/content-services/i18n/en.json', '/assets/adf-core/i18n/en.json': '/base/lib/core/i18n/en.json', diff --git a/lib/core/karma.conf.js b/lib/core/karma.conf.js index b6f6ae98d9..882b679916 100644 --- a/lib/core/karma.conf.js +++ b/lib/core/karma.conf.js @@ -23,7 +23,6 @@ module.exports = function (config) { watched: false }, - {pattern: 'node_modules/alfresco-js-api/dist/alfresco-js-api.min.js', included: true, watched: false}, {pattern: 'node_modules/moment/min/moment.min.js', included: true, watched: false}, {pattern: 'lib/core/i18n/**/en.json', included: false, served: true, watched: false}, diff --git a/lib/core/pagination/infinite-pagination.component.html b/lib/core/pagination/infinite-pagination.component.html index 26d4069c92..8cff374c12 100644 --- a/lib/core/pagination/infinite-pagination.component.html +++ b/lib/core/pagination/infinite-pagination.component.html @@ -1,4 +1,5 @@
+