mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Hide document list private api (#8735)
* hide private document list api * hide private datatable api
This commit is contained in:
@@ -247,7 +247,6 @@ describe('DocumentList', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not reset the selection when preselectNodes input changes', () => {
|
it('should not reset the selection when preselectNodes input changes', () => {
|
||||||
const resetSelectionSpy = spyOn(documentList, 'resetSelection').and.callThrough();
|
|
||||||
documentList.selection = [{ entry: mockNode3 }];
|
documentList.selection = [{ entry: mockNode3 }];
|
||||||
const changes: SimpleChanges = {
|
const changes: SimpleChanges = {
|
||||||
preselectNodes: {
|
preselectNodes: {
|
||||||
@@ -261,12 +260,10 @@ describe('DocumentList', () => {
|
|||||||
};
|
};
|
||||||
documentList.ngOnChanges(changes);
|
documentList.ngOnChanges(changes);
|
||||||
|
|
||||||
expect(resetSelectionSpy).not.toHaveBeenCalled();
|
|
||||||
expect(documentList.selection).toEqual([{ entry: mockNode3 }]);
|
expect(documentList.selection).toEqual([{ entry: mockNode3 }]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reset the selection for every change other than preselectNodes', () => {
|
it('should reset the selection for every change other than preselectNodes', () => {
|
||||||
const resetSelectionSpy = spyOn(documentList, 'resetSelection').and.callThrough();
|
|
||||||
documentList.selection = [{ entry: mockNode3 }];
|
documentList.selection = [{ entry: mockNode3 }];
|
||||||
const changes: SimpleChanges = {
|
const changes: SimpleChanges = {
|
||||||
mockChange: {
|
mockChange: {
|
||||||
@@ -280,7 +277,6 @@ describe('DocumentList', () => {
|
|||||||
};
|
};
|
||||||
documentList.ngOnChanges(changes);
|
documentList.ngOnChanges(changes);
|
||||||
|
|
||||||
expect(resetSelectionSpy).toHaveBeenCalled();
|
|
||||||
expect(documentList.selection).toEqual([]);
|
expect(documentList.selection).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1714,12 +1710,10 @@ describe('DocumentList', () => {
|
|||||||
fakeDatatableRows[1].isSelected = false;
|
fakeDatatableRows[1].isSelected = false;
|
||||||
documentList.data.setRows(fakeDatatableRows);
|
documentList.data.setRows(fakeDatatableRows);
|
||||||
|
|
||||||
const getSelectionFromAdapterSpy = spyOn(documentList.data, 'getSelectedRows').and.callThrough();
|
|
||||||
documentList.selectionMode = 'multiple';
|
documentList.selectionMode = 'multiple';
|
||||||
documentList.preselectedRows = fakeDatatableRows;
|
documentList.preselectedRows = fakeDatatableRows;
|
||||||
const selection = documentList.getSelectionBasedOnSelectionMode();
|
const selection = documentList.getSelectionBasedOnSelectionMode();
|
||||||
|
|
||||||
expect(getSelectionFromAdapterSpy).toHaveBeenCalled();
|
|
||||||
expect(selection.length).toEqual(1);
|
expect(selection.length).toEqual(1);
|
||||||
expect(selection[0]).toEqual(fakeDatatableRows[0]);
|
expect(selection[0]).toEqual(fakeDatatableRows[0]);
|
||||||
});
|
});
|
||||||
@@ -1754,7 +1748,6 @@ describe('DocumentList', () => {
|
|||||||
const datatableSelectRowSpy = spyOn(documentList.dataTable, 'selectRow');
|
const datatableSelectRowSpy = spyOn(documentList.dataTable, 'selectRow');
|
||||||
const getRowByNodeIdSpy = spyOn(documentList.data, 'getRowByNodeId').and.callThrough();
|
const getRowByNodeIdSpy = spyOn(documentList.data, 'getRowByNodeId').and.callThrough();
|
||||||
const onNodeUnselectSpy = spyOn(documentList, 'onNodeUnselect');
|
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)];
|
const fakeDatatableRows = [new ShareDataRow(mockPreselectedNodes[0], contentService, null), new ShareDataRow(mockPreselectedNodes[1], contentService, null)];
|
||||||
fakeDatatableRows[0].isSelected = true;
|
fakeDatatableRows[0].isSelected = true;
|
||||||
@@ -1767,7 +1760,6 @@ describe('DocumentList', () => {
|
|||||||
selection = documentList.data.getSelectedRows() as ShareDataRow[];
|
selection = documentList.data.getSelectedRows() as ShareDataRow[];
|
||||||
|
|
||||||
expect(selection).toEqual([]);
|
expect(selection).toEqual([]);
|
||||||
expect(getSelectionSpy).toHaveBeenCalled();
|
|
||||||
expect(getRowByNodeIdSpy).toHaveBeenCalledWith(mockPreselectedNodes[0].entry.id);
|
expect(getRowByNodeIdSpy).toHaveBeenCalledWith(mockPreselectedNodes[0].entry.id);
|
||||||
expect(datatableSelectRowSpy).toHaveBeenCalledWith(fakeDatatableRows[0], false);
|
expect(datatableSelectRowSpy).toHaveBeenCalledWith(fakeDatatableRows[0], false);
|
||||||
expect(onNodeUnselectSpy).toHaveBeenCalledWith({ row: undefined, selection });
|
expect(onNodeUnselectSpy).toHaveBeenCalledWith({ row: undefined, selection });
|
||||||
@@ -1775,7 +1767,6 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
it('should preselect the rows of the preselected nodes', () => {
|
it('should preselect the rows of the preselected nodes', () => {
|
||||||
const getRowByNodeIdSpy = spyOn(documentList.data, 'getRowByNodeId').and.callThrough();
|
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)];
|
const fakeDatatableRows = [new ShareDataRow(mockPreselectedNodes[0], contentService, null), new ShareDataRow(mockPreselectedNodes[1], contentService, null)];
|
||||||
documentList.data.setRows(fakeDatatableRows);
|
documentList.data.setRows(fakeDatatableRows);
|
||||||
@@ -1786,7 +1777,6 @@ describe('DocumentList', () => {
|
|||||||
documentList.preselectRowsOfPreselectedNodes();
|
documentList.preselectRowsOfPreselectedNodes();
|
||||||
const selectedRows = documentList.data.getSelectedRows();
|
const selectedRows = documentList.data.getSelectedRows();
|
||||||
|
|
||||||
expect(getPreselectedNodesSpy).toHaveBeenCalled();
|
|
||||||
expect(selectedRows.length).toEqual(2);
|
expect(selectedRows.length).toEqual(2);
|
||||||
expect(selectedRows[0].isSelected).toEqual(true);
|
expect(selectedRows[0].isSelected).toEqual(true);
|
||||||
expect(selectedRows[1].isSelected).toEqual(true);
|
expect(selectedRows[1].isSelected).toEqual(true);
|
||||||
@@ -1799,9 +1789,6 @@ describe('DocumentList', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should select the rows of the preselected nodes and emit the new combined selection', () => {
|
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 onNodeSelectSpy = spyOn(documentList, 'onNodeSelect').and.callThrough();
|
||||||
|
|
||||||
const fakeDatatableRows = [
|
const fakeDatatableRows = [
|
||||||
@@ -1818,9 +1805,6 @@ describe('DocumentList', () => {
|
|||||||
documentList.onPreselectNodes();
|
documentList.onPreselectNodes();
|
||||||
const selection = documentList.data.getSelectedRows() as ShareDataRow[];
|
const selection = documentList.data.getSelectedRows() as ShareDataRow[];
|
||||||
|
|
||||||
expect(hasPreselectedNodesSpy).toHaveBeenCalled();
|
|
||||||
expect(preselectRowsOfPreselectedNodesSpy).toHaveBeenCalled();
|
|
||||||
expect(getPreselectedRowsBasedOnSelectionModeSpy).toHaveBeenCalled();
|
|
||||||
expect(selection.length).toEqual(3);
|
expect(selection.length).toEqual(3);
|
||||||
expect(selection[0].id).toEqual(mockNode1.id);
|
expect(selection[0].id).toEqual(mockNode1.id);
|
||||||
expect(selection[1].id).toEqual(mockNode2.id);
|
expect(selection[1].id).toEqual(mockNode2.id);
|
||||||
|
@@ -298,38 +298,38 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
|
|
||||||
/** Emitted when the user clicks a list node */
|
/** Emitted when the user clicks a list node */
|
||||||
@Output()
|
@Output()
|
||||||
nodeClick: EventEmitter<NodeEntityEvent> = new EventEmitter<NodeEntityEvent>();
|
nodeClick = new EventEmitter<NodeEntityEvent>();
|
||||||
|
|
||||||
/** Emitted when the user double-clicks a list node */
|
/** Emitted when the user double-clicks a list node */
|
||||||
@Output()
|
@Output()
|
||||||
nodeDblClick: EventEmitter<NodeEntityEvent> = new EventEmitter<NodeEntityEvent>();
|
nodeDblClick = new EventEmitter<NodeEntityEvent>();
|
||||||
|
|
||||||
/** Emitted when the current display folder changes */
|
/** Emitted when the current display folder changes */
|
||||||
@Output()
|
@Output()
|
||||||
folderChange: EventEmitter<NodeEntryEvent> = new EventEmitter<NodeEntryEvent>();
|
folderChange = new EventEmitter<NodeEntryEvent>();
|
||||||
|
|
||||||
/** Emitted when the user acts upon files with either single or double click
|
/** Emitted when the user acts upon files with either single or double click
|
||||||
* (depends on `navigation-mode`). Useful for integration with the
|
* (depends on `navigation-mode`). Useful for integration with the
|
||||||
* Viewer component.
|
* Viewer component.
|
||||||
*/
|
*/
|
||||||
@Output()
|
@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 */
|
/** Emitted when the Document List has loaded all items and is ready for use */
|
||||||
@Output()
|
@Output()
|
||||||
ready: EventEmitter<NodePaging> = new EventEmitter();
|
ready = new EventEmitter<NodePaging>();
|
||||||
|
|
||||||
/** Emitted when the API fails to get the Document List data */
|
/** Emitted when the API fails to get the Document List data */
|
||||||
@Output()
|
@Output()
|
||||||
error: EventEmitter<any> = new EventEmitter();
|
error = new EventEmitter<any>();
|
||||||
|
|
||||||
/** Emitted when the node selection change */
|
/** Emitted when the node selection change */
|
||||||
@Output()
|
@Output()
|
||||||
nodeSelected: EventEmitter<NodeEntry[]> = new EventEmitter<NodeEntry[]>();
|
nodeSelected = new EventEmitter<NodeEntry[]>();
|
||||||
|
|
||||||
/** Emitted when a filter value is selected */
|
/** Emitted when a filter value is selected */
|
||||||
@Output()
|
@Output()
|
||||||
filterSelection: EventEmitter<FilterSearch[]> = new EventEmitter();
|
filterSelection = new EventEmitter<FilterSearch[]>();
|
||||||
|
|
||||||
@ViewChild('dataTable', { static: true })
|
@ViewChild('dataTable', { static: true })
|
||||||
dataTable: DataTableComponent;
|
dataTable: DataTableComponent;
|
||||||
@@ -356,7 +356,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
private loadingTimeout;
|
private loadingTimeout;
|
||||||
private onDestroy$ = new Subject<boolean>();
|
private onDestroy$ = new Subject<boolean>();
|
||||||
|
|
||||||
_nodesApi: NodesApi;
|
private _nodesApi: NodesApi;
|
||||||
get nodesApi(): NodesApi {
|
get nodesApi(): NodesApi {
|
||||||
this._nodesApi = this._nodesApi ?? new NodesApi(this.alfrescoApiService.getInstance());
|
this._nodesApi = this._nodesApi ?? new NodesApi(this.alfrescoApiService.getInstance());
|
||||||
return this._nodesApi;
|
return this._nodesApi;
|
||||||
@@ -400,7 +400,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
get hasCustomLayout(): boolean {
|
private get hasCustomLayout(): boolean {
|
||||||
return this.columnList && this.columnList.columns && this.columnList.columns.length > 0;
|
return this.columnList && this.columnList.columns && this.columnList.columns.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -653,7 +653,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
node.properties['cm:destination'];
|
node.properties['cm:destination'];
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCustomSourceData(nodeId: string): void {
|
private updateCustomSourceData(nodeId: string): void {
|
||||||
this.currentFolderId = nodeId;
|
this.currentFolderId = nodeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -754,7 +754,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
/**
|
/**
|
||||||
* Creates a set of predefined columns.
|
* Creates a set of predefined columns.
|
||||||
*/
|
*/
|
||||||
setupDefaultColumns(preset: string = 'default'): void {
|
private setupDefaultColumns(preset: string = 'default'): void {
|
||||||
if (this.data) {
|
if (this.data) {
|
||||||
const columns = this.getLayoutPreset(preset);
|
const columns = this.getLayoutPreset(preset);
|
||||||
this.data.setColumns(columns);
|
this.data.setColumns(columns);
|
||||||
@@ -938,7 +938,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
this.filterSelection.emit(activeFilters);
|
this.filterSelection.emit(activeFilters);
|
||||||
}
|
}
|
||||||
|
|
||||||
resetNewFolderPagination() {
|
private resetNewFolderPagination() {
|
||||||
this._pagination.skipCount = 0;
|
this._pagination.skipCount = 0;
|
||||||
this._pagination.maxItems = this.maxItems;
|
this._pagination.maxItems = this.maxItems;
|
||||||
}
|
}
|
||||||
@@ -986,7 +986,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
preserveExistingSelection() {
|
private preserveExistingSelection() {
|
||||||
if (this.isMultipleSelectionMode()) {
|
if (this.isMultipleSelectionMode()) {
|
||||||
for (const selection of this.selection) {
|
for (const selection of this.selection) {
|
||||||
const rowOfSelection = this.data.getRowByNodeId(selection.entry.id);
|
const rowOfSelection = this.data.getRowByNodeId(selection.entry.id);
|
||||||
@@ -1020,19 +1020,19 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isSingleSelectionMode(): boolean {
|
private isSingleSelectionMode(): boolean {
|
||||||
return this.selectionMode === 'single';
|
return this.selectionMode === 'single';
|
||||||
}
|
}
|
||||||
|
|
||||||
isMultipleSelectionMode(): boolean {
|
private isMultipleSelectionMode(): boolean {
|
||||||
return this.selectionMode === 'multiple';
|
return this.selectionMode === 'multiple';
|
||||||
}
|
}
|
||||||
|
|
||||||
hasPreselectedNodes(): boolean {
|
private hasPreselectedNodes(): boolean {
|
||||||
return this.preselectNodes?.length > 0;
|
return this.preselectNodes?.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasPreselectedRows(): boolean {
|
private hasPreselectedRows(): boolean {
|
||||||
return this.preselectedRows?.length > 0;
|
return this.preselectedRows?.length > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -896,7 +896,7 @@ export class DataTableComponent implements OnInit, AfterContentInit, OnChanges,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
datatableLayoutFix() {
|
private datatableLayoutFix() {
|
||||||
const maxGalleryRows = 25;
|
const maxGalleryRows = 25;
|
||||||
|
|
||||||
if (this.display === 'gallery') {
|
if (this.display === 'gallery') {
|
||||||
|
Reference in New Issue
Block a user