mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-10-08 14:51:32 +00:00
[ADF-1873] Remove all deprecated code from ADF (#4145)
* remove deprecated code part 1 * remove deprecation step 2 * fix spellcheck * fix * fix lint * fix not used import * remove deprecation * fix test first part after remove deprecation * fix test * fix sidebar demo shell
This commit is contained in:
@@ -72,6 +72,7 @@ describe('DocumentList', () => {
|
||||
customResourcesService = TestBed.get(CustomResourcesService);
|
||||
|
||||
documentList.ngOnInit();
|
||||
documentList.currentFolderId = 'no-node';
|
||||
|
||||
spyGetSites = spyOn(apiService.sitesApi, 'getSites').and.returnValue(Promise.resolve(fakeGetSitesAnswer));
|
||||
spyFavorite = spyOn(apiService.favoritesApi, 'getFavorites').and.returnValue(Promise.resolve({ list: [] }));
|
||||
@@ -246,20 +247,17 @@ describe('DocumentList', () => {
|
||||
expect(documentList.dataTable.resetSelection).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should empty template be present when no element are present', (done) => {
|
||||
fixture.detectChanges();
|
||||
documentList.folderNode = new NodeMinimal();
|
||||
documentList.folderNode.id = '1d26e465-dea3-42f3-b415-faa8364b9692';
|
||||
|
||||
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));
|
||||
|
||||
let disposableReady = documentList.ready.subscribe(() => {
|
||||
expect(element.querySelector('#adf-document-list-empty')).toBeDefined();
|
||||
disposableReady.unsubscribe();
|
||||
done();
|
||||
});
|
||||
documentList.currentFolderId = '1d26e465-dea3-42f3-b415-faa8364b9692';
|
||||
fixture.detectChanges();
|
||||
|
||||
documentList.reload();
|
||||
expect(element.querySelector('#adf-document-list-empty')).toBeDefined();
|
||||
});
|
||||
|
||||
it('should not execute action without node provided', () => {
|
||||
@@ -959,10 +957,9 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should load folder by ID on init', () => {
|
||||
documentList.currentFolderId = '1d26e465-dea3-42f3-b415-faa8364b9692';
|
||||
spyOn(documentList, 'loadFolder').and.returnValue(Promise.resolve());
|
||||
|
||||
documentList.ngOnChanges({ folderNode: new SimpleChange(null, documentList.currentFolderId, true) });
|
||||
documentList.ngOnChanges({ currentFolderId: new SimpleChange(null, '1d26e465-dea3-42f3-b415-faa8364b9692', true) });
|
||||
expect(documentList.loadFolder).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -1294,7 +1291,6 @@ describe('DocumentList', () => {
|
||||
spyOn(documentList, 'reload').and.stub();
|
||||
|
||||
documentList.maxItems = 0;
|
||||
documentList.skipCount = 0;
|
||||
|
||||
documentList.updatePagination({
|
||||
maxItems: 10,
|
||||
@@ -1313,32 +1309,6 @@ describe('DocumentList', () => {
|
||||
expect(documentList.reload).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should NOT reload data on ngOnChanges upon reset of skipCount to 0', () => {
|
||||
spyOn(documentList, 'reload').and.stub();
|
||||
|
||||
documentList.maxItems = 10;
|
||||
documentList.skipCount = 10;
|
||||
|
||||
const firstChange = true;
|
||||
documentList.ngOnChanges({ skipCount: new SimpleChange(undefined, 0, !firstChange) });
|
||||
|
||||
expect(documentList.reload).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should reload data upon changing pagination setting skipCount to 0', () => {
|
||||
spyOn(documentList, 'reload').and.stub();
|
||||
|
||||
documentList.maxItems = 5;
|
||||
documentList.skipCount = 5;
|
||||
|
||||
documentList.updatePagination({
|
||||
maxItems: 5,
|
||||
skipCount: 0
|
||||
});
|
||||
|
||||
expect(documentList.reload).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should add includeFields in the server request when present', () => {
|
||||
fixture.detectChanges();
|
||||
documentList.currentFolderId = 'fake-id';
|
||||
|
@@ -173,13 +173,6 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
@Input()
|
||||
currentFolderId: string = null;
|
||||
|
||||
/**
|
||||
* Currently displayed folder node
|
||||
* @deprecated 2.3.0 - use currentFolderId or node
|
||||
*/
|
||||
@Input()
|
||||
folderNode: Node = null;
|
||||
|
||||
/** The Document list will show all the nodes contained in the NodePaging entity */
|
||||
@Input()
|
||||
node: NodePaging = null;
|
||||
@@ -188,20 +181,6 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
@Input()
|
||||
maxItems: number;
|
||||
|
||||
/**
|
||||
* Number of elements to skip over for pagination purposes
|
||||
* @deprecated 2.3.0 - define it in pagination
|
||||
*/
|
||||
@Input()
|
||||
skipCount: number = 0;
|
||||
|
||||
/**
|
||||
* Set document list to work in infinite scrolling mode
|
||||
* @deprecated 2.3.0
|
||||
*/
|
||||
@Input()
|
||||
enableInfiniteScrolling: boolean = false;
|
||||
|
||||
/** Emitted when the user clicks a list node */
|
||||
@Output()
|
||||
nodeClick: EventEmitter<NodeEntityEvent> = new EventEmitter<NodeEntityEvent>();
|
||||
@@ -239,6 +218,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
data: ShareDataTableAdapter;
|
||||
noPermission: boolean = false;
|
||||
selection = new Array<NodeEntry>();
|
||||
folderNode: Node = null;
|
||||
|
||||
private _pagination: BehaviorSubject<PaginationModel>;
|
||||
private layoutPresets = {};
|
||||
@@ -272,11 +252,6 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @deprecated 2.3.0 define it in pagination */
|
||||
get supportedPageSizes(): number[] {
|
||||
return this.preferences.getDefaultPageSizes();
|
||||
}
|
||||
|
||||
get hasCustomLayout(): boolean {
|
||||
return this.columnList && this.columnList.columns && this.columnList.columns.length > 0;
|
||||
}
|
||||
@@ -296,7 +271,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
|
||||
get pagination(): BehaviorSubject<PaginationModel> {
|
||||
if (!this._pagination) {
|
||||
let maxItems = this.maxItems || this.preferences.paginationSize;
|
||||
let maxItems = this.maxItems || this.preferences.paginationSize;
|
||||
let defaultPagination = <PaginationModel> {
|
||||
maxItems: maxItems,
|
||||
skipCount: 0,
|
||||
@@ -337,7 +312,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
ngOnInit() {
|
||||
this.rowMenuCache = {};
|
||||
this.loadLayoutPresets();
|
||||
this.data = new ShareDataTableAdapter(this.documentListService, this.thumbnailService, null, this.getDefaultSorting(), this.sortingMode);
|
||||
this.data = new ShareDataTableAdapter(this.documentListService, this.thumbnailService, this.contentService, null, this.getDefaultSorting(), this.sortingMode);
|
||||
this.data.thumbnails = this.thumbnails;
|
||||
this.data.permissionsStyle = this.permissionsStyle;
|
||||
|
||||
@@ -375,7 +350,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
}
|
||||
|
||||
if (!this.data) {
|
||||
this.data = new ShareDataTableAdapter(this.documentListService, this.thumbnailService, schema, this.getDefaultSorting(), this.sortingMode);
|
||||
this.data = new ShareDataTableAdapter(this.documentListService, this.thumbnailService, this.contentService, schema, this.getDefaultSorting(), this.sortingMode);
|
||||
} else if (schema && schema.length > 0) {
|
||||
this.data.setColumns(schema);
|
||||
}
|
||||
@@ -404,11 +379,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
}
|
||||
}
|
||||
|
||||
if (changes.folderNode && changes.folderNode.currentValue) {
|
||||
this.currentFolderId = changes.folderNode.currentValue.id;
|
||||
this.resetNewFolderPagination();
|
||||
this.loadFolder();
|
||||
} else if (changes.currentFolderId &&
|
||||
if (changes.currentFolderId &&
|
||||
changes.currentFolderId.currentValue &&
|
||||
changes.currentFolderId.currentValue !== changes.currentFolderId.previousValue) {
|
||||
this.resetNewFolderPagination();
|
||||
@@ -600,12 +571,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
this.setupDefaultColumns(this.currentFolderId);
|
||||
}
|
||||
|
||||
if (this.folderNode) {
|
||||
return this.loadFolderNodesByFolderNodeId(this.folderNode.id, this.pagination.getValue())
|
||||
.catch((err) => this.handleError(err));
|
||||
} else {
|
||||
this.loadFolderByNodeId(this.currentFolderId);
|
||||
}
|
||||
this.loadFolderByNodeId(this.currentFolderId);
|
||||
}
|
||||
|
||||
loadFolderByNodeId(nodeId: string) {
|
||||
|
@@ -15,10 +15,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { DataRow, ObjectUtils, ThumbnailService } from '@alfresco/adf-core';
|
||||
import { DataRow, ObjectUtils, ThumbnailService, ContentService } from '@alfresco/adf-core';
|
||||
import { MinimalNode, NodeEntry } from '@alfresco/js-api';
|
||||
import { PermissionStyleModel } from './../models/permissions-style.model';
|
||||
import { DocumentListService } from './../services/document-list.service';
|
||||
|
||||
export class ShareDataRow implements DataRow {
|
||||
|
||||
@@ -34,7 +33,7 @@ export class ShareDataRow implements DataRow {
|
||||
}
|
||||
|
||||
constructor(private obj: NodeEntry,
|
||||
private documentListService: DocumentListService,
|
||||
private contentService: ContentService,
|
||||
private permissionsStyle: PermissionStyleModel[],
|
||||
private thumbnailService?: ThumbnailService) {
|
||||
if (!obj) {
|
||||
@@ -55,7 +54,7 @@ export class ShareDataRow implements DataRow {
|
||||
|
||||
if (this.applyPermissionStyleToFolder(nodeEntity.entry, currentPermissionsStyle) || this.applyPermissionStyleToFile(nodeEntity.entry, currentPermissionsStyle)) {
|
||||
|
||||
if (this.documentListService.hasPermission(nodeEntity.entry, currentPermissionsStyle.permission)) {
|
||||
if (this.contentService.hasPermission(nodeEntity.entry, currentPermissionsStyle.permission)) {
|
||||
permissionsClasses += ` ${currentPermissionsStyle.css}`;
|
||||
}
|
||||
}
|
||||
@@ -74,7 +73,7 @@ export class ShareDataRow implements DataRow {
|
||||
}
|
||||
|
||||
isFolderAndHasPermissionToUpload(nodeEntry: NodeEntry): boolean {
|
||||
return this.isFolder(nodeEntry) && this.documentListService.hasPermission(nodeEntry.entry, 'create');
|
||||
return this.isFolder(nodeEntry) && this.contentService.hasPermission(nodeEntry.entry, 'create');
|
||||
}
|
||||
|
||||
isFolder(nodeEntry: NodeEntry): boolean {
|
||||
|
@@ -24,21 +24,22 @@ import { ShareDataTableAdapter } from './share-datatable-adapter';
|
||||
describe('ShareDataTableAdapter', () => {
|
||||
|
||||
let documentListService: DocumentListService;
|
||||
let contentService: ContentService;
|
||||
|
||||
beforeEach(() => {
|
||||
let imageUrl: string = 'http://<addresss>';
|
||||
let contentService = new ContentService(null, null, null, null);
|
||||
contentService = new ContentService(null, null, null, null);
|
||||
documentListService = new DocumentListService(null, contentService, null, null, null);
|
||||
spyOn(documentListService, 'getDocumentThumbnailUrl').and.returnValue(imageUrl);
|
||||
});
|
||||
|
||||
it('should use client sorting by default', () => {
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, []);
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, []);
|
||||
expect(adapter.sortingMode).toBe('client');
|
||||
});
|
||||
|
||||
it('should not be case sensitive for sorting mode value', () => {
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, []);
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, []);
|
||||
|
||||
adapter.sortingMode = 'CLIENT';
|
||||
expect(adapter.sortingMode).toBe('client');
|
||||
@@ -48,7 +49,7 @@ describe('ShareDataTableAdapter', () => {
|
||||
});
|
||||
|
||||
it('should fallback to client sorting for unknown values', () => {
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, []);
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, []);
|
||||
|
||||
adapter.sortingMode = 'SeRvEr';
|
||||
expect(adapter.sortingMode).toBe('server');
|
||||
@@ -59,27 +60,27 @@ describe('ShareDataTableAdapter', () => {
|
||||
|
||||
it('should setup rows and columns with constructor', () => {
|
||||
let schema = [<DataColumn> {}];
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, schema);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, schema);
|
||||
|
||||
expect(adapter.getRows()).toEqual([]);
|
||||
expect(adapter.getColumns()).toEqual(schema);
|
||||
});
|
||||
|
||||
it('should setup columns when constructor is missing schema', () => {
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
expect(adapter.getColumns()).toEqual([]);
|
||||
});
|
||||
|
||||
it('should set new columns', () => {
|
||||
let columns = [<DataColumn> {}, <DataColumn> {}];
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
adapter.setColumns(columns);
|
||||
expect(adapter.getColumns()).toEqual(columns);
|
||||
});
|
||||
|
||||
it('should reset columns', () => {
|
||||
let columns = [<DataColumn> {}, <DataColumn> {}];
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, columns);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, columns);
|
||||
|
||||
expect(adapter.getColumns()).toEqual(columns);
|
||||
adapter.setColumns(null);
|
||||
@@ -88,7 +89,7 @@ describe('ShareDataTableAdapter', () => {
|
||||
|
||||
it('should set new rows', () => {
|
||||
let rows = [<DataRow> {}, <DataRow> {}];
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
expect(adapter.getRows()).toEqual([]);
|
||||
adapter.setRows(rows);
|
||||
@@ -97,7 +98,7 @@ describe('ShareDataTableAdapter', () => {
|
||||
|
||||
it('should reset rows', () => {
|
||||
let rows = [<DataRow> {}, <DataRow> {}];
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
adapter.setRows(rows);
|
||||
expect(adapter.getRows()).toEqual(rows);
|
||||
@@ -107,7 +108,7 @@ describe('ShareDataTableAdapter', () => {
|
||||
});
|
||||
|
||||
it('should sort new rows', () => {
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
spyOn(adapter, 'sort').and.callThrough();
|
||||
|
||||
let rows = [<DataRow> {}];
|
||||
@@ -117,7 +118,7 @@ describe('ShareDataTableAdapter', () => {
|
||||
});
|
||||
|
||||
it('should fail when getting value for missing row', () => {
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
let check = () => {
|
||||
return adapter.getValue(null, <DataColumn> {});
|
||||
};
|
||||
@@ -125,7 +126,7 @@ describe('ShareDataTableAdapter', () => {
|
||||
});
|
||||
|
||||
it('should fail when getting value for missing column', () => {
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
let check = () => {
|
||||
return adapter.getValue(<DataRow> {}, null);
|
||||
};
|
||||
@@ -143,8 +144,8 @@ describe('ShareDataTableAdapter', () => {
|
||||
type: 'string'
|
||||
};
|
||||
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
expect(value).toBe(rawValue);
|
||||
@@ -153,12 +154,12 @@ describe('ShareDataTableAdapter', () => {
|
||||
it('should generate fallback icon for a file thumbnail with missing mime type', () => {
|
||||
spyOn(documentListService, 'getDefaultMimeTypeIcon').and.returnValue(`assets/images/ft_ic_miscellaneous.svg`);
|
||||
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let file = new FileNode();
|
||||
file.entry.content.mimeType = null;
|
||||
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
@@ -169,12 +170,12 @@ describe('ShareDataTableAdapter', () => {
|
||||
it('should generate fallback icon for a file with no content entry', () => {
|
||||
spyOn(documentListService, 'getDefaultMimeTypeIcon').and.returnValue(`assets/images/ft_ic_miscellaneous.svg`);
|
||||
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let file = new FileNode();
|
||||
file.entry.content = null;
|
||||
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
@@ -188,8 +189,8 @@ describe('ShareDataTableAdapter', () => {
|
||||
let file = new FileNode();
|
||||
file.entry['icon'] = imageUrl;
|
||||
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
let col = <DataColumn> { type: 'image', key: 'icon' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
@@ -199,9 +200,9 @@ describe('ShareDataTableAdapter', () => {
|
||||
it('should resolve folder icon', () => {
|
||||
spyOn(documentListService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_folder.svg`);
|
||||
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let row = new ShareDataRow(new FolderNode(), documentListService, null);
|
||||
let row = new ShareDataRow(new FolderNode(), contentService, null);
|
||||
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
@@ -212,9 +213,9 @@ describe('ShareDataTableAdapter', () => {
|
||||
it('should resolve smart folder icon', () => {
|
||||
spyOn(documentListService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_smart_folder.svg`);
|
||||
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let row = new ShareDataRow(new SmartFolderNode(), documentListService, null);
|
||||
let row = new ShareDataRow(new SmartFolderNode(), contentService, null);
|
||||
let col = <DataColumn> { type: 'folder', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
@@ -225,9 +226,9 @@ describe('ShareDataTableAdapter', () => {
|
||||
it('should resolve link folder icon', () => {
|
||||
spyOn(documentListService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_folder_shortcut_link.svg`);
|
||||
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let row = new ShareDataRow(new LinkFolderNode(), documentListService, null);
|
||||
let row = new ShareDataRow(new LinkFolderNode(), contentService, null);
|
||||
let col = <DataColumn> { type: 'folder', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
@@ -238,9 +239,9 @@ describe('ShareDataTableAdapter', () => {
|
||||
it('should resolve rule folder icon', () => {
|
||||
spyOn(documentListService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_folder_rule.svg`);
|
||||
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let row = new ShareDataRow(new RuleFolderNode(), documentListService, null);
|
||||
let row = new ShareDataRow(new RuleFolderNode(), contentService, null);
|
||||
let col = <DataColumn> { type: 'folder', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
@@ -250,11 +251,11 @@ describe('ShareDataTableAdapter', () => {
|
||||
|
||||
it('should resolve file thumbnail', () => {
|
||||
let imageUrl = 'http://<addresss>';
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
adapter.thumbnails = true;
|
||||
|
||||
let file = new FileNode();
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
@@ -265,14 +266,14 @@ describe('ShareDataTableAdapter', () => {
|
||||
it('should resolve fallback file icon for unknown node', () => {
|
||||
spyOn(documentListService, 'getDefaultMimeTypeIcon').and.returnValue(`assets/images/ft_ic_miscellaneous.svg`);
|
||||
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let file = new FileNode();
|
||||
file.entry.isFile = false;
|
||||
file.entry.isFolder = false;
|
||||
file.entry.content = null;
|
||||
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
@@ -282,14 +283,14 @@ describe('ShareDataTableAdapter', () => {
|
||||
|
||||
it('should resolve file icon for content type', () => {
|
||||
spyOn(documentListService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_raster_image.svg`);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let file = new FileNode();
|
||||
file.entry.isFile = false;
|
||||
file.entry.isFolder = false;
|
||||
file.entry.content.mimeType = 'image/png';
|
||||
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
@@ -303,13 +304,13 @@ describe('ShareDataTableAdapter', () => {
|
||||
let folder = new FolderNode();
|
||||
|
||||
let col = <DataColumn> { key: 'name' };
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, [col]);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, [col]);
|
||||
adapter.setSorting(new DataSorting('name', 'asc'));
|
||||
|
||||
adapter.setRows([
|
||||
new ShareDataRow(file2, documentListService, null),
|
||||
new ShareDataRow(file1, documentListService, null),
|
||||
new ShareDataRow(folder, documentListService, null)
|
||||
new ShareDataRow(file2, contentService, null),
|
||||
new ShareDataRow(file1, contentService, null),
|
||||
new ShareDataRow(folder, contentService, null)
|
||||
]);
|
||||
|
||||
let sorted = adapter.getRows();
|
||||
@@ -326,11 +327,11 @@ describe('ShareDataTableAdapter', () => {
|
||||
file2.entry['dateProp'] = new Date(2016, 6, 30, 13, 14, 2);
|
||||
|
||||
let col = <DataColumn> { key: 'dateProp' };
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, [col]);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, [col]);
|
||||
|
||||
adapter.setRows([
|
||||
new ShareDataRow(file2, documentListService, null),
|
||||
new ShareDataRow(file1, documentListService, null)
|
||||
new ShareDataRow(file2, contentService, null),
|
||||
new ShareDataRow(file1, contentService, null)
|
||||
]);
|
||||
|
||||
adapter.sort('dateProp', 'asc');
|
||||
@@ -356,13 +357,13 @@ describe('ShareDataTableAdapter', () => {
|
||||
file4.entry.content.sizeInBytes = 2852791665; // 2.66 GB
|
||||
|
||||
let col = <DataColumn> { key: 'content.sizeInBytes' };
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, [col]);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, [col]);
|
||||
|
||||
adapter.setRows([
|
||||
new ShareDataRow(file3, documentListService, null),
|
||||
new ShareDataRow(file4, documentListService, null),
|
||||
new ShareDataRow(file1, documentListService, null),
|
||||
new ShareDataRow(file2, documentListService, null)
|
||||
new ShareDataRow(file3, contentService, null),
|
||||
new ShareDataRow(file4, contentService, null),
|
||||
new ShareDataRow(file1, contentService, null),
|
||||
new ShareDataRow(file2, contentService, null)
|
||||
]);
|
||||
|
||||
adapter.sort('content.sizeInBytes', 'asc');
|
||||
@@ -389,15 +390,15 @@ describe('ShareDataTableAdapter', () => {
|
||||
let file6 = new FileNode('b');
|
||||
|
||||
let col = <DataColumn> { key: 'name' };
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, [col]);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, [col]);
|
||||
|
||||
adapter.setRows([
|
||||
new ShareDataRow(file4, documentListService, null),
|
||||
new ShareDataRow(file6, documentListService, null),
|
||||
new ShareDataRow(file3, documentListService, null),
|
||||
new ShareDataRow(file1, documentListService, null),
|
||||
new ShareDataRow(file2, documentListService, null),
|
||||
new ShareDataRow(file5, documentListService, null)
|
||||
new ShareDataRow(file4, contentService, null),
|
||||
new ShareDataRow(file6, contentService, null),
|
||||
new ShareDataRow(file3, contentService, null),
|
||||
new ShareDataRow(file1, contentService, null),
|
||||
new ShareDataRow(file2, contentService, null),
|
||||
new ShareDataRow(file5, contentService, null)
|
||||
]);
|
||||
|
||||
adapter.sort('name', 'asc');
|
||||
@@ -423,25 +424,25 @@ describe('ShareDataTableAdapter', () => {
|
||||
|
||||
it('should wrap node', () => {
|
||||
let file = new FileNode();
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
expect(row.node).toBe(file);
|
||||
});
|
||||
|
||||
it('should require object source', () => {
|
||||
expect(() => {
|
||||
return new ShareDataRow(null, documentListService, null);
|
||||
return new ShareDataRow(null, contentService, null);
|
||||
}).toThrowError(ShareDataRow.ERR_OBJECT_NOT_FOUND);
|
||||
});
|
||||
|
||||
it('should resolve value from node entry', () => {
|
||||
let file = new FileNode('test');
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
expect(row.getValue('name')).toBe('test');
|
||||
});
|
||||
|
||||
it('should check value', () => {
|
||||
let file = new FileNode('test');
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
|
||||
expect(row.hasValue('name')).toBeTruthy();
|
||||
expect(row.hasValue('missing')).toBeFalsy();
|
||||
@@ -450,21 +451,21 @@ describe('ShareDataTableAdapter', () => {
|
||||
it('should be set as drop target when user has permission for that node', () => {
|
||||
let file = new FolderNode('test');
|
||||
file.entry['allowableOperations'] = ['create'];
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
|
||||
expect(row.isDropTarget).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should not be set as drop target when user has permission for that node', () => {
|
||||
let file = new FolderNode('test');
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
|
||||
expect(row.isDropTarget).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should not be set as drop target when element is not a Folder', () => {
|
||||
let file = new FileNode('test');
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
|
||||
expect(row.isDropTarget).toBeFalsy();
|
||||
});
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { DataColumn, DataRow, DataSorting, DataTableAdapter, ThumbnailService } 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';
|
||||
@@ -52,6 +52,7 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
|
||||
constructor(private documentListService: DocumentListService,
|
||||
private thumbnailService: ThumbnailService,
|
||||
private contentService: ContentService,
|
||||
schema: DataColumn[] = [],
|
||||
sorting?: DataSorting,
|
||||
sortingMode: string = 'client') {
|
||||
@@ -241,7 +242,7 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
if (page && page.list) {
|
||||
let data = page.list.entries;
|
||||
if (data && data.length > 0) {
|
||||
rows = data.map((item) => new ShareDataRow(item, this.documentListService, this.permissionsStyle, this.thumbnailService));
|
||||
rows = data.map((item) => new ShareDataRow(item, this.contentService, this.permissionsStyle, this.thumbnailService));
|
||||
|
||||
if (this.filter) {
|
||||
rows = rows.filter(this.filter);
|
||||
|
@@ -16,8 +16,7 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
AlfrescoApiService, AuthenticationService, ContentService, LogService,
|
||||
PermissionsEnum, ThumbnailService
|
||||
AlfrescoApiService, AuthenticationService, ContentService, LogService, ThumbnailService
|
||||
} from '@alfresco/adf-core';
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
@@ -179,17 +178,6 @@ export class DocumentListService {
|
||||
return this.thumbnailService.getDefaultMimeTypeIcon();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a node has the specified permission.
|
||||
* @deprecated 2.3.0 - use the equivalent in the content service
|
||||
* @param node Target node
|
||||
* @param permission Permission level to query
|
||||
* @returns True if the node has the permission, false otherwise
|
||||
*/
|
||||
hasPermission(node: any, permission: PermissionsEnum | string): boolean {
|
||||
return this.contentService.hasPermission(node, permission);
|
||||
}
|
||||
|
||||
private handleError(error: any) {
|
||||
this.logService.error(error);
|
||||
return throwError(error || 'Server error');
|
||||
|
Reference in New Issue
Block a user