dynamic column layout support (#2260)

This commit is contained in:
Denys Vuika
2017-09-01 11:51:02 +01:00
committed by Mario Romano
parent 42ed604349
commit 5f7d690db5
15 changed files with 70 additions and 193 deletions

View File

@@ -201,6 +201,10 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
}
}
get hasCustomLayout(): boolean {
return this.columnList && this.columnList.columns && this.columnList.columns.length > 0;
}
ngOnInit() {
this.data = new ShareDataTableAdapter(this.documentListService, null, this.getDefaultSorting());
this.data.thumbnails = this.thumbnails;
@@ -222,7 +226,7 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
ngAfterContentInit() {
let schema: DataColumn[] = [];
if (this.columnList && this.columnList.columns && this.columnList.columns.length > 0) {
if (this.hasCustomLayout) {
schema = this.columnList.columns.map(c => <DataColumn> c);
}
@@ -239,20 +243,23 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
}
ngOnChanges(changes: SimpleChanges) {
if (changes['folderNode'] && changes['folderNode'].currentValue) {
if (changes.folderNode && changes.folderNode.currentValue) {
this.loadFolder();
} else if (changes['currentFolderId'] && changes['currentFolderId'].currentValue) {
this.loadFolderByNodeId(changes['currentFolderId'].currentValue);
} else if (changes.currentFolderId && changes.currentFolderId.currentValue) {
if (!this.hasCustomLayout) {
this.setupDefaultColumns(changes.currentFolderId.currentValue);
}
this.loadFolderByNodeId(changes.currentFolderId.currentValue);
} else if (this.data) {
if (changes['node'] && changes['node'].currentValue) {
this.data.loadPage(changes['node'].currentValue);
} else if (changes['rowFilter']) {
this.data.setFilter(changes['rowFilter'].currentValue);
if (changes.node && changes.node.currentValue) {
this.data.loadPage(changes.node.currentValue);
} else if (changes.rowFilter) {
this.data.setFilter(changes.rowFilter.currentValue);
if (this.currentFolderId) {
this.loadFolderNodesByFolderNodeId(this.currentFolderId, this.pageSize, this.skipCount);
}
} else if (changes['imageResolver']) {
this.data.setImageResolver(changes['imageResolver'].currentValue);
} else if (changes.imageResolver) {
this.data.setImageResolver(changes.imageResolver.currentValue);
}
}
}
@@ -561,8 +568,10 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
* Creates a set of predefined columns.
*/
setupDefaultColumns(preset: string = 'default'): void {
const columns = this.getLayoutPreset(preset);
this.data.setColumns(columns);
if (this.data) {
const columns = this.getLayoutPreset(preset);
this.data.setColumns(columns);
}
}
onPreviewFile(node: MinimalNodeEntity) {
@@ -711,9 +720,7 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
}
canNavigateFolder(node: MinimalNodeEntity): boolean {
const restricted = ['-trashcan-', '-sharedlinks-', '-sites-', '-favorites-', '-recent-'];
if (restricted.indexOf(this.currentFolderId) > -1) {
if (this.isCustomSource(this.currentFolderId)) {
return false;
}
@@ -724,6 +731,16 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
return false;
}
isCustomSource(folderId: string): boolean {
const sources = ['-trashcan-', '-sharedlinks-', '-sites-', '-favorites-', '-recent-'];
if (sources.indexOf(folderId) > -1) {
return true;
}
return false;
}
updateSkipCount(newSkipCount) {
this.skipCount = newSkipCount;
}