mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Repair unit tests
This commit is contained in:
@@ -51,5 +51,5 @@ export class DataSorting {
|
|||||||
|
|
||||||
export interface DataRowEvent {
|
export interface DataRowEvent {
|
||||||
value?: DataRow;
|
value?: DataRow;
|
||||||
event: Event;
|
event?: Event;
|
||||||
}
|
}
|
||||||
|
@@ -15,17 +15,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, it, expect } from '@angular/core/testing';
|
|
||||||
|
|
||||||
describe('ContentAction', () => {
|
|
||||||
|
|
||||||
it('should be upgraded', () => {
|
|
||||||
expect(false).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
|
||||||
import {
|
import {
|
||||||
it,
|
it,
|
||||||
describe,
|
describe,
|
||||||
@@ -35,7 +24,7 @@ import {
|
|||||||
import { EventEmitter } from '@angular/core';
|
import { EventEmitter } from '@angular/core';
|
||||||
|
|
||||||
import { DocumentList } from './document-list';
|
import { DocumentList } from './document-list';
|
||||||
import { AlfrescoServiceMock } from '../assets/alfresco.service.mock';
|
import { DocumentListServiceMock } from '../assets/document-list.service.mock';
|
||||||
import { ContentActionList } from './content-action-list';
|
import { ContentActionList } from './content-action-list';
|
||||||
import { ContentAction } from './content-action';
|
import { ContentAction } from './content-action';
|
||||||
import { DocumentActionsService } from '../services/document-actions.service';
|
import { DocumentActionsService } from '../services/document-actions.service';
|
||||||
@@ -51,11 +40,11 @@ describe('ContentAction', () => {
|
|||||||
let folderActions: FolderActionsService;
|
let folderActions: FolderActionsService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
let alfrescoServiceMock = new AlfrescoServiceMock();
|
let documentServiceMock = new DocumentListServiceMock();
|
||||||
documentActions = new DocumentActionsService(null, null);
|
documentActions = new DocumentActionsService(null, null);
|
||||||
folderActions = new FolderActionsService(null);
|
folderActions = new FolderActionsService(null);
|
||||||
|
|
||||||
documentList = new DocumentList(alfrescoServiceMock, null);
|
documentList = new DocumentList(documentServiceMock, null);
|
||||||
actionList = new ContentActionList(documentList);
|
actionList = new ContentActionList(documentList);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -70,7 +59,6 @@ describe('ContentAction', () => {
|
|||||||
|
|
||||||
it('should setup and register model', () => {
|
it('should setup and register model', () => {
|
||||||
let action = new ContentAction(actionList, null, null);
|
let action = new ContentAction(actionList, null, null);
|
||||||
action.type = 'button';
|
|
||||||
action.target = 'document';
|
action.target = 'document';
|
||||||
action.title = '<title>';
|
action.title = '<title>';
|
||||||
action.icon = '<icon>';
|
action.icon = '<icon>';
|
||||||
@@ -81,7 +69,6 @@ describe('ContentAction', () => {
|
|||||||
expect(documentList.actions.length).toBe(1);
|
expect(documentList.actions.length).toBe(1);
|
||||||
|
|
||||||
let model = documentList.actions[0];
|
let model = documentList.actions[0];
|
||||||
expect(model.type).toBe(action.type);
|
|
||||||
expect(model.target).toBe(action.target);
|
expect(model.target).toBe(action.target);
|
||||||
expect(model.title).toBe(action.title);
|
expect(model.title).toBe(action.title);
|
||||||
expect(model.icon).toBe(action.icon);
|
expect(model.icon).toBe(action.icon);
|
||||||
@@ -93,7 +80,6 @@ describe('ContentAction', () => {
|
|||||||
spyOn(documentActions, 'getHandler').and.returnValue(handler);
|
spyOn(documentActions, 'getHandler').and.returnValue(handler);
|
||||||
|
|
||||||
let action = new ContentAction(actionList, documentActions, null);
|
let action = new ContentAction(actionList, documentActions, null);
|
||||||
action.type = 'button';
|
|
||||||
action.target = 'document';
|
action.target = 'document';
|
||||||
action.handler = '<handler>';
|
action.handler = '<handler>';
|
||||||
action.ngOnInit();
|
action.ngOnInit();
|
||||||
@@ -110,7 +96,6 @@ describe('ContentAction', () => {
|
|||||||
spyOn(folderActions, 'getHandler').and.returnValue(handler);
|
spyOn(folderActions, 'getHandler').and.returnValue(handler);
|
||||||
|
|
||||||
let action = new ContentAction(actionList, null, folderActions);
|
let action = new ContentAction(actionList, null, folderActions);
|
||||||
action.type = 'button';
|
|
||||||
action.target = 'folder';
|
action.target = 'folder';
|
||||||
action.handler = '<handler>';
|
action.handler = '<handler>';
|
||||||
action.ngOnInit();
|
action.ngOnInit();
|
||||||
@@ -127,7 +112,6 @@ describe('ContentAction', () => {
|
|||||||
spyOn(documentActions, 'getHandler').and.stub();
|
spyOn(documentActions, 'getHandler').and.stub();
|
||||||
|
|
||||||
let action = new ContentAction(actionList, documentActions, folderActions);
|
let action = new ContentAction(actionList, documentActions, folderActions);
|
||||||
action.type = 'button';
|
|
||||||
action.handler = '<handler>';
|
action.handler = '<handler>';
|
||||||
|
|
||||||
action.ngOnInit();
|
action.ngOnInit();
|
||||||
@@ -149,7 +133,6 @@ describe('ContentAction', () => {
|
|||||||
|
|
||||||
let action = new ContentAction(actionList, documentActions, null);
|
let action = new ContentAction(actionList, documentActions, null);
|
||||||
action.target = 'DoCuMeNt';
|
action.target = 'DoCuMeNt';
|
||||||
action.type = 'button';
|
|
||||||
action.handler = '<handler>';
|
action.handler = '<handler>';
|
||||||
|
|
||||||
action.ngOnInit();
|
action.ngOnInit();
|
||||||
@@ -161,7 +144,6 @@ describe('ContentAction', () => {
|
|||||||
|
|
||||||
let action = new ContentAction(actionList, null, folderActions);
|
let action = new ContentAction(actionList, null, folderActions);
|
||||||
action.target = 'FoLdEr';
|
action.target = 'FoLdEr';
|
||||||
action.type = 'button';
|
|
||||||
action.handler = '<handler>';
|
action.handler = '<handler>';
|
||||||
|
|
||||||
action.ngOnInit();
|
action.ngOnInit();
|
||||||
@@ -178,7 +160,6 @@ describe('ContentAction', () => {
|
|||||||
|
|
||||||
let action = new ContentAction(actionList, null, null);
|
let action = new ContentAction(actionList, null, null);
|
||||||
action.target = 'document';
|
action.target = 'document';
|
||||||
action.type = 'button';
|
|
||||||
action.execute = emitter;
|
action.execute = emitter;
|
||||||
|
|
||||||
action.ngOnInit();
|
action.ngOnInit();
|
||||||
@@ -281,4 +262,3 @@ describe('ContentAction', () => {
|
|||||||
expect(action.register()).toBeFalsy();
|
expect(action.register()).toBeFalsy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
|
@@ -15,17 +15,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, it, expect } from '@angular/core/testing';
|
|
||||||
|
|
||||||
describe('ContentColumnList', () => {
|
|
||||||
|
|
||||||
it('should be upgraded', () => {
|
|
||||||
expect(false).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
|
||||||
import {
|
import {
|
||||||
it,
|
it,
|
||||||
describe,
|
describe,
|
||||||
@@ -33,10 +22,11 @@ import {
|
|||||||
beforeEach
|
beforeEach
|
||||||
} from '@angular/core/testing';
|
} from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { DataColumn } from 'ng2-alfresco-datatable';
|
||||||
|
|
||||||
import { DocumentList } from './document-list';
|
import { DocumentList } from './document-list';
|
||||||
import {AlfrescoServiceMock} from '../assets/alfresco.service.mock';
|
import { DocumentListServiceMock } from '../assets/document-list.service.mock';
|
||||||
import { ContentColumnList } from './content-column-list';
|
import { ContentColumnList } from './content-column-list';
|
||||||
import {ContentColumnModel} from '../models/content-column.model';
|
|
||||||
|
|
||||||
describe('ContentColumnList', () => {
|
describe('ContentColumnList', () => {
|
||||||
|
|
||||||
@@ -44,23 +34,26 @@ describe('ContentColumnList', () => {
|
|||||||
let columnList: ContentColumnList;
|
let columnList: ContentColumnList;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
let alfrescoServiceMock = new AlfrescoServiceMock();
|
let service = new DocumentListServiceMock();
|
||||||
documentList = new DocumentList(alfrescoServiceMock, null);
|
documentList = new DocumentList(service, null);
|
||||||
columnList = new ContentColumnList(documentList);
|
columnList = new ContentColumnList(documentList);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should register column within parent document list', () => {
|
it('should register column within parent document list', () => {
|
||||||
expect(documentList.columns.length).toBe(0);
|
let columns = documentList.data.getColumns();
|
||||||
|
expect(columns.length).toBe(0);
|
||||||
|
|
||||||
let result = columnList.registerColumn(new ContentColumnModel());
|
let column = <DataColumn> {};
|
||||||
|
let result = columnList.registerColumn(column);
|
||||||
|
|
||||||
expect(result).toBeTruthy();
|
expect(result).toBeTruthy();
|
||||||
expect(documentList.columns.length).toBe(1);
|
expect(columns.length).toBe(1);
|
||||||
|
expect(columns[0]).toBe(column);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should require document list instance to register action', () => {
|
it('should require document list instance to register action', () => {
|
||||||
columnList = new ContentColumnList(null);
|
columnList = new ContentColumnList(null);
|
||||||
let col = new ContentColumnModel();
|
let col = <DataColumn> {};
|
||||||
expect(columnList.registerColumn(col)).toBeFalsy();
|
expect(columnList.registerColumn(col)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -73,4 +66,3 @@ describe('ContentColumnList', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
|
@@ -15,17 +15,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, it, expect } from '@angular/core/testing';
|
|
||||||
|
|
||||||
describe('ContentColumn', () => {
|
|
||||||
|
|
||||||
it('should be upgraded', () => {
|
|
||||||
expect(false).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
|
||||||
import {
|
import {
|
||||||
it,
|
it,
|
||||||
describe,
|
describe,
|
||||||
@@ -35,7 +24,7 @@ import {
|
|||||||
|
|
||||||
import { DocumentList } from './document-list';
|
import { DocumentList } from './document-list';
|
||||||
import { ContentColumn } from './content-column';
|
import { ContentColumn } from './content-column';
|
||||||
import {AlfrescoServiceMock} from '../assets/alfresco.service.mock';
|
import { DocumentListServiceMock } from '../assets/document-list.service.mock';
|
||||||
import { ContentColumnList } from './content-column-list';
|
import { ContentColumnList } from './content-column-list';
|
||||||
|
|
||||||
describe('ContentColumn', () => {
|
describe('ContentColumn', () => {
|
||||||
@@ -44,8 +33,8 @@ describe('ContentColumn', () => {
|
|||||||
let columnList: ContentColumnList;
|
let columnList: ContentColumnList;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
let alfrescoServiceMock = new AlfrescoServiceMock();
|
let service = new DocumentListServiceMock();
|
||||||
documentList = new DocumentList(alfrescoServiceMock, null);
|
documentList = new DocumentList(service, null);
|
||||||
columnList = new ContentColumnList(documentList);
|
columnList = new ContentColumnList(documentList);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -56,52 +45,19 @@ describe('ContentColumn', () => {
|
|||||||
column.ngOnInit();
|
column.ngOnInit();
|
||||||
|
|
||||||
expect(columnList.registerColumn).toHaveBeenCalled();
|
expect(columnList.registerColumn).toHaveBeenCalled();
|
||||||
});
|
|
||||||
|
|
||||||
it('should setup model properties during registration', () => {
|
let columns = documentList.data.getColumns();
|
||||||
|
expect(columns.length).toBe(1);
|
||||||
let column = new ContentColumn(columnList);
|
expect(columns[0]).toBe(column);
|
||||||
column.title = '<title>';
|
|
||||||
column.srTitle = '<sr-title>';
|
|
||||||
column.source = '<source>';
|
|
||||||
column.cssClass = '<css-class>';
|
|
||||||
column.ngOnInit();
|
|
||||||
|
|
||||||
expect(documentList.columns.length).toBe(1);
|
|
||||||
|
|
||||||
let model = documentList.columns[0];
|
|
||||||
expect(model.title).toBe(column.title);
|
|
||||||
expect(model.srTitle).toBe(column.srTitle);
|
|
||||||
expect(model.source).toBe(column.source);
|
|
||||||
expect(model.cssClass).toBe(column.cssClass);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should setup screen reader title for thumbnail column', () => {
|
it('should setup screen reader title for thumbnail column', () => {
|
||||||
|
let column = new ContentColumn(columnList, {
|
||||||
let column = new ContentColumn(columnList);
|
key: '$thumbnail'
|
||||||
column.source = '$thumbnail';
|
|
||||||
column.ngOnInit();
|
|
||||||
|
|
||||||
expect(documentList.columns.length).toBe(1);
|
|
||||||
|
|
||||||
let model = documentList.columns[0];
|
|
||||||
expect(model.srTitle).toBe('Thumbnail');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should sync localizable fields with model', () => {
|
|
||||||
|
|
||||||
let column = new ContentColumn(columnList);
|
|
||||||
column.title = 'title1';
|
|
||||||
column.srTitle = 'srTitle1';
|
|
||||||
column.ngOnInit();
|
column.ngOnInit();
|
||||||
|
|
||||||
expect(column.model.title).toBe(column.title);
|
expect(column.srTitle).toBe('Thumbnail');
|
||||||
expect(column.model.srTitle).toBe(column.srTitle);
|
|
||||||
|
|
||||||
column.title = 'title2';
|
|
||||||
column.ngOnChanges(null);
|
|
||||||
|
|
||||||
expect(column.model.title).toBe('title2');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should register on init', () => {
|
it('should register on init', () => {
|
||||||
@@ -121,4 +77,3 @@ describe('ContentColumn', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
|
@@ -49,7 +49,17 @@ export class ContentColumn implements OnInit, DataColumn {
|
|||||||
@Input('class')
|
@Input('class')
|
||||||
cssClass: string;
|
cssClass: string;
|
||||||
|
|
||||||
constructor(private list: ContentColumnList) {}
|
constructor(private list: ContentColumnList, opts?: any) {
|
||||||
|
if (opts) {
|
||||||
|
this.key = opts.key;
|
||||||
|
this.type = opts.type || 'text';
|
||||||
|
this.format = opts.format;
|
||||||
|
this.sortable = opts.sortable ? true : false;
|
||||||
|
this.title = opts.title || '';
|
||||||
|
this.srTitle = opts.srTitle;
|
||||||
|
this.cssClass = opts.cssClass;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (!this.srTitle && this.key === '$thumbnail') {
|
if (!this.srTitle && this.key === '$thumbnail') {
|
||||||
|
@@ -15,46 +15,26 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, it, expect } from '@angular/core/testing';
|
import { it, describe, expect, beforeEach } from '@angular/core/testing';
|
||||||
|
|
||||||
describe('DocumentList', () => {
|
|
||||||
|
|
||||||
it('should be upgraded', () => {
|
|
||||||
expect(false).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
|
||||||
import {
|
|
||||||
it,
|
|
||||||
describe,
|
|
||||||
expect,
|
|
||||||
beforeEach
|
|
||||||
} from '@angular/core/testing';
|
|
||||||
import { NgZone } from '@angular/core';
|
import { NgZone } from '@angular/core';
|
||||||
|
import { DataColumn } from 'ng2-alfresco-datatable';
|
||||||
import { DocumentList } from './document-list';
|
import { DocumentList } from './document-list';
|
||||||
import { ContentColumnModel } from '../models/content-column.model';
|
import { DocumentListServiceMock } from './../assets/document-list.service.mock';
|
||||||
import { AlfrescoServiceMock } from '../assets/alfresco.service.mock';
|
|
||||||
import { ContentActionModel } from '../models/content-action.model';
|
import { ContentActionModel } from '../models/content-action.model';
|
||||||
import {
|
import { FileNode, FolderNode } from '../assets/document-library.model.mock';
|
||||||
PageNode,
|
import { MinimalNodeEntity } from '../models/document-library.model';
|
||||||
FileNode,
|
|
||||||
FolderNode
|
|
||||||
} from '../assets/document-library.model.mock';
|
|
||||||
import { ColumnSortingModel } from '../models/column-sorting.model';
|
|
||||||
|
|
||||||
describe('DocumentList', () => {
|
describe('DocumentList', () => {
|
||||||
|
|
||||||
let alfrescoServiceMock: AlfrescoServiceMock;
|
let documentListService: DocumentListServiceMock;
|
||||||
let documentList: DocumentList;
|
let documentList: DocumentList;
|
||||||
let eventMock: any;
|
let eventMock: any;
|
||||||
let componentHandler;
|
let componentHandler;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
alfrescoServiceMock = new AlfrescoServiceMock();
|
documentListService = new DocumentListServiceMock();
|
||||||
let zone = new NgZone(false);
|
let zone = new NgZone(false);
|
||||||
documentList = new DocumentList(alfrescoServiceMock, zone);
|
documentList = new DocumentList(documentListService, zone);
|
||||||
|
|
||||||
eventMock = {
|
eventMock = {
|
||||||
preventDefault: function () {
|
preventDefault: function () {
|
||||||
@@ -74,56 +54,67 @@ describe('DocumentList', () => {
|
|||||||
documentList.ngAfterContentInit();
|
documentList.ngAfterContentInit();
|
||||||
|
|
||||||
expect(documentList.setupDefaultColumns).toHaveBeenCalled();
|
expect(documentList.setupDefaultColumns).toHaveBeenCalled();
|
||||||
expect(documentList.columns.length).not.toBe(0);
|
expect(documentList.data.getColumns().length).not.toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use custom columns instead of default ones', () => {
|
it('should use custom columns instead of default ones', () => {
|
||||||
let column: ContentColumnModel = {
|
let column = <DataColumn> {
|
||||||
title: 'title',
|
title: 'title',
|
||||||
source: 'source',
|
key: 'source',
|
||||||
cssClass: 'css',
|
cssClass: 'css',
|
||||||
srTitle: '',
|
srTitle: '',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
format: ''
|
format: ''
|
||||||
};
|
};
|
||||||
documentList.columns.push(column);
|
|
||||||
|
let columns = documentList.data.getColumns();
|
||||||
|
columns.push(column);
|
||||||
|
|
||||||
documentList.ngAfterContentInit();
|
documentList.ngAfterContentInit();
|
||||||
expect(documentList.columns.length).toBe(1);
|
expect(columns.length).toBe(1);
|
||||||
expect(documentList.columns[0]).toBe(column);
|
expect(columns[0]).toBe(column);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO: move to data adapter
|
||||||
|
/*
|
||||||
it('should fetch folder', () => {
|
it('should fetch folder', () => {
|
||||||
let folder = {
|
let folder = {
|
||||||
'nodeRef': 'workspace://SpacesStore/8bb36efb-c26d-4d2b-9199-ab6922f53c28'
|
'nodeRef': 'workspace://SpacesStore/8bb36efb-c26d-4d2b-9199-ab6922f53c28'
|
||||||
};
|
};
|
||||||
alfrescoServiceMock.folderToReturn = folder;
|
documentListService.folderToReturn = folder;
|
||||||
documentList.ngOnInit();
|
documentList.ngOnInit();
|
||||||
|
|
||||||
expect(documentList.folder).toBe(folder);
|
expect(documentList.folder).toBe(folder);
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO: move to data adapter
|
||||||
|
/*
|
||||||
it('should return thumbnail url for a file when thumbnails turned on', () => {
|
it('should return thumbnail url for a file when thumbnails turned on', () => {
|
||||||
let url = 'URL';
|
let url = 'URL';
|
||||||
spyOn(alfrescoServiceMock, 'getDocumentThumbnailUrl').and.returnValue(url);
|
spyOn(documentListService, 'getDocumentThumbnailUrl').and.returnValue(url);
|
||||||
|
|
||||||
let node = new FileNode();
|
let node = new FileNode();
|
||||||
documentList.thumbnails = true;
|
documentList.thumbnails = true;
|
||||||
let result = documentList.getThumbnailUrl(node);
|
let result = documentList.getThumbnailUrl(node);
|
||||||
|
|
||||||
expect(result).toBe(url);
|
expect(result).toBe(url);
|
||||||
expect(alfrescoServiceMock.getDocumentThumbnailUrl).toHaveBeenCalled();
|
expect(documentListService.getDocumentThumbnailUrl).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO: move to data adapter
|
||||||
|
/*
|
||||||
it('should return a null thumbnail url for a null item', () => {
|
it('should return a null thumbnail url for a null item', () => {
|
||||||
let url = 'URL';
|
let url = 'URL';
|
||||||
spyOn(alfrescoServiceMock, 'getDocumentThumbnailUrl').and.returnValue(url);
|
spyOn(documentListService, 'getDocumentThumbnailUrl').and.returnValue(url);
|
||||||
|
|
||||||
let result = documentList.getThumbnailUrl(null);
|
let result = documentList.getThumbnailUrl(null);
|
||||||
|
|
||||||
expect(result).toBeNull();
|
expect(result).toBeNull();
|
||||||
expect(alfrescoServiceMock.getDocumentThumbnailUrl).not.toHaveBeenCalled();
|
expect(documentListService.getDocumentThumbnailUrl).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
it('should execute action with node', () => {
|
it('should execute action with node', () => {
|
||||||
let node = new FileNode();
|
let node = new FileNode();
|
||||||
@@ -150,100 +141,54 @@ describe('DocumentList', () => {
|
|||||||
expect(action.handler).not.toHaveBeenCalled();
|
expect(action.handler).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should give no content actions for empty target', () => {
|
it('should not give node actions for empty target', () => {
|
||||||
let actions = documentList.getContentActions(null, 'button');
|
let actions = documentList.getNodeActions(null);
|
||||||
expect(actions.length).toBe(0);
|
expect(actions.length).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should give no content actions for empty type', () => {
|
it('should filter content actions for various targets', () => {
|
||||||
let actions = documentList.getContentActions('folder', null);
|
|
||||||
expect(actions.length).toBe(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should filter content actions for various types and targets', () => {
|
|
||||||
let folderButton = new ContentActionModel();
|
|
||||||
folderButton.target = 'folder';
|
|
||||||
folderButton.type = 'button';
|
|
||||||
|
|
||||||
let folderMenu = new ContentActionModel();
|
let folderMenu = new ContentActionModel();
|
||||||
folderMenu.target = 'folder';
|
folderMenu.target = 'folder';
|
||||||
folderMenu.type = 'menu';
|
|
||||||
|
|
||||||
let documentButton = new ContentActionModel();
|
|
||||||
documentButton.target = 'document';
|
|
||||||
documentButton.type = 'button';
|
|
||||||
|
|
||||||
let documentMenu = new ContentActionModel();
|
let documentMenu = new ContentActionModel();
|
||||||
documentMenu.target = 'document';
|
documentMenu.target = 'document';
|
||||||
documentMenu.type = 'menu';
|
|
||||||
|
|
||||||
documentList.actions = [
|
documentList.actions = [
|
||||||
folderButton,
|
|
||||||
folderMenu,
|
folderMenu,
|
||||||
documentButton,
|
|
||||||
documentMenu
|
documentMenu
|
||||||
];
|
];
|
||||||
|
|
||||||
let actions = documentList.getContentActions('folder', 'button');
|
|
||||||
expect(actions.length).toBe(1);
|
|
||||||
expect(actions[0]).toBe(folderButton);
|
|
||||||
|
|
||||||
actions = documentList.getContentActions('folder', 'menu');
|
let actions = documentList.getNodeActions(new FolderNode());
|
||||||
expect(actions.length).toBe(1);
|
expect(actions.length).toBe(1);
|
||||||
expect(actions[0]).toBe(folderMenu);
|
expect(actions[0]).toBe(folderMenu);
|
||||||
|
|
||||||
actions = documentList.getContentActions('document', 'button');
|
actions = documentList.getNodeActions(new FileNode());
|
||||||
expect(actions.length).toBe(1);
|
|
||||||
expect(actions[0]).toBe(documentButton);
|
|
||||||
|
|
||||||
actions = documentList.getContentActions('document', 'menu');
|
|
||||||
expect(actions.length).toBe(1);
|
expect(actions.length).toBe(1);
|
||||||
expect(actions[0]).toBe(documentMenu);
|
expect(actions[0]).toBe(documentMenu);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be case insensitive when filtering content actions', () => {
|
|
||||||
let documentButton = new ContentActionModel();
|
|
||||||
documentButton.target = 'document';
|
|
||||||
documentButton.type = 'button';
|
|
||||||
|
|
||||||
documentList.actions = [documentButton];
|
|
||||||
|
|
||||||
let actions = documentList.getContentActions('DoCuMeNt', 'BUTTON');
|
|
||||||
expect(actions.length).toBe(1);
|
|
||||||
expect(actions[0]).toBe(documentButton);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should find no content actions', () => {
|
it('should find no content actions', () => {
|
||||||
let documentButton = new ContentActionModel();
|
let documentButton = new ContentActionModel();
|
||||||
documentButton.target = 'document';
|
documentButton.target = 'document';
|
||||||
documentButton.type = 'button';
|
|
||||||
|
|
||||||
documentList.actions = [documentButton];
|
documentList.actions = [documentButton];
|
||||||
|
|
||||||
let actions = documentList.getContentActions('unknown', 'value');
|
let node = new MinimalNodeEntity();
|
||||||
expect(actions.length).toBe(0);
|
expect(documentList.getNodeActions(node)).toEqual([]);
|
||||||
|
|
||||||
|
node = new FileNode();
|
||||||
|
node.entry.isFile = false;
|
||||||
|
node.entry.isFolder = false;
|
||||||
|
expect(documentList.getNodeActions(node)).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should emit itemClick event', (done) => {
|
it('should emit nodeClick event', (done) => {
|
||||||
let node = new FileNode();
|
let node = new FileNode();
|
||||||
documentList.itemClick.subscribe(e => {
|
documentList.nodeClick.subscribe(e => {
|
||||||
expect(e.value).toBe(node);
|
expect(e.value).toBe(node);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
documentList.onItemClick(node);
|
documentList.onNodeClick(node);
|
||||||
});
|
|
||||||
|
|
||||||
it('should prevent default item single click event', () => {
|
|
||||||
spyOn(eventMock, 'preventDefault').and.stub();
|
|
||||||
|
|
||||||
documentList.onItemClick(null, eventMock);
|
|
||||||
expect(eventMock.preventDefault).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should prevent default item double click event', () => {
|
|
||||||
spyOn(eventMock, 'preventDefault').and.stub();
|
|
||||||
documentList.onItemDblClick(null, eventMock);
|
|
||||||
expect(eventMock.preventDefault).toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display folder content on click', () => {
|
it('should display folder content on click', () => {
|
||||||
@@ -255,7 +200,7 @@ describe('DocumentList', () => {
|
|||||||
spyOn(documentList, 'displayFolderContent').and.stub();
|
spyOn(documentList, 'displayFolderContent').and.stub();
|
||||||
|
|
||||||
documentList.navigationMode = DocumentList.SINGLE_CLICK_NAVIGATION;
|
documentList.navigationMode = DocumentList.SINGLE_CLICK_NAVIGATION;
|
||||||
documentList.onItemClick(node);
|
documentList.onNodeClick(node);
|
||||||
|
|
||||||
expect(documentList.currentFolderPath).toBe(path);
|
expect(documentList.currentFolderPath).toBe(path);
|
||||||
});
|
});
|
||||||
@@ -264,7 +209,7 @@ describe('DocumentList', () => {
|
|||||||
expect(documentList.navigate).toBe(true);
|
expect(documentList.navigate).toBe(true);
|
||||||
spyOn(documentList, 'displayFolderContent').and.stub();
|
spyOn(documentList, 'displayFolderContent').and.stub();
|
||||||
|
|
||||||
documentList.onItemClick(null);
|
documentList.onNodeClick(null);
|
||||||
expect(documentList.displayFolderContent).not.toHaveBeenCalled();
|
expect(documentList.displayFolderContent).not.toHaveBeenCalled();
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -274,7 +219,7 @@ describe('DocumentList', () => {
|
|||||||
spyOn(documentList, 'displayFolderContent').and.stub();
|
spyOn(documentList, 'displayFolderContent').and.stub();
|
||||||
|
|
||||||
let node = new FileNode();
|
let node = new FileNode();
|
||||||
documentList.onItemClick(node);
|
documentList.onNodeClick(node);
|
||||||
|
|
||||||
expect(documentList.displayFolderContent).not.toHaveBeenCalled();
|
expect(documentList.displayFolderContent).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@@ -284,7 +229,7 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
let node = new FolderNode('<display name>');
|
let node = new FolderNode('<display name>');
|
||||||
documentList.navigate = false;
|
documentList.navigate = false;
|
||||||
documentList.onItemClick(node);
|
documentList.onNodeClick(node);
|
||||||
|
|
||||||
expect(documentList.displayFolderContent).not.toHaveBeenCalled();
|
expect(documentList.displayFolderContent).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@@ -293,33 +238,6 @@ describe('DocumentList', () => {
|
|||||||
expect(documentList.getNodePath(null)).toBe(null);
|
expect(documentList.getNodePath(null)).toBe(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return root object value', () => {
|
|
||||||
let target = {
|
|
||||||
key1: 'value1'
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(documentList.getObjectValue(target, 'key1')).toBe('value1');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return no object value when key is missing', () => {
|
|
||||||
let target = {
|
|
||||||
key1: 'value1'
|
|
||||||
};
|
|
||||||
expect(documentList.getObjectValue(target, 'missing')).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return nested object value', () => {
|
|
||||||
let target = {
|
|
||||||
key1: {
|
|
||||||
key2: {
|
|
||||||
key3: 'value1'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(documentList.getObjectValue(target, 'key1.key2.key3')).toBe('value1');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should display folder content for new folder path', () => {
|
it('should display folder content for new folder path', () => {
|
||||||
spyOn(documentList, 'displayFolderContent').and.stub();
|
spyOn(documentList, 'displayFolderContent').and.stub();
|
||||||
let newPath = '/some/new/path';
|
let newPath = '/some/new/path';
|
||||||
@@ -345,42 +263,44 @@ describe('DocumentList', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should emit folder changed event', (done) => {
|
it('should emit folder changed event', (done) => {
|
||||||
|
spyOn(documentList, 'displayFolderContent').and.stub();
|
||||||
documentList.folderChange.subscribe(e => {
|
documentList.folderChange.subscribe(e => {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
documentList.folder = new PageNode();
|
|
||||||
|
documentList.currentFolderPath = '/some/new/path';
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should emit folder changed event with folder details', (done) => {
|
it('should emit folder changed event with folder details', (done) => {
|
||||||
let folder = new PageNode();
|
spyOn(documentList, 'displayFolderContent').and.stub();
|
||||||
|
|
||||||
let path = '/path';
|
let path = '/path';
|
||||||
|
|
||||||
documentList.folderChange.subscribe(e => {
|
documentList.folderChange.subscribe(e => {
|
||||||
expect(e.value).toBe(folder);
|
|
||||||
expect(e.path).toBe(path);
|
expect(e.path).toBe(path);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
spyOn(documentList, 'displayFolderContent').and.stub();
|
|
||||||
documentList.currentFolderPath = path;
|
documentList.currentFolderPath = path;
|
||||||
documentList.folder = folder;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not emit folder changed event', () => {
|
it('should emit folder changed event only once', () => {
|
||||||
let folder = new PageNode();
|
spyOn(documentList, 'displayFolderContent').and.stub();
|
||||||
|
let path = '/new/path';
|
||||||
let calls = 0;
|
let calls = 0;
|
||||||
documentList.folderChange.subscribe(e => {
|
documentList.folderChange.subscribe(e => {
|
||||||
calls++;
|
calls++;
|
||||||
});
|
});
|
||||||
|
|
||||||
documentList.folder = folder;
|
documentList.currentFolderPath = path;
|
||||||
documentList.folder = folder;
|
documentList.currentFolderPath = path;
|
||||||
|
documentList.currentFolderPath = path;
|
||||||
expect(calls).toBe(1);
|
expect(calls).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reload on binding changes', () => {
|
it('should reload on binding changes', () => {
|
||||||
spyOn(documentList, 'reload').and.stub();
|
spyOn(documentList, 'reload').and.stub();
|
||||||
documentList.ngOnChanges(null);
|
documentList.ngOnChanges();
|
||||||
expect(documentList.reload).toHaveBeenCalled();
|
expect(documentList.reload).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -407,8 +327,9 @@ describe('DocumentList', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should subscribe to context action handler', () => {
|
it('should subscribe to context action handler', () => {
|
||||||
let value = {};
|
spyOn(documentList, 'displayFolderContent').and.stub();
|
||||||
spyOn(documentList, 'contextActionCallback').and.stub();
|
spyOn(documentList, 'contextActionCallback').and.stub();
|
||||||
|
let value = {};
|
||||||
documentList.ngOnInit();
|
documentList.ngOnInit();
|
||||||
documentList.contextActionHandler.next(value);
|
documentList.contextActionHandler.next(value);
|
||||||
expect(documentList.contextActionCallback).toHaveBeenCalledWith(value);
|
expect(documentList.contextActionCallback).toHaveBeenCalledWith(value);
|
||||||
@@ -427,7 +348,7 @@ describe('DocumentList', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
documentList.navigationMode = DocumentList.SINGLE_CLICK_NAVIGATION;
|
documentList.navigationMode = DocumentList.SINGLE_CLICK_NAVIGATION;
|
||||||
documentList.onItemClick(file, null);
|
documentList.onNodeClick(file);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should emit file preview event on double click', (done) => {
|
it('should emit file preview event on double click', (done) => {
|
||||||
@@ -437,7 +358,7 @@ describe('DocumentList', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
documentList.navigationMode = DocumentList.DOUBLE_CLICK_NAVIGATION;
|
documentList.navigationMode = DocumentList.DOUBLE_CLICK_NAVIGATION;
|
||||||
documentList.onItemDblClick(file, null);
|
documentList.onNodeDblClick(file);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should perform folder navigation on single click', () => {
|
it('should perform folder navigation on single click', () => {
|
||||||
@@ -445,7 +366,7 @@ describe('DocumentList', () => {
|
|||||||
spyOn(documentList, 'performNavigation').and.stub();
|
spyOn(documentList, 'performNavigation').and.stub();
|
||||||
|
|
||||||
documentList.navigationMode = DocumentList.SINGLE_CLICK_NAVIGATION;
|
documentList.navigationMode = DocumentList.SINGLE_CLICK_NAVIGATION;
|
||||||
documentList.onItemClick(folder, null);
|
documentList.onNodeClick(folder);
|
||||||
expect(documentList.performNavigation).toHaveBeenCalled();
|
expect(documentList.performNavigation).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -454,7 +375,7 @@ describe('DocumentList', () => {
|
|||||||
spyOn(documentList, 'performNavigation').and.stub();
|
spyOn(documentList, 'performNavigation').and.stub();
|
||||||
|
|
||||||
documentList.navigationMode = DocumentList.DOUBLE_CLICK_NAVIGATION;
|
documentList.navigationMode = DocumentList.DOUBLE_CLICK_NAVIGATION;
|
||||||
documentList.onItemDblClick(folder, null);
|
documentList.onNodeDblClick(folder);
|
||||||
expect(documentList.performNavigation).toHaveBeenCalled();
|
expect(documentList.performNavigation).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -463,7 +384,7 @@ describe('DocumentList', () => {
|
|||||||
spyOn(documentList, 'performNavigation').and.stub();
|
spyOn(documentList, 'performNavigation').and.stub();
|
||||||
|
|
||||||
documentList.navigationMode = DocumentList.SINGLE_CLICK_NAVIGATION;
|
documentList.navigationMode = DocumentList.SINGLE_CLICK_NAVIGATION;
|
||||||
documentList.onItemDblClick(folder, null);
|
documentList.onNodeDblClick(folder);
|
||||||
|
|
||||||
expect(documentList.performNavigation).not.toHaveBeenCalled();
|
expect(documentList.performNavigation).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@@ -474,15 +395,16 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
documentList.navigate = false;
|
documentList.navigate = false;
|
||||||
documentList.navigationMode = DocumentList.DOUBLE_CLICK_NAVIGATION;
|
documentList.navigationMode = DocumentList.DOUBLE_CLICK_NAVIGATION;
|
||||||
documentList.onItemDblClick(folder, null);
|
documentList.onNodeDblClick(folder);
|
||||||
|
|
||||||
expect(documentList.performNavigation).not.toHaveBeenCalled();
|
expect(documentList.performNavigation).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should perform navigation for folder node only', () => {
|
it('should perform navigation for folder node only', () => {
|
||||||
|
spyOn(documentList, 'getNodePath').and.returnValue('/path');
|
||||||
|
|
||||||
let folder = new FolderNode();
|
let folder = new FolderNode();
|
||||||
let file = new FileNode();
|
let file = new FileNode();
|
||||||
spyOn(documentList, 'getNodePath').and.returnValue('/path');
|
|
||||||
|
|
||||||
expect(documentList.performNavigation(folder)).toBeTruthy();
|
expect(documentList.performNavigation(folder)).toBeTruthy();
|
||||||
expect(documentList.performNavigation(file)).toBeFalsy();
|
expect(documentList.performNavigation(file)).toBeFalsy();
|
||||||
@@ -499,7 +421,6 @@ describe('DocumentList', () => {
|
|||||||
expect(documentList.getNodePath(file)).toBe('/folder1/file.txt');
|
expect(documentList.getNodePath(file)).toBe('/folder1/file.txt');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should require valid node for file preview', () => {
|
it('should require valid node for file preview', () => {
|
||||||
let file = new FileNode();
|
let file = new FileNode();
|
||||||
file.entry = null;
|
file.entry = null;
|
||||||
@@ -508,11 +429,11 @@ describe('DocumentList', () => {
|
|||||||
documentList.navigationMode = DocumentList.SINGLE_CLICK_NAVIGATION;
|
documentList.navigationMode = DocumentList.SINGLE_CLICK_NAVIGATION;
|
||||||
documentList.preview.subscribe(val => called = true);
|
documentList.preview.subscribe(val => called = true);
|
||||||
|
|
||||||
documentList.onItemClick(file, null);
|
documentList.onNodeClick(file);
|
||||||
expect(called).toBeFalsy();
|
expect(called).toBeFalsy();
|
||||||
|
|
||||||
documentList.navigationMode = DocumentList.DOUBLE_CLICK_NAVIGATION;
|
documentList.navigationMode = DocumentList.DOUBLE_CLICK_NAVIGATION;
|
||||||
documentList.onItemDblClick(file, null);
|
documentList.onNodeDblClick(file);
|
||||||
expect(called).toBeFalsy();
|
expect(called).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -522,10 +443,10 @@ describe('DocumentList', () => {
|
|||||||
spyOn(documentList, 'performNavigation').and.stub();
|
spyOn(documentList, 'performNavigation').and.stub();
|
||||||
|
|
||||||
documentList.navigationMode = DocumentList.SINGLE_CLICK_NAVIGATION;
|
documentList.navigationMode = DocumentList.SINGLE_CLICK_NAVIGATION;
|
||||||
documentList.onItemClick(folder, null);
|
documentList.onNodeClick(folder);
|
||||||
|
|
||||||
documentList.navigationMode = DocumentList.DOUBLE_CLICK_NAVIGATION;
|
documentList.navigationMode = DocumentList.DOUBLE_CLICK_NAVIGATION;
|
||||||
documentList.onItemDblClick(folder, null);
|
documentList.onNodeDblClick(folder);
|
||||||
|
|
||||||
expect(documentList.performNavigation).not.toHaveBeenCalled();
|
expect(documentList.performNavigation).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@@ -536,6 +457,8 @@ describe('DocumentList', () => {
|
|||||||
expect(documentList.displayFolderContent).toHaveBeenCalled();
|
expect(documentList.displayFolderContent).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO: move to data adapter
|
||||||
|
/*
|
||||||
it('should generate thumbnail for unknown content', () => {
|
it('should generate thumbnail for unknown content', () => {
|
||||||
documentList.baseComponentPath = '/root';
|
documentList.baseComponentPath = '/root';
|
||||||
let node = new FileNode();
|
let node = new FileNode();
|
||||||
@@ -543,13 +466,19 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
expect(documentList.getThumbnailUrl(node)).toBe('/root/img/ft_ic_miscellaneous.svg');
|
expect(documentList.getThumbnailUrl(node)).toBe('/root/img/ft_ic_miscellaneous.svg');
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO: move to data adapter
|
||||||
|
/*
|
||||||
it('should generate folder icon path', () => {
|
it('should generate folder icon path', () => {
|
||||||
documentList.baseComponentPath = '/root';
|
documentList.baseComponentPath = '/root';
|
||||||
let folder = new FolderNode();
|
let folder = new FolderNode();
|
||||||
expect(documentList.getThumbnailUrl(folder)).toBe('/root/img/ft_ic_folder.svg');
|
expect(documentList.getThumbnailUrl(folder)).toBe('/root/img/ft_ic_folder.svg');
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO: move to data adapter
|
||||||
|
/*
|
||||||
it('should generate file icon path based on mime type', () => {
|
it('should generate file icon path based on mime type', () => {
|
||||||
let fileName = 'custom-icon.svg';
|
let fileName = 'custom-icon.svg';
|
||||||
spyOn(alfrescoServiceMock, 'getMimeTypeIcon').and.returnValue(fileName);
|
spyOn(alfrescoServiceMock, 'getMimeTypeIcon').and.returnValue(fileName);
|
||||||
@@ -560,9 +489,12 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
expect(documentList.getThumbnailUrl(file)).toBe(`/root/img/${fileName}`);
|
expect(documentList.getThumbnailUrl(file)).toBe(`/root/img/${fileName}`);
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO: move to data adapter
|
||||||
|
/*
|
||||||
it('should fallback to default icon for missing mime type', () => {
|
it('should fallback to default icon for missing mime type', () => {
|
||||||
spyOn(alfrescoServiceMock, 'getMimeTypeIcon').and.returnValue(null);
|
spyOn(documentListService, 'getMimeTypeIcon').and.returnValue(null);
|
||||||
documentList.baseComponentPath = '/root';
|
documentList.baseComponentPath = '/root';
|
||||||
|
|
||||||
let file = new FileNode();
|
let file = new FileNode();
|
||||||
@@ -570,9 +502,12 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
expect(documentList.getThumbnailUrl(file)).toBe('/root/img/ft_ic_miscellaneous.svg');
|
expect(documentList.getThumbnailUrl(file)).toBe('/root/img/ft_ic_miscellaneous.svg');
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO: move to data adapter
|
||||||
|
/*
|
||||||
it('should fallback to default icon for unknown mime type', () => {
|
it('should fallback to default icon for unknown mime type', () => {
|
||||||
spyOn(alfrescoServiceMock, 'getMimeTypeIcon').and.returnValue(null);
|
spyOn(documentListService, 'getMimeTypeIcon').and.returnValue(null);
|
||||||
documentList.baseComponentPath = '/root';
|
documentList.baseComponentPath = '/root';
|
||||||
|
|
||||||
let file = new FileNode();
|
let file = new FileNode();
|
||||||
@@ -580,17 +515,23 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
expect(documentList.getThumbnailUrl(file)).toBe('/root/img/ft_ic_miscellaneous.svg');
|
expect(documentList.getThumbnailUrl(file)).toBe('/root/img/ft_ic_miscellaneous.svg');
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO: move to data adapter
|
||||||
|
/*
|
||||||
it('should resolve thumbnail url for a file', () => {
|
it('should resolve thumbnail url for a file', () => {
|
||||||
let url = 'http://<some url>';
|
let url = 'http://<some url>';
|
||||||
spyOn(alfrescoServiceMock, 'getDocumentThumbnailUrl').and.returnValue(url);
|
spyOn(documentListService, 'getDocumentThumbnailUrl').and.returnValue(url);
|
||||||
|
|
||||||
documentList.thumbnails = true;
|
documentList.thumbnails = true;
|
||||||
|
|
||||||
let file = new FileNode();
|
let file = new FileNode();
|
||||||
expect(documentList.getThumbnailUrl(file)).toBe(url);
|
expect(documentList.getThumbnailUrl(file)).toBe(url);
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO: move to data adapter
|
||||||
|
/*
|
||||||
it('should return no thumbnail url with missing service', () => {
|
it('should return no thumbnail url with missing service', () => {
|
||||||
let list = new DocumentList(null, null);
|
let list = new DocumentList(null, null);
|
||||||
list.thumbnails = true;
|
list.thumbnails = true;
|
||||||
@@ -598,76 +539,10 @@ describe('DocumentList', () => {
|
|||||||
let file = new FileNode();
|
let file = new FileNode();
|
||||||
expect(list.getThumbnailUrl(file)).toBeNull();
|
expect(list.getThumbnailUrl(file)).toBeNull();
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
it('should sort on column header click', () => {
|
// TODO: move to DataTable
|
||||||
let col = new ContentColumnModel();
|
/*
|
||||||
col.source = 'id';
|
|
||||||
|
|
||||||
spyOn(documentList, 'sort').and.callThrough();
|
|
||||||
|
|
||||||
documentList.onColumnHeaderClick(col);
|
|
||||||
|
|
||||||
expect(documentList.sorting).toEqual(
|
|
||||||
jasmine.objectContaining({
|
|
||||||
key: 'id',
|
|
||||||
direction: 'asc'
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect(documentList.sort).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should invert sorting on column header click', () => {
|
|
||||||
let col = new ContentColumnModel();
|
|
||||||
col.source = 'id';
|
|
||||||
|
|
||||||
spyOn(documentList, 'sort').and.callThrough();
|
|
||||||
|
|
||||||
documentList.sorting = <ColumnSortingModel> { key: 'id', direction: 'asc' };
|
|
||||||
documentList.onColumnHeaderClick(col);
|
|
||||||
|
|
||||||
expect(documentList.sorting).toEqual(
|
|
||||||
jasmine.objectContaining({
|
|
||||||
key: 'id',
|
|
||||||
direction: 'desc'
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
documentList.onColumnHeaderClick(col);
|
|
||||||
expect(documentList.sorting).toEqual(
|
|
||||||
jasmine.objectContaining({
|
|
||||||
key: 'id',
|
|
||||||
direction: 'asc'
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(documentList.sort).toHaveBeenCalledTimes(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should use ascending direction for different column header click', () => {
|
|
||||||
let col = new ContentColumnModel();
|
|
||||||
col.source = 'id';
|
|
||||||
|
|
||||||
spyOn(documentList, 'sort').and.callThrough();
|
|
||||||
|
|
||||||
documentList.sorting = <ColumnSortingModel> { key: 'col1', direction: 'desc' };
|
|
||||||
documentList.onColumnHeaderClick(col);
|
|
||||||
|
|
||||||
expect(documentList.sorting).toEqual(
|
|
||||||
jasmine.objectContaining({
|
|
||||||
key: 'id',
|
|
||||||
direction: 'asc'
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(documentList.sort).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not sort by column header when instance is missing', () => {
|
|
||||||
spyOn(documentList, 'sort').and.callThrough();
|
|
||||||
documentList.onColumnHeaderClick(null);
|
|
||||||
expect(documentList.sort).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should convert cell value to formatted date', () => {
|
it('should convert cell value to formatted date', () => {
|
||||||
|
|
||||||
let rawValue = new Date(2015, 6, 15, 21, 43, 11).toString(); // Wed Jul 15 2015 21:43:11 GMT+0100 (BST);
|
let rawValue = new Date(2015, 6, 15, 21, 43, 11).toString(); // Wed Jul 15 2015 21:43:11 GMT+0100 (BST);
|
||||||
@@ -684,7 +559,10 @@ describe('DocumentList', () => {
|
|||||||
let value = documentList.getCellValue(file, col);
|
let value = documentList.getCellValue(file, col);
|
||||||
expect(value).toBe(dateValue);
|
expect(value).toBe(dateValue);
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO: move to DataTable
|
||||||
|
/*
|
||||||
it('should return date value as string', () => {
|
it('should return date value as string', () => {
|
||||||
let rawValue = new Date(2015, 6, 15, 21, 43, 11).toString(); // Wed Jul 15 2015 21:43:11 GMT+0100 (BST);
|
let rawValue = new Date(2015, 6, 15, 21, 43, 11).toString(); // Wed Jul 15 2015 21:43:11 GMT+0100 (BST);
|
||||||
|
|
||||||
@@ -698,7 +576,10 @@ describe('DocumentList', () => {
|
|||||||
let value = documentList.getCellValue(file, col);
|
let value = documentList.getCellValue(file, col);
|
||||||
expect(value).toBe(rawValue);
|
expect(value).toBe(rawValue);
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO: move to data adapter
|
||||||
|
/*
|
||||||
it('should convert cell value to thumbnail', () => {
|
it('should convert cell value to thumbnail', () => {
|
||||||
let url = 'http://<address>';
|
let url = 'http://<address>';
|
||||||
spyOn(documentList, 'getThumbnailUrl').and.returnValue(url);
|
spyOn(documentList, 'getThumbnailUrl').and.returnValue(url);
|
||||||
@@ -712,14 +593,15 @@ describe('DocumentList', () => {
|
|||||||
let value = documentList.getCellValue(file, col);
|
let value = documentList.getCellValue(file, col);
|
||||||
expect(value).toBe(url);
|
expect(value).toBe(url);
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
it('should require path to display folder content', () => {
|
it('should require path to display folder content', () => {
|
||||||
spyOn(alfrescoServiceMock, 'getFolder').and.callThrough();
|
spyOn(documentListService, 'getFolder').and.callThrough();
|
||||||
|
|
||||||
documentList.displayFolderContent(null);
|
documentList.displayFolderContent(null);
|
||||||
documentList.displayFolderContent('');
|
documentList.displayFolderContent('');
|
||||||
|
|
||||||
expect(alfrescoServiceMock.getFolder).not.toHaveBeenCalled();
|
expect(documentListService.getFolder).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should require node to resolve context menu actions', () => {
|
it('should require node to resolve context menu actions', () => {
|
||||||
@@ -733,12 +615,12 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
it('should fetch context menu actions for a file node', () => {
|
it('should fetch context menu actions for a file node', () => {
|
||||||
let actionModel = {};
|
let actionModel = {};
|
||||||
spyOn(documentList, 'getContentActions').and.returnValue([actionModel]);
|
spyOn(documentList, 'getNodeActions').and.returnValue([actionModel]);
|
||||||
|
|
||||||
let file = new FileNode();
|
let file = new FileNode();
|
||||||
let actions = documentList.getContextActions(file);
|
let actions = documentList.getContextActions(file);
|
||||||
|
|
||||||
expect(documentList.getContentActions).toHaveBeenCalledWith('document', 'menu');
|
expect(documentList.getNodeActions).toHaveBeenCalledWith(file);
|
||||||
expect(actions.length).toBe(1);
|
expect(actions.length).toBe(1);
|
||||||
expect(actions[0].model).toBe(actionModel);
|
expect(actions[0].model).toBe(actionModel);
|
||||||
expect(actions[0].node).toBe(file);
|
expect(actions[0].node).toBe(file);
|
||||||
@@ -747,12 +629,12 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
it('should fetch context menu actions for a folder node', () => {
|
it('should fetch context menu actions for a folder node', () => {
|
||||||
let actionModel = {};
|
let actionModel = {};
|
||||||
spyOn(documentList, 'getContentActions').and.returnValue([actionModel]);
|
spyOn(documentList, 'getNodeActions').and.returnValue([actionModel]);
|
||||||
|
|
||||||
let folder = new FolderNode();
|
let folder = new FolderNode();
|
||||||
let actions = documentList.getContextActions(folder);
|
let actions = documentList.getContextActions(folder);
|
||||||
|
|
||||||
expect(documentList.getContentActions).toHaveBeenCalledWith('folder', 'menu');
|
expect(documentList.getNodeActions).toHaveBeenCalledWith(folder);
|
||||||
expect(actions.length).toBe(1);
|
expect(actions.length).toBe(1);
|
||||||
expect(actions[0].model).toBe(actionModel);
|
expect(actions[0].model).toBe(actionModel);
|
||||||
expect(actions[0].node).toBe(folder);
|
expect(actions[0].node).toBe(folder);
|
||||||
@@ -760,51 +642,39 @@ describe('DocumentList', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should fetch no context menu actions for unknown type', () => {
|
it('should fetch no context menu actions for unknown type', () => {
|
||||||
spyOn(documentList, 'getContentActions').and.stub();
|
spyOn(documentList, 'getNodeActions').and.stub();
|
||||||
|
|
||||||
let node = new FileNode();
|
let node = new FileNode();
|
||||||
node.entry.isFile = false;
|
node.entry.isFile = false;
|
||||||
node.entry.isFolder = false;
|
node.entry.isFolder = false;
|
||||||
|
|
||||||
let actions = documentList.getContextActions(node);
|
let actions = documentList.getContextActions(node);
|
||||||
|
|
||||||
expect(documentList.getContentActions).not.toHaveBeenCalled();
|
|
||||||
expect(actions).toBeNull();
|
expect(actions).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return null value when no content actions found', () => {
|
it('should return null value when no content actions found', () => {
|
||||||
spyOn(documentList, 'getContentActions').and.returnValue([]);
|
spyOn(documentList, 'getNodeActions').and.returnValue([]);
|
||||||
|
|
||||||
let file = new FileNode();
|
let file = new FileNode();
|
||||||
let actions = documentList.getContextActions(file);
|
let actions = documentList.getContextActions(file);
|
||||||
|
|
||||||
expect(actions).toBeNull();
|
expect(actions).toBeNull();
|
||||||
expect(documentList.getContentActions).toHaveBeenCalled();
|
expect(documentList.getNodeActions).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
it('should update error message when folder content display fails', () => {
|
it('should update error message when folder content display fails', () => {
|
||||||
let error = 'My Error';
|
let error = 'My Error';
|
||||||
alfrescoServiceMock.getFolderReject = true;
|
documentListService.getFolderReject = true;
|
||||||
alfrescoServiceMock.getFolderRejectError = error;
|
documentListService.getFolderRejectError = error;
|
||||||
|
|
||||||
documentList.displayFolderContent('/some/path');
|
documentList.displayFolderContent('/some/path');
|
||||||
expect(documentList.errorMessage).toBe(error);
|
expect(documentList.errorMessage).toBe(error);
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
it('should get object value via property path', () => {
|
// TODO: move to data adapter
|
||||||
let obj = {
|
/*
|
||||||
name: {
|
|
||||||
firstName: '<name>'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(documentList.getObjectValue(obj, 'name.firstName')).toBe('<name>');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not get object value via invalid path', () => {
|
|
||||||
expect(documentList.getObjectValue({}, 'some.missing.path')).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should log error when having date conversion issues', () => {
|
it('should log error when having date conversion issues', () => {
|
||||||
|
|
||||||
let value = '<wrong-date>';
|
let value = '<wrong-date>';
|
||||||
@@ -824,7 +694,10 @@ describe('DocumentList', () => {
|
|||||||
expect(result).toBe(value);
|
expect(result).toBe(value);
|
||||||
expect(console.error).toHaveBeenCalledWith(`DocumentList: error parsing date ${value} to format ${col.format}`);
|
expect(console.error).toHaveBeenCalledWith(`DocumentList: error parsing date ${value} to format ${col.format}`);
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO: move to data adapter
|
||||||
|
/*
|
||||||
it('should convert thumbnail if column source defined', () => {
|
it('should convert thumbnail if column source defined', () => {
|
||||||
let file = new FileNode();
|
let file = new FileNode();
|
||||||
let col = new ContentColumnModel({
|
let col = new ContentColumnModel({
|
||||||
@@ -834,6 +707,7 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
expect(documentList.getCellValue(file, col)).toBe(file.entry.name);
|
expect(documentList.getCellValue(file, col)).toBe(file.entry.name);
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
it('should require current folder path to reload', () => {
|
it('should require current folder path to reload', () => {
|
||||||
|
|
||||||
@@ -850,6 +724,8 @@ describe('DocumentList', () => {
|
|||||||
expect(documentList.displayFolderContent).not.toHaveBeenCalled();
|
expect(documentList.displayFolderContent).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO: move to data adapter
|
||||||
|
/*
|
||||||
it('should not sort empty page', () => {
|
it('should not sort empty page', () => {
|
||||||
let page = new PageNode();
|
let page = new PageNode();
|
||||||
spyOn(page.list.entries, 'sort').and.stub();
|
spyOn(page.list.entries, 'sort').and.stub();
|
||||||
@@ -857,7 +733,10 @@ describe('DocumentList', () => {
|
|||||||
documentList.sort(page, null);
|
documentList.sort(page, null);
|
||||||
expect(page.list.entries.sort).not.toHaveBeenCalled();
|
expect(page.list.entries.sort).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO: move to data adapter
|
||||||
|
/*
|
||||||
it('should put folders to top on sort', () => {
|
it('should put folders to top on sort', () => {
|
||||||
let folder = new FolderNode();
|
let folder = new FolderNode();
|
||||||
let file1 = new FileNode('file1');
|
let file1 = new FileNode('file1');
|
||||||
@@ -884,7 +763,10 @@ describe('DocumentList', () => {
|
|||||||
expect(page.list.entries[1]).toBe(file2);
|
expect(page.list.entries[1]).toBe(file2);
|
||||||
expect(page.list.entries[2]).toBe(file1);
|
expect(page.list.entries[2]).toBe(file1);
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO: move to data adapter
|
||||||
|
/*
|
||||||
it('should sort by dates up to ms', () => {
|
it('should sort by dates up to ms', () => {
|
||||||
let file1 = new FileNode();
|
let file1 = new FileNode();
|
||||||
file1.entry['dateProp'] = new Date(2016, 6, 30, 13, 14, 1);
|
file1.entry['dateProp'] = new Date(2016, 6, 30, 13, 14, 1);
|
||||||
@@ -912,6 +794,6 @@ describe('DocumentList', () => {
|
|||||||
expect(page.list.entries[0]).toBe(file1);
|
expect(page.list.entries[0]).toBe(file1);
|
||||||
expect(page.list.entries[1]).toBe(file2);
|
expect(page.list.entries[1]).toBe(file2);
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
|
@@ -158,7 +158,7 @@ export class DocumentList implements OnInit, AfterViewInit, AfterViewChecked, Af
|
|||||||
this.contextActionHandler.subscribe(val => this.contextActionCallback(val));
|
this.contextActionHandler.subscribe(val => this.contextActionCallback(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(/*change*/) {
|
ngOnChanges() {
|
||||||
this.reload();
|
this.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,6 +189,7 @@ export class DocumentList implements OnInit, AfterViewInit, AfterViewChecked, Af
|
|||||||
getNodeActions(node: MinimalNodeEntity): ContentActionModel[] {
|
getNodeActions(node: MinimalNodeEntity): ContentActionModel[] {
|
||||||
let target = null;
|
let target = null;
|
||||||
|
|
||||||
|
if (node && node.entry) {
|
||||||
if (node.entry.isFile) {
|
if (node.entry.isFile) {
|
||||||
target = 'document';
|
target = 'document';
|
||||||
}
|
}
|
||||||
@@ -205,6 +206,8 @@ export class DocumentList implements OnInit, AfterViewInit, AfterViewChecked, Af
|
|||||||
return entry.target.toLowerCase() === ltarget;
|
return entry.target.toLowerCase() === ltarget;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,10 +237,8 @@ export class DocumentList implements OnInit, AfterViewInit, AfterViewChecked, Af
|
|||||||
}
|
}
|
||||||
|
|
||||||
displayFolderContent(path: string) {
|
displayFolderContent(path: string) {
|
||||||
if (path) {
|
|
||||||
this.data.loadPath(path);
|
this.data.loadPath(path);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
reload() {
|
reload() {
|
||||||
this.ngZone.run(() => {
|
this.ngZone.run(() => {
|
||||||
@@ -282,49 +283,58 @@ export class DocumentList implements OnInit, AfterViewInit, AfterViewChecked, Af
|
|||||||
this.data.setColumns([colThumbnail, colName]);
|
this.data.setColumns([colThumbnail, colName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
onRowClick(event: DataRowEvent) {
|
onPreviewFile(node: MinimalNodeEntity) {
|
||||||
let item = (<ShareDataRow> event.value).node;
|
if (node) {
|
||||||
|
this.preview.emit({
|
||||||
|
value: node
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onNodeClick(node: MinimalNodeEntity) {
|
||||||
this.nodeClick.emit({
|
this.nodeClick.emit({
|
||||||
value: item
|
value: node
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.navigate && this.navigationMode === DocumentList.SINGLE_CLICK_NAVIGATION) {
|
if (this.navigate && this.navigationMode === DocumentList.SINGLE_CLICK_NAVIGATION) {
|
||||||
if (item && item.entry) {
|
if (node && node.entry) {
|
||||||
if (item.entry.isFile) {
|
if (node.entry.isFile) {
|
||||||
this.preview.emit({
|
this.onPreviewFile(node);
|
||||||
value: item
|
}
|
||||||
|
|
||||||
|
if (node.entry.isFolder) {
|
||||||
|
this.performNavigation(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onRowClick(event: DataRowEvent) {
|
||||||
|
let item = (<ShareDataRow> event.value).node;
|
||||||
|
this.onNodeClick(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
onNodeDblClick(node: MinimalNodeEntity) {
|
||||||
|
this.nodeDblClick.emit({
|
||||||
|
value: node
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.navigate && this.navigationMode === DocumentList.DOUBLE_CLICK_NAVIGATION) {
|
||||||
|
if (node && node.entry) {
|
||||||
|
if (node.entry.isFile) {
|
||||||
|
this.onPreviewFile(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.entry.isFolder) {
|
if (node.entry.isFolder) {
|
||||||
this.performNavigation(item);
|
this.performNavigation(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onRowDblClick(event?: DataRowEvent) {
|
onRowDblClick(event?: DataRowEvent) {
|
||||||
let item = (<ShareDataRow> event.value).node;
|
let item = (<ShareDataRow> event.value).node;
|
||||||
|
this.onNodeDblClick(item);
|
||||||
this.nodeDblClick.emit({
|
|
||||||
value: item
|
|
||||||
});
|
|
||||||
|
|
||||||
if (this.navigate && this.navigationMode === DocumentList.DOUBLE_CLICK_NAVIGATION) {
|
|
||||||
if (item && item.entry) {
|
|
||||||
if (item.entry.isFile) {
|
|
||||||
this.preview.emit({
|
|
||||||
value: item
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.entry.isFolder) {
|
|
||||||
this.performNavigation(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onShowRowContextMenu(event) {
|
onShowRowContextMenu(event) {
|
||||||
|
@@ -168,9 +168,12 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
|||||||
.getFolder(path)
|
.getFolder(path)
|
||||||
.subscribe(val => {
|
.subscribe(val => {
|
||||||
let page = <NodePaging>val;
|
let page = <NodePaging>val;
|
||||||
|
let rows = [];
|
||||||
|
|
||||||
|
if (page && page.list) {
|
||||||
let data = page.list.entries;
|
let data = page.list.entries;
|
||||||
if (data && data.length > 0) {
|
if (data && data.length > 0) {
|
||||||
this.rows = data.map(item => new ShareDataRow(item));
|
rows = data.map(item => new ShareDataRow(item));
|
||||||
// Sort by first sortable or just first column
|
// Sort by first sortable or just first column
|
||||||
let sortable = this.columns.filter(c => c.sortable);
|
let sortable = this.columns.filter(c => c.sortable);
|
||||||
if (sortable.length > 0) {
|
if (sortable.length > 0) {
|
||||||
@@ -178,9 +181,10 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
|||||||
} else {
|
} else {
|
||||||
this.sort(this.columns[0].key, 'asc');
|
this.sort(this.columns[0].key, 'asc');
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this.rows = [];
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.rows = [];
|
||||||
},
|
},
|
||||||
error => console.log(error));
|
error => console.log(error));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user