mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
* #1014 use document list to diplay search results * #1014 refactor pagination * #1014 documentation and scripts update * fix random erros on tests executrion * #1014 fix travis scripts and raise timeout jasmine * #1014 fix appveyor script * #1014 type nodeId
This commit is contained in:
committed by
Denys Vuika
parent
9e00b1d4f1
commit
b05247dade
@@ -17,80 +17,34 @@
|
||||
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { ObjectUtils } from 'ng2-alfresco-core';
|
||||
import { PaginationProvider, DataLoadedEventEmitter, DataTableAdapter, DataRow, DataColumn, DataSorting } from 'ng2-alfresco-datatable';
|
||||
import { DataTableAdapter, DataRow, DataColumn, DataSorting } from 'ng2-alfresco-datatable';
|
||||
|
||||
import { NodePaging, NodeMinimalEntry } from './../models/document-library.model';
|
||||
import { DocumentListService } from './../services/document-list.service';
|
||||
|
||||
export class ShareDataTableAdapter implements DataTableAdapter, PaginationProvider {
|
||||
export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
|
||||
ERR_ROW_NOT_FOUND: string = 'Row not found';
|
||||
ERR_COL_NOT_FOUND: string = 'Column not found';
|
||||
|
||||
DEFAULT_DATE_FORMAT: string = 'medium';
|
||||
DEFAULT_PAGE_SIZE: number = 20;
|
||||
MIN_PAGE_SIZE: number = 5;
|
||||
|
||||
private sorting: DataSorting;
|
||||
private rows: DataRow[];
|
||||
private columns: DataColumn[];
|
||||
private page: NodePaging;
|
||||
private folderNodeId: string;
|
||||
|
||||
private filter: RowFilter;
|
||||
private imageResolver: ImageResolver;
|
||||
|
||||
private _count: number = 0;
|
||||
private _hasMoreItems: boolean = false;
|
||||
private _totalItems: number = 0;
|
||||
private _skipCount: number = 0;
|
||||
private _maxItems: number = this.DEFAULT_PAGE_SIZE;
|
||||
|
||||
thumbnails: boolean = false;
|
||||
dataLoaded: DataLoadedEventEmitter;
|
||||
selectedRow: DataRow;
|
||||
|
||||
constructor(private documentListService: DocumentListService,
|
||||
private basePath: string,
|
||||
schema: DataColumn[]) {
|
||||
this.dataLoaded = new DataLoadedEventEmitter();
|
||||
this.rows = [];
|
||||
this.columns = schema || [];
|
||||
this.resetPagination();
|
||||
}
|
||||
|
||||
get count(): number {
|
||||
return this._count;
|
||||
}
|
||||
|
||||
get hasMoreItems(): boolean {
|
||||
return this._hasMoreItems;
|
||||
}
|
||||
|
||||
get totalItems(): number {
|
||||
return this._totalItems;
|
||||
}
|
||||
|
||||
get skipCount(): number {
|
||||
return this._skipCount;
|
||||
}
|
||||
|
||||
set skipCount(value: number) {
|
||||
if (value !== this._skipCount) {
|
||||
this._skipCount = value > 0 ? value : 0;
|
||||
this.loadById(this.folderNodeId);
|
||||
}
|
||||
}
|
||||
|
||||
get maxItems(): number {
|
||||
return this._maxItems;
|
||||
}
|
||||
|
||||
set maxItems(value: number) {
|
||||
if (value !== this._maxItems) {
|
||||
this._maxItems = value > this.MIN_PAGE_SIZE ? value : this.MIN_PAGE_SIZE;
|
||||
this.loadById(this.folderNodeId);
|
||||
}
|
||||
}
|
||||
|
||||
getRows(): Array<DataRow> {
|
||||
@@ -198,37 +152,8 @@ export class ShareDataTableAdapter implements DataTableAdapter, PaginationProvid
|
||||
this.setSorting(sorting);
|
||||
}
|
||||
|
||||
loadById(id: string): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (id && this.documentListService) {
|
||||
this.documentListService
|
||||
.getFolder(null, {
|
||||
maxItems: this._maxItems,
|
||||
skipCount: this._skipCount,
|
||||
rootFolderId: id
|
||||
})
|
||||
.subscribe(val => {
|
||||
this.folderNodeId = id;
|
||||
this.loadPage(<NodePaging>val);
|
||||
this.dataLoaded.emit(null);
|
||||
resolve(true);
|
||||
},
|
||||
error => {
|
||||
reject(error);
|
||||
});
|
||||
} else {
|
||||
resolve(false);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
setFilter(filter: RowFilter) {
|
||||
this.filter = filter;
|
||||
|
||||
if (this.filter && this.folderNodeId) {
|
||||
this.loadById(this.folderNodeId);
|
||||
}
|
||||
}
|
||||
|
||||
setImageResolver(resolver: ImageResolver) {
|
||||
@@ -263,9 +188,8 @@ export class ShareDataTableAdapter implements DataTableAdapter, PaginationProvid
|
||||
}
|
||||
}
|
||||
|
||||
private loadPage(page: NodePaging) {
|
||||
public loadPage(page: NodePaging) {
|
||||
this.page = page;
|
||||
this.resetPagination();
|
||||
|
||||
let rows = [];
|
||||
|
||||
@@ -293,15 +217,6 @@ export class ShareDataTableAdapter implements DataTableAdapter, PaginationProvid
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let pagination = page.list.pagination;
|
||||
if (pagination) {
|
||||
this._count = pagination.count;
|
||||
this._hasMoreItems = pagination.hasMoreItems;
|
||||
this._maxItems = pagination.maxItems;
|
||||
this._skipCount = pagination.skipCount;
|
||||
this._totalItems = pagination.totalItems;
|
||||
}
|
||||
}
|
||||
|
||||
this.rows = rows;
|
||||
@@ -310,14 +225,6 @@ export class ShareDataTableAdapter implements DataTableAdapter, PaginationProvid
|
||||
getImagePath(id: string): any {
|
||||
return `${this.basePath}/assets/images/${id}`;
|
||||
}
|
||||
|
||||
private resetPagination() {
|
||||
this._count = 0;
|
||||
this._hasMoreItems = false;
|
||||
this._totalItems = 0;
|
||||
this._skipCount = 0;
|
||||
this._maxItems = this.DEFAULT_PAGE_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
export class ShareDataRow implements DataRow {
|
||||
|
Reference in New Issue
Block a user