mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
[ACA-4409] Resolved - More button is displayed on Destination Picker … (#7018)
* [ACA-4409] Resolved - More button is displayed on Destination Picker on a folder even if its files are not displayed * [ACA-4409] Updated param names * [ACA-4409] Refactored the changes * Removed fit and fdescribe * Resolved lint error
This commit is contained in:
parent
68db27bc91
commit
f3ada4ef85
@ -84,7 +84,7 @@
|
||||
sortingMode="server"
|
||||
[where]="where"
|
||||
(folderChange)="onFolderChange($event)"
|
||||
(ready)="onFolderLoaded()"
|
||||
(ready)="onFolderLoaded($event)"
|
||||
(nodeSelected)="onCurrentSelection($event)"
|
||||
data-automation-id="content-node-selector-document-list">
|
||||
|
||||
|
@ -18,8 +18,8 @@
|
||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Node, NodeEntry, NodePaging, RequestScope, ResultSetPaging, SiteEntry, SitePaging } from '@alfresco/js-api';
|
||||
import { AppConfigService, FileModel, FileUploadStatus, NodesApiService, setupTestBed, SitesService, UploadService, FileUploadCompleteEvent } from '@alfresco/adf-core';
|
||||
import { Node, NodeEntry, NodePaging, RequestScope, ResultSetPaging, SiteEntry, SitePaging, UserInfo } from '@alfresco/js-api';
|
||||
import { AppConfigService, FileModel, FileUploadStatus, NodesApiService, setupTestBed, SitesService, UploadService, FileUploadCompleteEvent, DataRow, ThumbnailService, ContentService, DataColumn } from '@alfresco/adf-core';
|
||||
import { of, throwError } from 'rxjs';
|
||||
import { DropdownBreadcrumbComponent } from '../breadcrumb';
|
||||
import { ContentNodeSelectorPanelComponent } from './content-node-selector-panel.component';
|
||||
@ -28,7 +28,7 @@ import { DocumentListService } from '../document-list/services/document-list.ser
|
||||
import { DocumentListComponent } from '../document-list/components/document-list.component';
|
||||
import { DropdownSitesComponent } from '../site-dropdown/sites-dropdown.component';
|
||||
import { CustomResourcesService } from '../document-list/services/custom-resources.service';
|
||||
import { NodeEntryEvent, ShareDataRow } from '../document-list';
|
||||
import { NodeEntryEvent, ShareDataRow, ShareDataTableAdapter } from '../document-list';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { SearchQueryBuilderService } from '../search';
|
||||
import { mockQueryBody } from '../mock/search-query.mock';
|
||||
@ -66,6 +66,8 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
let searchQueryBuilderService: SearchQueryBuilderService;
|
||||
let contentNodeSelectorPanelService: ContentNodeSelectorPanelService;
|
||||
let uploadService: UploadService;
|
||||
let thumbnailService: ThumbnailService;
|
||||
let contentService: ContentService;
|
||||
|
||||
function typeToSearchBox(searchTerm = 'string-to-search') {
|
||||
const searchInput = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-input"]'));
|
||||
@ -97,6 +99,9 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
sitesService = TestBed.inject(SitesService);
|
||||
contentNodeSelectorPanelService = TestBed.inject(ContentNodeSelectorPanelService);
|
||||
uploadService = TestBed.inject(UploadService);
|
||||
contentService = TestBed.inject(ContentService);
|
||||
thumbnailService = TestBed.inject(ThumbnailService);
|
||||
|
||||
searchQueryBuilderService = component.queryBuilderService;
|
||||
component.queryBuilderService.resetToDefaults();
|
||||
|
||||
@ -1016,25 +1021,78 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
describe('Chosen node', () => {
|
||||
|
||||
const entry: Node = <Node> { id: 'fakeid'};
|
||||
const nodePage: NodePaging = <NodePaging> { list: {}, pagination: {} };
|
||||
const nodePage: NodePaging = <NodePaging> { list: { pagination: {} } };
|
||||
let hasAllowableOperations;
|
||||
const fakeFolderNode = <Node> { id: 'fakeNodeId', isFolder: true };
|
||||
|
||||
function returnHasPermission(): boolean {
|
||||
return hasAllowableOperations;
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
const schema = [<DataColumn> {}];
|
||||
const rows = [<DataRow> {}, <DataRow> {}];
|
||||
component.documentList.data = new ShareDataTableAdapter(thumbnailService, contentService, schema);
|
||||
spyOn(component.documentList.data, 'getRows').and.returnValue(rows);
|
||||
spyOn(sitesService, 'getSites').and.returnValue(of({ list: { entries: [] } }));
|
||||
});
|
||||
|
||||
it('should the selection become the currently navigated folder when the folder loads (Acts as destination for cases like copy action)', () => {
|
||||
const fakeFolderNode = <Node> { id: 'fakeNodeId', isFolder: true };
|
||||
component.documentList.folderNode = fakeFolderNode;
|
||||
component.onFolderLoaded();
|
||||
component.onFolderLoaded(nodePage);
|
||||
|
||||
expect(component.chosenNode).toEqual([fakeFolderNode]);
|
||||
});
|
||||
|
||||
it('should update the pagination after filtering rows on copy and move action', () => {
|
||||
component.documentList.folderNode = fakeFolderNode;
|
||||
const fakeNodePage: NodePaging = {
|
||||
list: {
|
||||
pagination: {
|
||||
hasMoreItems: true,
|
||||
maxItems: 1,
|
||||
totalItems: 2
|
||||
},
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
id: '123',
|
||||
name: 'MyFolder',
|
||||
isFile: false,
|
||||
isFolder: true,
|
||||
nodeType: 'mock',
|
||||
modifiedAt: new Date(),
|
||||
modifiedByUser: new UserInfo(),
|
||||
createdAt: new Date(),
|
||||
createdByUser: new UserInfo()
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
id: '456',
|
||||
name: 'MyFolder2',
|
||||
isFile: false,
|
||||
isFolder: true,
|
||||
nodeType: 'mock',
|
||||
modifiedAt: new Date(),
|
||||
modifiedByUser: new UserInfo(),
|
||||
createdAt: new Date(),
|
||||
createdByUser: new UserInfo()
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
component.documentList.ready.emit(fakeNodePage);
|
||||
component.onFolderLoaded(fakeNodePage);
|
||||
|
||||
expect(fakeNodePage.list.pagination.hasMoreItems).toBe(true);
|
||||
fakeNodePage.list.pagination.maxItems = 25;
|
||||
component.onFolderLoaded(fakeNodePage);
|
||||
|
||||
expect(fakeNodePage.list.pagination.hasMoreItems).toBe(false);
|
||||
});
|
||||
|
||||
describe('in the case when isSelectionValid is a custom function for checking permissions,', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -563,13 +563,23 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
||||
/**
|
||||
* Attempts to set the currently loaded node
|
||||
*/
|
||||
onFolderLoaded(): void {
|
||||
onFolderLoaded(nodePaging: NodePaging): void {
|
||||
this.updatePaginationAfterRowFilter(nodePaging);
|
||||
if (!this.showingSearchResults) {
|
||||
this.attemptNodeSelection(this.documentList.folderNode);
|
||||
}
|
||||
this.folderLoaded.emit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates pagination.hasMoreItems to false after filtering only folders during 'COPY' and 'MOVE' action
|
||||
*/
|
||||
updatePaginationAfterRowFilter(nodePaging: NodePaging): void {
|
||||
if (this.documentList.data.getRows().length < nodePaging.list.pagination.maxItems) {
|
||||
nodePaging.list.pagination.hasMoreItems = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether breadcrumb has to be shown or not
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user