mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-3930] Can't load more results in Copy/Move dialog (#4247)
* fix unrelated failing test improve type definition add set get filtering node selector fix directive highlight fix minor problem style breadcrumb small refactoring problem documentlist * fix lint style * fix html node * fix test
This commit is contained in:
@@ -23,7 +23,6 @@ import { Subject, of, throwError } from 'rxjs';
|
||||
import { FileNode, FolderNode } from '../../mock';
|
||||
import {
|
||||
fakeNodeAnswerWithNOEntries,
|
||||
fakeNodeWithCreatePermission,
|
||||
fakeNodeWithNoPermission,
|
||||
fakeGetSitesAnswer,
|
||||
fakeGetSiteMembership
|
||||
@@ -249,7 +248,6 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should empty template be present when no element are present', () => {
|
||||
spyOn(documentList, 'loadFolderNodesByFolderNodeId').and.returnValue(Promise.resolve(''));
|
||||
spyOn(documentList, 'loadFolder').and.callThrough();
|
||||
spyOn(documentListService, 'getFolderNode').and.returnValue(of({ entry: { id: 'fake-node' } }));
|
||||
spyOn(documentListService, 'getFolder').and.returnValue(of(fakeNodeAnswerWithNOEntries));
|
||||
@@ -675,41 +673,41 @@ describe('DocumentList', () => {
|
||||
|
||||
it('should perform folder navigation on single click', () => {
|
||||
let folder = new FolderNode();
|
||||
spyOn(documentList, 'performNavigation').and.stub();
|
||||
spyOn(documentList, 'navigateTo').and.stub();
|
||||
|
||||
documentList.navigationMode = DocumentListComponent.SINGLE_CLICK_NAVIGATION;
|
||||
documentList.onNodeClick(folder);
|
||||
expect(documentList.performNavigation).toHaveBeenCalled();
|
||||
expect(documentList.navigateTo).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should perform folder navigation on double click', () => {
|
||||
let folder = new FolderNode();
|
||||
spyOn(documentList, 'performNavigation').and.stub();
|
||||
spyOn(documentList, 'navigateTo').and.stub();
|
||||
|
||||
documentList.navigationMode = DocumentListComponent.DOUBLE_CLICK_NAVIGATION;
|
||||
documentList.onNodeDblClick(folder);
|
||||
expect(documentList.performNavigation).toHaveBeenCalled();
|
||||
expect(documentList.navigateTo).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not perform folder navigation on double click when single mode', () => {
|
||||
let folder = new FolderNode();
|
||||
spyOn(documentList, 'performNavigation').and.stub();
|
||||
spyOn(documentList, 'navigateTo').and.stub();
|
||||
|
||||
documentList.navigationMode = DocumentListComponent.SINGLE_CLICK_NAVIGATION;
|
||||
documentList.onNodeDblClick(folder);
|
||||
|
||||
expect(documentList.performNavigation).not.toHaveBeenCalled();
|
||||
expect(documentList.navigateTo).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not perform folder navigation on double click when navigation off', () => {
|
||||
let folder = new FolderNode();
|
||||
spyOn(documentList, 'performNavigation').and.stub();
|
||||
spyOn(documentList, 'navigateTo').and.stub();
|
||||
|
||||
documentList.navigate = false;
|
||||
documentList.navigationMode = DocumentListComponent.DOUBLE_CLICK_NAVIGATION;
|
||||
documentList.onNodeDblClick(folder);
|
||||
|
||||
expect(documentList.performNavigation).not.toHaveBeenCalled();
|
||||
expect(documentList.navigateTo).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should perform navigation for folder node only', () => {
|
||||
@@ -718,9 +716,9 @@ describe('DocumentList', () => {
|
||||
|
||||
spyOn(documentList, 'loadFolder').and.stub();
|
||||
|
||||
expect(documentList.performNavigation(folder)).toBeTruthy();
|
||||
expect(documentList.performNavigation(file)).toBeFalsy();
|
||||
expect(documentList.performNavigation(null)).toBeFalsy();
|
||||
expect(documentList.navigateTo(folder.entry)).toBeTruthy();
|
||||
expect(documentList.navigateTo(file.entry)).toBeFalsy();
|
||||
expect(documentList.navigateTo(null)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should perform navigation through corret linked folder', () => {
|
||||
@@ -731,7 +729,7 @@ describe('DocumentList', () => {
|
||||
|
||||
spyOn(documentList, 'loadFolder').and.stub();
|
||||
|
||||
expect(documentList.performNavigation(linkFolder)).toBeTruthy();
|
||||
expect(documentList.navigateTo(linkFolder.entry)).toBeTruthy();
|
||||
expect(documentList.currentFolderId).toBe('normal-folder');
|
||||
});
|
||||
|
||||
@@ -754,7 +752,7 @@ describe('DocumentList', () => {
|
||||
it('should require valid node for folder navigation', () => {
|
||||
let folder = new FolderNode();
|
||||
folder.entry = null;
|
||||
spyOn(documentList, 'performNavigation').and.stub();
|
||||
spyOn(documentList, 'navigateTo').and.stub();
|
||||
|
||||
documentList.navigationMode = DocumentListComponent.SINGLE_CLICK_NAVIGATION;
|
||||
documentList.onNodeClick(folder);
|
||||
@@ -762,13 +760,12 @@ describe('DocumentList', () => {
|
||||
documentList.navigationMode = DocumentListComponent.DOUBLE_CLICK_NAVIGATION;
|
||||
documentList.onNodeDblClick(folder);
|
||||
|
||||
expect(documentList.performNavigation).not.toHaveBeenCalled();
|
||||
expect(documentList.navigateTo).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should display folder content from loadFolder on reload if folderNode defined', () => {
|
||||
documentList.folderNode = new NodeMinimal();
|
||||
|
||||
spyOn(documentList, 'loadFolderNodesByFolderNodeId').and.returnValue(Promise.resolve(''));
|
||||
spyOn(documentList, 'loadFolder').and.callThrough();
|
||||
documentList.reload();
|
||||
expect(documentList.loadFolder).toHaveBeenCalled();
|
||||
@@ -878,9 +875,9 @@ describe('DocumentList', () => {
|
||||
let filter = <RowFilter> {};
|
||||
documentList.currentFolderId = 'id';
|
||||
spyOn(documentList.data, 'setFilter').and.callThrough();
|
||||
spyOn(documentListService, 'getFolder');
|
||||
spyOn(documentListService, 'getFolder').and.callThrough();
|
||||
|
||||
documentList.ngOnChanges({ rowFilter: new SimpleChange(null, filter, true) });
|
||||
documentList.rowFilter = filter;
|
||||
|
||||
expect(documentList.data.setFilter).toHaveBeenCalledWith(filter);
|
||||
expect(documentListService.getFolder).toHaveBeenCalled();
|
||||
@@ -950,21 +947,7 @@ describe('DocumentList', () => {
|
||||
|
||||
it('should emit error when getFolderNode fails', (done) => {
|
||||
const error = { message: '{ "error": { "statusCode": 501 } }' };
|
||||
spyOn(documentListService, 'getFolderNode').and.returnValue(throwError(error));
|
||||
|
||||
let disposableError = documentList.error.subscribe((val) => {
|
||||
expect(val).toBe(error);
|
||||
disposableError.unsubscribe();
|
||||
done();
|
||||
});
|
||||
|
||||
documentList.loadFolderByNodeId('123');
|
||||
});
|
||||
|
||||
it('should emit error when loadFolderNodesByFolderNodeId fails', (done) => {
|
||||
const error = { message: '{ "error": { "statusCode": 501 } }' };
|
||||
spyOn(documentListService, 'getFolderNode').and.returnValue(of({ entry: fakeNodeWithCreatePermission }));
|
||||
spyOn(documentList, 'loadFolderNodesByFolderNodeId').and.returnValue(Promise.reject(error));
|
||||
spyOn(documentListService, 'getFolder').and.returnValue(throwError(error));
|
||||
|
||||
let disposableError = documentList.error.subscribe((val) => {
|
||||
expect(val).toBe(error);
|
||||
@@ -987,7 +970,7 @@ describe('DocumentList', () => {
|
||||
|
||||
it('should set no permission when getFolderNode fails with 403', (done) => {
|
||||
const error = { message: '{ "error": { "statusCode": 403 } }' };
|
||||
spyOn(documentListService, 'getFolderNode').and.returnValue(throwError(error));
|
||||
spyOn(documentListService, 'getFolder').and.returnValue(throwError(error));
|
||||
|
||||
let disposableError = documentList.error.subscribe((val) => {
|
||||
expect(val).toBe(error);
|
||||
@@ -1045,11 +1028,11 @@ describe('DocumentList', () => {
|
||||
const node = new FolderNode('folder');
|
||||
|
||||
documentList.currentFolderId = 'node-id';
|
||||
expect(documentList.canNavigateFolder(node)).toBeTruthy();
|
||||
expect(documentList.canNavigateFolder(node.entry)).toBeTruthy();
|
||||
|
||||
sources.forEach((source) => {
|
||||
documentList.currentFolderId = source;
|
||||
expect(documentList.canNavigateFolder(node)).toBeFalsy();
|
||||
expect(documentList.canNavigateFolder(node.entry)).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1245,23 +1228,6 @@ describe('DocumentList', () => {
|
||||
documentList.loadFolderByNodeId('-recent-');
|
||||
});
|
||||
|
||||
it('should reset folder node upon changing current folder id', () => {
|
||||
documentList.currentFolderId = 'fake-node-id';
|
||||
documentList.folderNode = <any> {};
|
||||
|
||||
documentList.ngOnChanges({ currentFolderId: new SimpleChange(null, '-sites-', false) });
|
||||
|
||||
expect(documentList.folderNode).toBeNull();
|
||||
});
|
||||
|
||||
it('should reset folder node on loading folder by node id', () => {
|
||||
documentList.folderNode = <any> {};
|
||||
|
||||
documentList.loadFolderByNodeId('-sites-');
|
||||
|
||||
expect(documentList.folderNode).toBeNull();
|
||||
});
|
||||
|
||||
it('should have correct currentFolderId on loading folder by node id', () => {
|
||||
documentList.currentFolderId = '12345-some-id-6789';
|
||||
|
||||
@@ -1298,9 +1264,9 @@ describe('DocumentList', () => {
|
||||
fixture.detectChanges();
|
||||
documentList.currentFolderId = 'fake-id';
|
||||
documentList.includeFields = ['test-include'];
|
||||
spyOn(documentListService, 'getFolder').and.stub();
|
||||
spyOn(documentListService, 'getFolder').and.callThrough();
|
||||
|
||||
documentList.ngOnChanges({ rowFilter: new SimpleChange(null, <RowFilter> {}, true) });
|
||||
documentList.ngOnChanges({ currentFolderId: new SimpleChange(null, '-root-', false) });
|
||||
|
||||
expect(documentListService.getFolder).toHaveBeenCalledWith(null, {
|
||||
maxItems: 25,
|
||||
|
@@ -23,9 +23,23 @@ import {
|
||||
} from '@angular/core';
|
||||
|
||||
import {
|
||||
ContentService, DataCellEvent, DataColumn, DataRowActionEvent, DataSorting, DataTableComponent,
|
||||
DisplayMode, ObjectDataColumn, PaginatedComponent, AppConfigService, DataColumnListComponent,
|
||||
UserPreferencesService, PaginationModel, ThumbnailService, CustomLoadingContentTemplateDirective, CustomNoPermissionTemplateDirective, CustomEmptyContentTemplateDirective
|
||||
ContentService,
|
||||
DataCellEvent,
|
||||
DataColumn,
|
||||
DataRowActionEvent,
|
||||
DataSorting,
|
||||
DataTableComponent,
|
||||
DisplayMode,
|
||||
ObjectDataColumn,
|
||||
PaginatedComponent,
|
||||
AppConfigService,
|
||||
DataColumnListComponent,
|
||||
UserPreferencesService,
|
||||
PaginationModel,
|
||||
ThumbnailService,
|
||||
CustomLoadingContentTemplateDirective,
|
||||
CustomNoPermissionTemplateDirective,
|
||||
CustomEmptyContentTemplateDirective
|
||||
} from '@alfresco/adf-core';
|
||||
|
||||
import { Node, NodeEntry, NodePaging } from '@alfresco/js-api';
|
||||
@@ -39,6 +53,7 @@ import { DocumentListService } from './../services/document-list.service';
|
||||
import { NodeEntityEvent, NodeEntryEvent } from './node.event';
|
||||
import { CustomResourcesService } from './../services/custom-resources.service';
|
||||
import { NavigableComponentInterface } from '../../breadcrumb/navigable-component.interface';
|
||||
import { RowFilter } from '../data/row-filter.model';
|
||||
|
||||
export enum PaginationStrategy {
|
||||
Finite,
|
||||
@@ -172,7 +187,22 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
|
||||
/** Custom row filter */
|
||||
@Input()
|
||||
rowFilter: any | null = null;
|
||||
_rowFilter: RowFilter | null = null;
|
||||
|
||||
@Input()
|
||||
set rowFilter(rowFilter: RowFilter) {
|
||||
this._rowFilter = rowFilter;
|
||||
if (this.data) {
|
||||
this.data.setFilter(this._rowFilter);
|
||||
if (this.currentFolderId) {
|
||||
this.reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get rowFilter(): RowFilter {
|
||||
return this._rowFilter;
|
||||
}
|
||||
|
||||
/** Custom image resolver */
|
||||
@Input()
|
||||
@@ -225,7 +255,10 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
data: ShareDataTableAdapter;
|
||||
noPermission: boolean = false;
|
||||
selection = new Array<NodeEntry>();
|
||||
folderNode: Node = null;
|
||||
$folderNode: Subject<Node> = new Subject<Node>();
|
||||
|
||||
// @deprecated 3.0.0
|
||||
folderNode: Node;
|
||||
|
||||
private _pagination: BehaviorSubject<PaginationModel>;
|
||||
private layoutPresets = {};
|
||||
@@ -305,8 +338,8 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
this.data.thumbnails = this.thumbnails;
|
||||
this.data.permissionsStyle = this.permissionsStyle;
|
||||
|
||||
if (this.rowFilter) {
|
||||
this.data.setFilter(this.rowFilter);
|
||||
if (this._rowFilter) {
|
||||
this.data.setFilter(this._rowFilter);
|
||||
}
|
||||
|
||||
if (this.imageResolver) {
|
||||
@@ -371,17 +404,16 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
if (changes.currentFolderId &&
|
||||
changes.currentFolderId.currentValue &&
|
||||
changes.currentFolderId.currentValue !== changes.currentFolderId.previousValue) {
|
||||
if (this.data) {
|
||||
this.data.loadPage(null, false);
|
||||
}
|
||||
|
||||
this.resetNewFolderPagination();
|
||||
this.loadFolder();
|
||||
} else if (this.data) {
|
||||
if (changes.node && changes.node.currentValue) {
|
||||
this.data.loadPage(changes.node.currentValue);
|
||||
this.onDataReady(changes.node.currentValue);
|
||||
} else if (changes.rowFilter && changes.rowFilter.currentValue !== changes.rowFilter.previousValue) {
|
||||
this.data.setFilter(changes.rowFilter.currentValue);
|
||||
if (this.currentFolderId) {
|
||||
this.loadFolderNodesByFolderNodeId(this.currentFolderId, this.pagination.getValue()).catch((err) => this.error.emit(err));
|
||||
}
|
||||
} else if (changes.imageResolver) {
|
||||
this.data.setImageResolver(changes.imageResolver.currentValue);
|
||||
}
|
||||
@@ -392,7 +424,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
this.ngZone.run(() => {
|
||||
this.resetSelection();
|
||||
if (this.node) {
|
||||
this.data.loadPage(this.node);
|
||||
this.data.loadPage(this.node, this.pagination.getValue().merge);
|
||||
this.onDataReady(this.node);
|
||||
} else {
|
||||
this.loadFolder();
|
||||
@@ -479,40 +511,35 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
}
|
||||
}
|
||||
|
||||
performNavigation(node: NodeEntry): boolean {
|
||||
if (this.canNavigateFolder(node)) {
|
||||
this.updateFolderData(node);
|
||||
navigateTo(node: Node | string): boolean {
|
||||
if (typeof node === 'string') {
|
||||
this.resetNewFolderPagination();
|
||||
this.currentFolderId = node;
|
||||
this.folderChange.emit(new NodeEntryEvent(<Node> { id: node }));
|
||||
this.reload();
|
||||
return true;
|
||||
} else {
|
||||
if (this.canNavigateFolder(node)) {
|
||||
this.resetNewFolderPagination();
|
||||
this.currentFolderId = this.getNodeFolderDestinationId(node);
|
||||
this.folderChange.emit(new NodeEntryEvent(<Node> { id: this.currentFolderId }));
|
||||
this.reload();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
performCustomSourceNavigation(node: NodeEntry): boolean {
|
||||
if (this.customResourcesService.isCustomSource(this.currentFolderId)) {
|
||||
this.updateFolderData(node);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
private getNodeFolderDestinationId(node: Node) {
|
||||
return this.isLinkFolder(node) ? node.properties['cm:destination'] : node.id;
|
||||
}
|
||||
|
||||
updateFolderData(node: NodeEntry): void {
|
||||
this.resetNewFolderPagination();
|
||||
this.currentFolderId = this.getNodeFolderDestinationId(node);
|
||||
this.folderChange.emit(new NodeEntryEvent(<Node> { id: this.currentFolderId }));
|
||||
this.reload();
|
||||
}
|
||||
|
||||
private getNodeFolderDestinationId(node: NodeEntry) {
|
||||
return this.isLinkFolder(node) ? node.entry.properties['cm:destination'] : node.entry.id;
|
||||
}
|
||||
|
||||
private isLinkFolder(node: NodeEntry) {
|
||||
return node.entry.nodeType === 'app:folderlink' && node.entry.properties &&
|
||||
node.entry.properties['cm:destination'];
|
||||
private isLinkFolder(node: Node) {
|
||||
return node.nodeType === 'app:folderlink' && node.properties &&
|
||||
node.properties['cm:destination'];
|
||||
}
|
||||
|
||||
updateCustomSourceData(nodeId: string): void {
|
||||
this.folderNode = null;
|
||||
this.currentFolderId = nodeId;
|
||||
}
|
||||
|
||||
@@ -573,39 +600,26 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
this.error.emit(err);
|
||||
});
|
||||
} else {
|
||||
this.documentListService
|
||||
.getFolderNode(nodeId, this.includeFields)
|
||||
.subscribe((node: NodeEntry) => {
|
||||
this.folderNode = node.entry;
|
||||
return this.loadFolderNodesByFolderNodeId(node.entry.id, this.pagination.getValue())
|
||||
.catch((err) => this.handleError(err));
|
||||
let pagination = this.pagination.getValue();
|
||||
this.documentListService.getFolder(null, {
|
||||
maxItems: pagination.maxItems,
|
||||
skipCount: pagination.skipCount,
|
||||
rootFolderId: nodeId
|
||||
}, this.includeFields)
|
||||
.subscribe((nodePaging: NodePaging) => {
|
||||
this.data.loadPage(nodePaging, this.pagination.getValue().merge);
|
||||
this.setLoadingState(false);
|
||||
this.onDataReady(nodePaging);
|
||||
this.documentListService.getFolderNode(nodeId, this.includeFields).subscribe((nodeEntry: NodeEntry) => {
|
||||
this.folderNode = nodeEntry.entry;
|
||||
this.$folderNode.next(this.folderNode);
|
||||
});
|
||||
}, (err) => {
|
||||
this.handleError(err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
loadFolderNodesByFolderNodeId(id: string, pagination: PaginationModel): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
this.documentListService
|
||||
.getFolder(null, {
|
||||
maxItems: pagination.maxItems,
|
||||
skipCount: pagination.skipCount,
|
||||
rootFolderId: id
|
||||
}, this.includeFields)
|
||||
.subscribe(
|
||||
(nodePaging) => {
|
||||
this.data.loadPage(<NodePaging> nodePaging, this.pagination.getValue().merge);
|
||||
this.setLoadingState(false);
|
||||
this.onDataReady(nodePaging);
|
||||
resolve(true);
|
||||
}, (err) => {
|
||||
this.handleError(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
resetSelection() {
|
||||
this.dataTable.resetSelection();
|
||||
this.selection = [];
|
||||
@@ -636,58 +650,56 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
}
|
||||
}
|
||||
|
||||
onNodeClick(node: NodeEntry) {
|
||||
onNodeClick(nodeEntry: NodeEntry) {
|
||||
const domEvent = new CustomEvent('node-click', {
|
||||
detail: {
|
||||
sender: this,
|
||||
node: node
|
||||
node: nodeEntry
|
||||
},
|
||||
bubbles: true
|
||||
});
|
||||
|
||||
this.elementRef.nativeElement.dispatchEvent(domEvent);
|
||||
|
||||
const event = new NodeEntityEvent(node);
|
||||
const event = new NodeEntityEvent(nodeEntry);
|
||||
this.nodeClick.emit(event);
|
||||
|
||||
if (!event.defaultPrevented) {
|
||||
if (this.navigate && this.navigationMode === DocumentListComponent.SINGLE_CLICK_NAVIGATION) {
|
||||
if (node && node.entry) {
|
||||
if (node.entry.isFile) {
|
||||
this.onPreviewFile(node);
|
||||
}
|
||||
|
||||
if (node.entry.isFolder) {
|
||||
this.performNavigation(node);
|
||||
}
|
||||
}
|
||||
this.executeActionClick(nodeEntry);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onNodeDblClick(node: NodeEntry) {
|
||||
onNodeDblClick(nodeEntry: NodeEntry) {
|
||||
const domEvent = new CustomEvent('node-dblclick', {
|
||||
detail: {
|
||||
sender: this,
|
||||
node: node
|
||||
node: nodeEntry
|
||||
},
|
||||
bubbles: true
|
||||
});
|
||||
this.elementRef.nativeElement.dispatchEvent(domEvent);
|
||||
|
||||
const event = new NodeEntityEvent(node);
|
||||
const event = new NodeEntityEvent(nodeEntry);
|
||||
this.nodeDblClick.emit(event);
|
||||
|
||||
if (!event.defaultPrevented) {
|
||||
if (this.navigate && this.navigationMode === DocumentListComponent.DOUBLE_CLICK_NAVIGATION) {
|
||||
if (node && node.entry) {
|
||||
if (node.entry.isFile) {
|
||||
this.onPreviewFile(node);
|
||||
}
|
||||
this.executeActionClick(nodeEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (node.entry.isFolder) {
|
||||
this.performNavigation(node);
|
||||
}
|
||||
}
|
||||
executeActionClick(nodeEntry: NodeEntry) {
|
||||
if (nodeEntry && nodeEntry.entry) {
|
||||
if (nodeEntry.entry.isFile) {
|
||||
this.onPreviewFile(nodeEntry);
|
||||
}
|
||||
|
||||
if (nodeEntry.entry.isFolder) {
|
||||
this.navigateTo(nodeEntry.entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -751,12 +763,12 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
}
|
||||
}
|
||||
|
||||
canNavigateFolder(node: NodeEntry): boolean {
|
||||
canNavigateFolder(node: Node): boolean {
|
||||
let canNavigateFolder: boolean = false;
|
||||
|
||||
if (this.customResourcesService.isCustomSource(this.currentFolderId)) {
|
||||
canNavigateFolder = false;
|
||||
} else if (node && node.entry && node.entry.isFolder) {
|
||||
} else if (node && node.isFolder) {
|
||||
canNavigateFolder = true;
|
||||
}
|
||||
|
||||
@@ -784,15 +796,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
this.reload();
|
||||
}
|
||||
|
||||
navigateTo(nodeId: string) {
|
||||
this.currentFolderId = nodeId;
|
||||
this.resetNewFolderPagination();
|
||||
this.loadFolder();
|
||||
this.folderChange.emit(new NodeEntryEvent(<Node> { id: nodeId }));
|
||||
}
|
||||
|
||||
private resetNewFolderPagination() {
|
||||
this.folderNode = null;
|
||||
this.pagination.value.skipCount = 0;
|
||||
}
|
||||
|
||||
|
@@ -15,11 +15,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { DataColumn, DataRow, DataSorting, DataTableAdapter, ThumbnailService, ContentService } from '@alfresco/adf-core';
|
||||
import {
|
||||
DataColumn,
|
||||
DataRow,
|
||||
DataSorting,
|
||||
DataTableAdapter,
|
||||
ThumbnailService,
|
||||
ContentService
|
||||
} from '@alfresco/adf-core';
|
||||
import { NodePaging } from '@alfresco/js-api';
|
||||
import { PermissionStyleModel } from './../models/permissions-style.model';
|
||||
import { DocumentListService } from './../services/document-list.service';
|
||||
import { ShareDataRow } from './share-data-row.model';
|
||||
import { NodeEntry } from '@alfresco/js-api/src/api/content-rest-api/model/nodeEntry';
|
||||
import { RowFilter } from './row-filter.model';
|
||||
|
||||
export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
|
||||
@@ -31,7 +40,7 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
private rows: DataRow[];
|
||||
private columns: DataColumn[];
|
||||
|
||||
private filter: any;
|
||||
private filter: RowFilter;
|
||||
private imageResolver: any;
|
||||
|
||||
thumbnails: boolean = false;
|
||||
@@ -156,7 +165,7 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
this.setSorting(sorting);
|
||||
}
|
||||
|
||||
setFilter(filter: any) {
|
||||
setFilter(filter: RowFilter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
@@ -237,15 +246,15 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
}
|
||||
|
||||
public loadPage(page: NodePaging, merge: boolean = false) {
|
||||
let rows = [];
|
||||
let shareDataRows: ShareDataRow[] = [];
|
||||
|
||||
if (page && page.list) {
|
||||
let data = page.list.entries;
|
||||
if (data && data.length > 0) {
|
||||
rows = data.map((item) => new ShareDataRow(item, this.contentService, this.permissionsStyle, this.thumbnailService));
|
||||
let nodeEntries: NodeEntry[] = page.list.entries;
|
||||
if (nodeEntries && nodeEntries.length > 0) {
|
||||
shareDataRows = nodeEntries.map((item) => new ShareDataRow(item, this.contentService, this.permissionsStyle, this.thumbnailService));
|
||||
|
||||
if (this.filter) {
|
||||
rows = rows.filter(this.filter);
|
||||
shareDataRows = shareDataRows.filter(this.filter);
|
||||
}
|
||||
|
||||
if (this.sortingMode !== 'server') {
|
||||
@@ -253,7 +262,7 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
if (this.columns && this.columns.length > 0) {
|
||||
let sorting = this.getSorting();
|
||||
if (sorting) {
|
||||
this.sortRows(rows, sorting);
|
||||
this.sortRows(shareDataRows, sorting);
|
||||
} else {
|
||||
let sortable = this.columns.filter((c) => c.sortable);
|
||||
if (sortable.length > 0) {
|
||||
@@ -268,7 +277,7 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
}
|
||||
|
||||
if (merge) {
|
||||
let listPrunedDuplicate = rows.filter((elementToFilter) => {
|
||||
let listPrunedDuplicate = shareDataRows.filter((elementToFilter: any) => {
|
||||
let isPresent = this.rows.find((currentRow: any) => {
|
||||
return currentRow.obj.entry.id === elementToFilter.obj.entry.id;
|
||||
});
|
||||
@@ -278,7 +287,8 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
|
||||
this.rows = this.rows.concat(listPrunedDuplicate);
|
||||
} else {
|
||||
this.rows = rows;
|
||||
this.rows = shareDataRows;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user