fix infinite pagination delete, difficult to handle the delta in case of delete better to reload the whole list for infinite pagination

This commit is contained in:
Eugenio Romano 2019-02-06 19:06:28 +00:00
parent 0d6c1bedfa
commit 836caf5253
4 changed files with 33 additions and 36 deletions

View File

@ -35,7 +35,7 @@
<adf-upload-drag-area fxFlex="1 1 auto"
[disabled]="disableDragArea"
[acceptedFilesType]="getFileFiltering()"
[rootFolderId]="getDocumentListCurrentFolderId()"
[rootFolderId]="currentFolderId"
[versioning]="versioning"
[adf-node-permission]="'create'"
[adf-nodes]="disableDragArea ? getCurrentDocumentListNode() : []"
@ -77,7 +77,7 @@
title="{{ 'DOCUMENT_LIST.TOOLBAR.NEW_FOLDER' | translate }}"
(error)="openSnackMessage($event)"
(success)="documentList.reload()"
[adf-create-folder]="getDocumentListCurrentFolderId()"
[adf-create-folder]="currentFolderId"
matTooltip="{{ 'DOCUMENT_LIST.TOOLBAR.NEW_FOLDER' | translate }}">
<mat-icon>create_new_folder</mat-icon>
</button>
@ -166,7 +166,7 @@
</button>
<button mat-menu-item
(error)="openSnackMessage($event)"
[adf-create-folder]="getDocumentListCurrentFolderId()">
[adf-create-folder]="currentFolderId">
<mat-icon>create_new_folder</mat-icon>
<span>{{ 'DOCUMENT_LIST.TOOLBAR.NEW_FOLDER' | translate }}</span>
</button>
@ -531,7 +531,7 @@
</section>
<section>
<mat-slide-toggle id="adf-document-list-enable-drop-files" [color]="'primary'" (click)="toggleAllowDropFiles()" >
<mat-slide-toggle id="adf-document-list-enable-drop-files" [color]="'primary'" [(ngModel)]="allowDropFiles" (click)="toggleAllowDropFiles()" >
{{'DOCUMENT_LIST.ALLOW_DROP_FILES' | translate}}
</mat-slide-toggle>
</section>

View File

@ -231,7 +231,6 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
}
toggleAllowDropFiles() {
this.allowDropFiles = !this.allowDropFiles;
this.documentList.reload();
}
@ -434,10 +433,6 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
this.currentFolderId = site.entry.guid;
}
getDocumentListCurrentFolderId() {
return this.documentList.currentFolderId || DEFAULT_FOLDER_TO_SHOW;
}
hasSelection(selection: Array<MinimalNodeEntity>): boolean {
return selection && selection.length > 0;
}

View File

@ -57,11 +57,6 @@ 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,
Infinite
}
@Component({
selector: 'adf-document-list',
styleUrls: ['./document-list.component.scss'],
@ -203,7 +198,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
this._rowFilter = rowFilter;
if (this.data) {
this.data.setFilter(this._rowFilter);
if (this.currentFolderId) {
if (this._currentFolderId) {
this.reload();
}
}
@ -217,9 +212,25 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
@Input()
imageResolver: any | null = null;
_currentFolderId: string = null;
/** The ID of the folder node to display or a reserved string alias for special sources */
@Input()
currentFolderId: string = null;
set currentFolderId(currentFolderId: string) {
if (this._currentFolderId !== currentFolderId) {
this._currentFolderId = currentFolderId;
if (this.data) {
this.data.loadPage(null, false);
}
this.resetNewFolderPagination();
this.loadFolder();
}
}
get currentFolderId(): string {
return this._currentFolderId;
}
/** The Document list will show all the nodes contained in the NodePaging entity */
@Input()
@ -391,7 +402,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
let columns = this.data.getColumns();
if (!columns || columns.length === 0) {
this.setupDefaultColumns(this.currentFolderId);
this.setupDefaultColumns(this._currentFolderId);
}
}
@ -413,16 +424,7 @@ 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 (this.data) {
if (changes.node && changes.node.currentValue) {
let merge = this._pagination ? this._pagination.merge : false;
@ -528,15 +530,15 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
navigateTo(node: Node | string): boolean {
if (typeof node === 'string') {
this.resetNewFolderPagination();
this.currentFolderId = node;
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._currentFolderId = this.getNodeFolderDestinationId(node);
this.folderChange.emit(new NodeEntryEvent(<Node> { id: this._currentFolderId }));
this.reload();
return true;
}
@ -554,7 +556,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
}
updateCustomSourceData(nodeId: string): void {
this.currentFolderId = nodeId;
this._currentFolderId = nodeId;
}
/**
@ -598,10 +600,10 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
}
if (!this.hasCustomLayout) {
this.setupDefaultColumns(this.currentFolderId);
this.setupDefaultColumns(this._currentFolderId);
}
this.loadFolderByNodeId(this.currentFolderId);
this.loadFolderByNodeId(this._currentFolderId);
}
loadFolderByNodeId(nodeId: string) {

View File

@ -88,9 +88,9 @@ export class InfinitePaginationComponent implements OnInit, OnDestroy, Paginatio
}
onLoadMore() {
this.requestPaginationModel.skipCount += this.pageSize;
this.requestPaginationModel.merge = true;
this.requestPaginationModel.maxItems = this.pageSize;
this.requestPaginationModel.skipCount = 0;
this.requestPaginationModel.merge = false;
this.requestPaginationModel.maxItems += this.pageSize;
this.loadMore.next(this.requestPaginationModel);