Skip to content

Commit

Permalink
Hide document list private api (#8735)
Browse files Browse the repository at this point in the history
* hide private document list api

* hide private datatable api
  • Loading branch information
DenysVuika committed Jul 4, 2023
1 parent 0ffbf9f commit 4452007
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ describe('DocumentList', () => {
});

it('should not reset the selection when preselectNodes input changes', () => {
const resetSelectionSpy = spyOn(documentList, 'resetSelection').and.callThrough();
documentList.selection = [{ entry: mockNode3 }];
const changes: SimpleChanges = {
preselectNodes: {
Expand All @@ -261,12 +260,10 @@ describe('DocumentList', () => {
};
documentList.ngOnChanges(changes);

expect(resetSelectionSpy).not.toHaveBeenCalled();
expect(documentList.selection).toEqual([{ entry: mockNode3 }]);
});

it('should reset the selection for every change other than preselectNodes', () => {
const resetSelectionSpy = spyOn(documentList, 'resetSelection').and.callThrough();
documentList.selection = [{ entry: mockNode3 }];
const changes: SimpleChanges = {
mockChange: {
Expand All @@ -280,7 +277,6 @@ describe('DocumentList', () => {
};
documentList.ngOnChanges(changes);

expect(resetSelectionSpy).toHaveBeenCalled();
expect(documentList.selection).toEqual([]);
});

Expand Down Expand Up @@ -1714,12 +1710,10 @@ describe('DocumentList', () => {
fakeDatatableRows[1].isSelected = false;
documentList.data.setRows(fakeDatatableRows);

const getSelectionFromAdapterSpy = spyOn(documentList.data, 'getSelectedRows').and.callThrough();
documentList.selectionMode = 'multiple';
documentList.preselectedRows = fakeDatatableRows;
const selection = documentList.getSelectionBasedOnSelectionMode();

expect(getSelectionFromAdapterSpy).toHaveBeenCalled();
expect(selection.length).toEqual(1);
expect(selection[0]).toEqual(fakeDatatableRows[0]);
});
Expand Down Expand Up @@ -1754,7 +1748,6 @@ describe('DocumentList', () => {
const datatableSelectRowSpy = spyOn(documentList.dataTable, 'selectRow');
const getRowByNodeIdSpy = spyOn(documentList.data, 'getRowByNodeId').and.callThrough();
const onNodeUnselectSpy = spyOn(documentList, 'onNodeUnselect');
const getSelectionSpy = spyOn(documentList, 'getSelectionBasedOnSelectionMode').and.callThrough();

const fakeDatatableRows = [new ShareDataRow(mockPreselectedNodes[0], contentService, null), new ShareDataRow(mockPreselectedNodes[1], contentService, null)];
fakeDatatableRows[0].isSelected = true;
Expand All @@ -1767,15 +1760,13 @@ describe('DocumentList', () => {
selection = documentList.data.getSelectedRows() as ShareDataRow[];

expect(selection).toEqual([]);
expect(getSelectionSpy).toHaveBeenCalled();
expect(getRowByNodeIdSpy).toHaveBeenCalledWith(mockPreselectedNodes[0].entry.id);
expect(datatableSelectRowSpy).toHaveBeenCalledWith(fakeDatatableRows[0], false);
expect(onNodeUnselectSpy).toHaveBeenCalledWith({ row: undefined, selection });
});

it('should preselect the rows of the preselected nodes', () => {
const getRowByNodeIdSpy = spyOn(documentList.data, 'getRowByNodeId').and.callThrough();
const getPreselectedNodesSpy = spyOn(documentList, 'getPreselectedNodesBasedOnSelectionMode').and.callThrough();

const fakeDatatableRows = [new ShareDataRow(mockPreselectedNodes[0], contentService, null), new ShareDataRow(mockPreselectedNodes[1], contentService, null)];
documentList.data.setRows(fakeDatatableRows);
Expand All @@ -1786,7 +1777,6 @@ describe('DocumentList', () => {
documentList.preselectRowsOfPreselectedNodes();
const selectedRows = documentList.data.getSelectedRows();

expect(getPreselectedNodesSpy).toHaveBeenCalled();
expect(selectedRows.length).toEqual(2);
expect(selectedRows[0].isSelected).toEqual(true);
expect(selectedRows[1].isSelected).toEqual(true);
Expand All @@ -1799,9 +1789,6 @@ describe('DocumentList', () => {
});

it('should select the rows of the preselected nodes and emit the new combined selection', () => {
const hasPreselectedNodesSpy = spyOn(documentList, 'hasPreselectedNodes').and.callThrough();
const preselectRowsOfPreselectedNodesSpy = spyOn(documentList, 'preselectRowsOfPreselectedNodes').and.callThrough();
const getPreselectedRowsBasedOnSelectionModeSpy = spyOn(documentList, 'getPreselectedRowsBasedOnSelectionMode').and.callThrough();
const onNodeSelectSpy = spyOn(documentList, 'onNodeSelect').and.callThrough();

const fakeDatatableRows = [
Expand All @@ -1818,9 +1805,6 @@ describe('DocumentList', () => {
documentList.onPreselectNodes();
const selection = documentList.data.getSelectedRows() as ShareDataRow[];

expect(hasPreselectedNodesSpy).toHaveBeenCalled();
expect(preselectRowsOfPreselectedNodesSpy).toHaveBeenCalled();
expect(getPreselectedRowsBasedOnSelectionModeSpy).toHaveBeenCalled();
expect(selection.length).toEqual(3);
expect(selection[0].id).toEqual(mockNode1.id);
expect(selection[1].id).toEqual(mockNode2.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,38 +298,38 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte

/** Emitted when the user clicks a list node */
@Output()
nodeClick: EventEmitter<NodeEntityEvent> = new EventEmitter<NodeEntityEvent>();
nodeClick = new EventEmitter<NodeEntityEvent>();

/** Emitted when the user double-clicks a list node */
@Output()
nodeDblClick: EventEmitter<NodeEntityEvent> = new EventEmitter<NodeEntityEvent>();
nodeDblClick = new EventEmitter<NodeEntityEvent>();

/** Emitted when the current display folder changes */
@Output()
folderChange: EventEmitter<NodeEntryEvent> = new EventEmitter<NodeEntryEvent>();
folderChange = new EventEmitter<NodeEntryEvent>();

/** Emitted when the user acts upon files with either single or double click
* (depends on `navigation-mode`). Useful for integration with the
* Viewer component.
*/
@Output()
preview: EventEmitter<NodeEntityEvent> = new EventEmitter<NodeEntityEvent>();
preview = new EventEmitter<NodeEntityEvent>();

/** Emitted when the Document List has loaded all items and is ready for use */
@Output()
ready: EventEmitter<NodePaging> = new EventEmitter();
ready = new EventEmitter<NodePaging>();

/** Emitted when the API fails to get the Document List data */
@Output()
error: EventEmitter<any> = new EventEmitter();
error = new EventEmitter<any>();

/** Emitted when the node selection change */
@Output()
nodeSelected: EventEmitter<NodeEntry[]> = new EventEmitter<NodeEntry[]>();
nodeSelected = new EventEmitter<NodeEntry[]>();

/** Emitted when a filter value is selected */
@Output()
filterSelection: EventEmitter<FilterSearch[]> = new EventEmitter();
filterSelection = new EventEmitter<FilterSearch[]>();

@ViewChild('dataTable', { static: true })
dataTable: DataTableComponent;
Expand All @@ -356,7 +356,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
private loadingTimeout;
private onDestroy$ = new Subject<boolean>();

_nodesApi: NodesApi;
private _nodesApi: NodesApi;
get nodesApi(): NodesApi {
this._nodesApi = this._nodesApi ?? new NodesApi(this.alfrescoApiService.getInstance());
return this._nodesApi;
Expand Down Expand Up @@ -400,7 +400,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
return null;
}

get hasCustomLayout(): boolean {
private get hasCustomLayout(): boolean {
return this.columnList && this.columnList.columns && this.columnList.columns.length > 0;
}

Expand Down Expand Up @@ -653,7 +653,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
node.properties['cm:destination'];
}

updateCustomSourceData(nodeId: string): void {
private updateCustomSourceData(nodeId: string): void {
this.currentFolderId = nodeId;
}

Expand Down Expand Up @@ -754,7 +754,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
/**
* Creates a set of predefined columns.
*/
setupDefaultColumns(preset: string = 'default'): void {
private setupDefaultColumns(preset: string = 'default'): void {
if (this.data) {
const columns = this.getLayoutPreset(preset);
this.data.setColumns(columns);
Expand Down Expand Up @@ -938,7 +938,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
this.filterSelection.emit(activeFilters);
}

resetNewFolderPagination() {
private resetNewFolderPagination() {
this._pagination.skipCount = 0;
this._pagination.maxItems = this.maxItems;
}
Expand Down Expand Up @@ -986,7 +986,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
}
}

preserveExistingSelection() {
private preserveExistingSelection() {
if (this.isMultipleSelectionMode()) {
for (const selection of this.selection) {
const rowOfSelection = this.data.getRowByNodeId(selection.entry.id);
Expand Down Expand Up @@ -1020,19 +1020,19 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
}
}

isSingleSelectionMode(): boolean {
private isSingleSelectionMode(): boolean {
return this.selectionMode === 'single';
}

isMultipleSelectionMode(): boolean {
private isMultipleSelectionMode(): boolean {
return this.selectionMode === 'multiple';
}

hasPreselectedNodes(): boolean {
private hasPreselectedNodes(): boolean {
return this.preselectNodes?.length > 0;
}

hasPreselectedRows(): boolean {
private hasPreselectedRows(): boolean {
return this.preselectedRows?.length > 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ export class DataTableComponent implements OnInit, AfterContentInit, OnChanges,
}
}

datatableLayoutFix() {
private datatableLayoutFix() {
const maxGalleryRows = 25;

if (this.display === 'gallery') {
Expand Down

0 comments on commit 4452007

Please sign in to comment.