mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
enable prefer-const rule for tslint, fix issues (#4409)
* enable prefer-const rule for tslint, fix issues * Update content-node-selector.component.spec.ts * Update content-node-selector.component.spec.ts * fix const * fix lint issues * update tests * update tests * update tests * fix code * fix page class
This commit is contained in:
committed by
Eugenio Romano
parent
26c5982a1a
commit
a7a48e8b2b
@@ -46,7 +46,7 @@ describe('Breadcrumb', () => {
|
||||
});
|
||||
|
||||
it('should prevent default click behavior', () => {
|
||||
let event = jasmine.createSpyObj('event', ['preventDefault']);
|
||||
const event = jasmine.createSpyObj('event', ['preventDefault']);
|
||||
component.onRoutePathClick(null, event);
|
||||
expect(event.preventDefault).toHaveBeenCalled();
|
||||
});
|
||||
@@ -60,7 +60,7 @@ describe('Breadcrumb', () => {
|
||||
});
|
||||
|
||||
it('should emit navigation event', (done) => {
|
||||
let node = <PathElementEntity> { id: '-id-', name: 'name' };
|
||||
const node = <PathElementEntity> { id: '-id-', name: 'name' };
|
||||
component.navigate.subscribe((val) => {
|
||||
expect(val).toBe(node);
|
||||
done();
|
||||
@@ -72,7 +72,7 @@ describe('Breadcrumb', () => {
|
||||
it('should update document list on click', (done) => {
|
||||
spyOn(documentList, 'loadFolderByNodeId').and.stub();
|
||||
|
||||
let node = <PathElementEntity> { id: '-id-', name: 'name' };
|
||||
const node = <PathElementEntity> { id: '-id-', name: 'name' };
|
||||
component.target = documentList;
|
||||
|
||||
component.onRoutePathClick(node, null);
|
||||
|
||||
@@ -108,7 +108,7 @@ export class BreadcrumbComponent implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
protected recalculateNodes(): void {
|
||||
let node: Node = this.transform ? this.transform(this.folderNode) : this.folderNode;
|
||||
const node: Node = this.transform ? this.transform(this.folderNode) : this.folderNode;
|
||||
|
||||
this.route = this.parseRoute(node);
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ describe('DropdownBreadcrumb', () => {
|
||||
}
|
||||
|
||||
it('should display only the current folder name if there is no previous folders', (done) => {
|
||||
let fakeNodeWithCreatePermissionInstance = JSON.parse(JSON.stringify(fakeNodeWithCreatePermission));
|
||||
const fakeNodeWithCreatePermissionInstance = JSON.parse(JSON.stringify(fakeNodeWithCreatePermission));
|
||||
fakeNodeWithCreatePermissionInstance.path.elements = [];
|
||||
|
||||
triggerComponentChange(fakeNodeWithCreatePermissionInstance);
|
||||
@@ -83,7 +83,7 @@ describe('DropdownBreadcrumb', () => {
|
||||
});
|
||||
|
||||
it('should display only the path in the selectBox', (done) => {
|
||||
let fakeNodeWithCreatePermissionInstance = JSON.parse(JSON.stringify(fakeNodeWithCreatePermission));
|
||||
const fakeNodeWithCreatePermissionInstance = JSON.parse(JSON.stringify(fakeNodeWithCreatePermission));
|
||||
fakeNodeWithCreatePermissionInstance.path.elements = [
|
||||
{ id: '1', name: 'Stark Industries' },
|
||||
{ id: '2', name: 'User Homes' },
|
||||
@@ -105,7 +105,7 @@ describe('DropdownBreadcrumb', () => {
|
||||
});
|
||||
|
||||
xit('should display the path in reverse order', (done) => {
|
||||
let fakeNodeWithCreatePermissionInstance = JSON.parse(JSON.stringify(fakeNodeWithCreatePermission));
|
||||
const fakeNodeWithCreatePermissionInstance = JSON.parse(JSON.stringify(fakeNodeWithCreatePermission));
|
||||
fakeNodeWithCreatePermissionInstance.path.elements = [
|
||||
{ id: '1', name: 'Stark Industries' },
|
||||
{ id: '2', name: 'User Homes' },
|
||||
@@ -130,7 +130,7 @@ describe('DropdownBreadcrumb', () => {
|
||||
});
|
||||
|
||||
it('should emit navigation event when clicking on an option', (done) => {
|
||||
let fakeNodeWithCreatePermissionInstance = JSON.parse(JSON.stringify(fakeNodeWithCreatePermission));
|
||||
const fakeNodeWithCreatePermissionInstance = JSON.parse(JSON.stringify(fakeNodeWithCreatePermission));
|
||||
fakeNodeWithCreatePermissionInstance.path.elements = [{ id: '1', name: 'Stark Industries' }];
|
||||
|
||||
triggerComponentChange(fakeNodeWithCreatePermissionInstance);
|
||||
@@ -153,7 +153,7 @@ describe('DropdownBreadcrumb', () => {
|
||||
it('should update document list when clicking on an option', (done) => {
|
||||
spyOn(documentList, 'loadFolderByNodeId').and.stub();
|
||||
component.target = documentList;
|
||||
let fakeNodeWithCreatePermissionInstance = JSON.parse(JSON.stringify(fakeNodeWithCreatePermission));
|
||||
const fakeNodeWithCreatePermissionInstance = JSON.parse(JSON.stringify(fakeNodeWithCreatePermission));
|
||||
fakeNodeWithCreatePermissionInstance.path.elements = [{ id: '1', name: 'Stark Industries' }];
|
||||
triggerComponentChange(fakeNodeWithCreatePermissionInstance);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ export class DropdownBreadcrumbComponent extends BreadcrumbComponent implements
|
||||
* Calculate the current and previous nodes from the route array
|
||||
*/
|
||||
protected recalculateNodes(): void {
|
||||
let node: Node = this.transform ? this.transform(this.folderNode) : this.folderNode;
|
||||
const node: Node = this.transform ? this.transform(this.folderNode) : this.folderNode;
|
||||
|
||||
this.route = this.parseRoute(node);
|
||||
this.currentNode = this.route[this.route.length - 1];
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ describe('ContentMetadataCardComponent', () => {
|
||||
let component: ContentMetadataCardComponent;
|
||||
let fixture: ComponentFixture<ContentMetadataCardComponent>;
|
||||
let node: Node;
|
||||
let preset = 'custom-preset';
|
||||
const preset = 'custom-preset';
|
||||
|
||||
setupTestBed({
|
||||
imports: [ContentTestingModule]
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ describe('ContentMetadataComponent', () => {
|
||||
let fixture: ComponentFixture<ContentMetadataComponent>;
|
||||
let node: Node;
|
||||
let folderNode: Node;
|
||||
let preset = 'custom-preset';
|
||||
const preset = 'custom-preset';
|
||||
|
||||
setupTestBed({
|
||||
imports: [ContentTestingModule],
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ export class LayoutOrientedConfigService implements ContentMetadataConfig {
|
||||
public reorganiseByConfig(propertyGroups: PropertyGroupContainer): OrganisedPropertyGroup[] {
|
||||
const layoutBlocks = this.config.filter((itemsGroup) => itemsGroup.items);
|
||||
|
||||
let organisedPropertyGroup = layoutBlocks.map((layoutBlock) => {
|
||||
const organisedPropertyGroup = layoutBlocks.map((layoutBlock) => {
|
||||
const flattenedItems = this.flattenItems(layoutBlock.items),
|
||||
properties = flattenedItems.reduce((props, explodedItem) => {
|
||||
const property = getProperty(propertyGroups, explodedItem.groupName, explodedItem.propertyName) || [];
|
||||
@@ -82,7 +82,7 @@ export class LayoutOrientedConfigService implements ContentMetadataConfig {
|
||||
}
|
||||
|
||||
public isIncludeAllEnabled() {
|
||||
let includeAllProperty = this.config
|
||||
const includeAllProperty = this.config
|
||||
.map((config) => config.includeAll)
|
||||
.find((includeAll) => includeAll !== undefined);
|
||||
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ export class PropertyGroupTranslatorService {
|
||||
|
||||
const prefix = 'properties.';
|
||||
|
||||
let propertyDefinition: CardViewItemProperties = {
|
||||
const propertyDefinition: CardViewItemProperties = {
|
||||
label: property.title || property.name,
|
||||
value: propertyValue,
|
||||
key: `${prefix}${property.name}`,
|
||||
|
||||
@@ -71,7 +71,7 @@ describe('ContentNodeDialogService', () => {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
let appConfig: AppConfigService = TestBed.get(AppConfigService);
|
||||
const appConfig: AppConfigService = TestBed.get(AppConfigService);
|
||||
appConfig.config.ecmHost = 'http://localhost:9876/ecm';
|
||||
|
||||
service = TestBed.get(ContentNodeDialogService);
|
||||
|
||||
@@ -151,7 +151,7 @@ export class ContentNodeDialogService {
|
||||
|
||||
return select;
|
||||
} else {
|
||||
let errors = new Error(JSON.stringify({ error: { statusCode: 403 } }));
|
||||
const errors = new Error(JSON.stringify({ error: { statusCode: 403 } }));
|
||||
return throwError(errors);
|
||||
}
|
||||
}
|
||||
|
||||
+16
-16
@@ -60,7 +60,7 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
let _observer: Observer<NodePaging>;
|
||||
|
||||
function typeToSearchBox(searchTerm = 'string-to-search') {
|
||||
let searchInput = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-input"]'));
|
||||
const searchInput = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-input"]'));
|
||||
searchInput.nativeElement.value = searchTerm;
|
||||
component.searchInput.setValue(searchTerm);
|
||||
fixture.detectChanges();
|
||||
@@ -323,11 +323,11 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
describe('Search functionality', () => {
|
||||
let getCorrespondingNodeIdsSpy;
|
||||
|
||||
let defaultSearchOptions = (searchTerm, rootNodeId = undefined, skipCount = 0) => {
|
||||
const defaultSearchOptions = (searchTerm, rootNodeId = undefined, skipCount = 0) => {
|
||||
|
||||
const parentFiltering = rootNodeId ? [{ query: `ANCESTOR:'workspace://SpacesStore/${rootNodeId}'` }] : [];
|
||||
|
||||
let defaultSearchNode: any = {
|
||||
const defaultSearchNode: any = {
|
||||
query: {
|
||||
query: searchTerm ? `${searchTerm}* OR name:${searchTerm}*` : searchTerm
|
||||
},
|
||||
@@ -507,8 +507,8 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
fixture.detectChanges();
|
||||
tick(debounceSearch);
|
||||
|
||||
let searchIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-icon"]'));
|
||||
let clearIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-clear"]'));
|
||||
const searchIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-icon"]'));
|
||||
const clearIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-clear"]'));
|
||||
|
||||
expect(searchIcon).not.toBeNull('Search icon should be in the DOM');
|
||||
expect(clearIcon).toBeNull('Clear icon should NOT be in the DOM');
|
||||
@@ -521,8 +521,8 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
let searchIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-icon"]'));
|
||||
let clearIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-clear"]'));
|
||||
const searchIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-icon"]'));
|
||||
const clearIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-clear"]'));
|
||||
|
||||
expect(searchIcon).toBeNull('Search icon should NOT be in the DOM');
|
||||
expect(clearIcon).not.toBeNull('Clear icon should be in the DOM');
|
||||
@@ -602,13 +602,13 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
}));
|
||||
|
||||
it('should show the current folder\'s content instead of search results if search was not performed', () => {
|
||||
let documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
||||
const documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
||||
expect(documentList).not.toBeNull('Document list should be shown');
|
||||
expect(documentList.componentInstance.currentFolderId).toBe('cat-girl-nuku-nuku');
|
||||
});
|
||||
|
||||
it('should pass through the rowFilter to the documentList', () => {
|
||||
let filter = (shareDataRow: ShareDataRow) => {
|
||||
const filter = (shareDataRow: ShareDataRow) => {
|
||||
if (shareDataRow.node.entry.name === 'impossible-name') {
|
||||
return true;
|
||||
}
|
||||
@@ -618,7 +618,7 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
let documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
||||
const documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
||||
expect(documentList).not.toBeNull('Document list should be shown');
|
||||
expect(documentList.componentInstance.rowFilter({
|
||||
node: {
|
||||
@@ -643,7 +643,7 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
let documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
||||
const documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
||||
expect(documentList).not.toBeNull('Document list should be shown');
|
||||
expect(documentList.componentInstance.rowFilter).toBeTruthy('Document list should have had a rowFilter');
|
||||
|
||||
@@ -658,7 +658,7 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
let documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
||||
const documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
||||
expect(documentList).not.toBeNull('Document list should be shown');
|
||||
expect(documentList.componentInstance.imageResolver).toBe(resolver);
|
||||
});
|
||||
@@ -670,7 +670,7 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
respondWithSearchResults(ONE_FOLDER_RESULT);
|
||||
|
||||
fixture.detectChanges();
|
||||
let documentList = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-document-list"]'));
|
||||
const documentList = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-document-list"]'));
|
||||
expect(documentList).not.toBeNull('Document list should be shown');
|
||||
expect(documentList.componentInstance.currentFolderId).toBeNull();
|
||||
done();
|
||||
@@ -700,12 +700,12 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
let clearButton = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-clear"]'));
|
||||
const clearButton = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-clear"]'));
|
||||
expect(clearButton).not.toBeNull('Clear button should be in DOM');
|
||||
clearButton.triggerEventHandler('click', {});
|
||||
fixture.detectChanges();
|
||||
|
||||
let documentList = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-document-list"]'));
|
||||
const documentList = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-document-list"]'));
|
||||
expect(documentList).not.toBeNull('Document list should be shown');
|
||||
expect(documentList.componentInstance.currentFolderId).toBe('cat-girl-nuku-nuku');
|
||||
done();
|
||||
@@ -726,7 +726,7 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
let documentList = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-document-list"]'));
|
||||
const documentList = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-document-list"]'));
|
||||
expect(documentList.componentInstance.currentFolderId).toBe('cat-girl-nuku-nuku');
|
||||
}));
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ describe('ContentNodeSelectorDialogComponent', () => {
|
||||
|
||||
let component: ContentNodeSelectorComponent;
|
||||
let fixture: ComponentFixture<ContentNodeSelectorComponent>;
|
||||
let data: any = {
|
||||
const data: any = {
|
||||
title: 'Move along citizen...',
|
||||
actionName: 'move',
|
||||
select: new EventEmitter<Node>(),
|
||||
@@ -87,13 +87,13 @@ describe('ContentNodeSelectorDialogComponent', () => {
|
||||
});
|
||||
|
||||
it('should pass through the injected currentFolderId to the documentList', () => {
|
||||
let documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
||||
const documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
||||
expect(documentList).not.toBeNull('Document list should be shown');
|
||||
expect(documentList.componentInstance.currentFolderId).toBe('cat-girl-nuku-nuku');
|
||||
});
|
||||
|
||||
it('should pass through the injected rowFilter to the documentList', () => {
|
||||
let documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
||||
const documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
||||
expect(documentList).not.toBeNull('Document list should be shown');
|
||||
expect(documentList.componentInstance.rowFilter({
|
||||
node: {
|
||||
@@ -114,7 +114,7 @@ describe('ContentNodeSelectorDialogComponent', () => {
|
||||
});
|
||||
|
||||
it('should pass through the injected imageResolver to the documentList', () => {
|
||||
let documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
||||
const documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
||||
expect(documentList).not.toBeNull('Document list should be shown');
|
||||
expect(documentList.componentInstance.imageResolver).toBe(data.imageResolver);
|
||||
});
|
||||
@@ -150,7 +150,7 @@ describe('ContentNodeSelectorDialogComponent', () => {
|
||||
it('should be disabled by default', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
let actionButton = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-actions-choose"]'));
|
||||
const actionButton = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-actions-choose"]'));
|
||||
expect(actionButton.nativeElement.disabled).toBeTruthy();
|
||||
});
|
||||
|
||||
@@ -158,7 +158,7 @@ describe('ContentNodeSelectorDialogComponent', () => {
|
||||
component.onSelect([new Node({ id: 'fake' })]);
|
||||
fixture.detectChanges();
|
||||
|
||||
let actionButton = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-actions-choose"]'));
|
||||
const actionButton = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-actions-choose"]'));
|
||||
expect(actionButton.nativeElement.disabled).toBeFalsy();
|
||||
});
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ export class ContentNodeSelectorService {
|
||||
|
||||
const parentFiltering = rootNodeId ? [{ query: `ANCESTOR:'workspace://SpacesStore/${rootNodeId}'${extraParentFiltering}` }] : [];
|
||||
|
||||
let defaultSearchNode: any = {
|
||||
const defaultSearchNode: any = {
|
||||
query: {
|
||||
query: `${searchTerm}* OR name:${searchTerm}*`
|
||||
},
|
||||
|
||||
@@ -34,7 +34,7 @@ import moment from 'moment-es6';
|
||||
describe('ShareDialogComponent', () => {
|
||||
let node;
|
||||
let matDialog: MatDialog;
|
||||
let notificationServiceMock = {
|
||||
const notificationServiceMock = {
|
||||
openSnackMessage: jasmine.createSpy('openSnackMessage')
|
||||
};
|
||||
let sharedLinksApiService: SharedLinksApiService;
|
||||
|
||||
@@ -29,7 +29,7 @@ describe('FolderDialogComponent', () => {
|
||||
let fixture: ComponentFixture<FolderDialogComponent>;
|
||||
let component: FolderDialogComponent;
|
||||
let nodesApi: NodesApiService;
|
||||
let dialogRef = {
|
||||
const dialogRef = {
|
||||
close: jasmine.createSpy('close')
|
||||
};
|
||||
|
||||
|
||||
@@ -99,13 +99,13 @@ export class FolderDialogComponent implements OnInit {
|
||||
}
|
||||
|
||||
get name(): string {
|
||||
let { name } = this.form.value;
|
||||
const { name } = this.form.value;
|
||||
|
||||
return (name || '').trim();
|
||||
}
|
||||
|
||||
get description(): string {
|
||||
let { description } = this.form.value;
|
||||
const { description } = this.form.value;
|
||||
|
||||
return (description || '').trim();
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ describe('NodeLockDialogComponent', () => {
|
||||
});
|
||||
|
||||
it('should update form inputs', () => {
|
||||
let newTime = moment();
|
||||
const newTime = moment();
|
||||
component.form.controls['isLocked'].setValue(false);
|
||||
component.form.controls['allowOwner'].setValue(false);
|
||||
component.form.controls['isTimeLock'].setValue(false);
|
||||
|
||||
@@ -59,7 +59,7 @@ export class NodeLockDialogComponent implements OnInit {
|
||||
|
||||
private get lockTimeInSeconds(): number {
|
||||
if (this.form.value.isTimeLock) {
|
||||
let duration = moment.duration(moment(this.form.value.time).diff(moment()));
|
||||
const duration = moment.duration(moment(this.form.value.time).diff(moment()));
|
||||
return duration.asSeconds();
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -41,8 +41,8 @@ describe('ContentColumnList', () => {
|
||||
it('should register action', () => {
|
||||
spyOn(documentList.actions, 'push').and.callThrough();
|
||||
|
||||
let action = new ContentActionModel();
|
||||
let result = actionList.registerAction(action);
|
||||
const action = new ContentActionModel();
|
||||
const result = actionList.registerAction(action);
|
||||
|
||||
expect(result).toBeTruthy();
|
||||
expect(documentList.actions.push).toHaveBeenCalledWith(action);
|
||||
@@ -50,13 +50,13 @@ describe('ContentColumnList', () => {
|
||||
|
||||
it('should require document list instance to register action', () => {
|
||||
actionList = new ContentActionListComponent(null);
|
||||
let action = new ContentActionModel();
|
||||
const action = new ContentActionModel();
|
||||
expect(actionList.registerAction(action)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should require action instance to register', () => {
|
||||
spyOn(documentList.actions, 'push').and.callThrough();
|
||||
let result = actionList.registerAction(null);
|
||||
const result = actionList.registerAction(null);
|
||||
|
||||
expect(result).toBeFalsy();
|
||||
expect(documentList.actions.push).not.toHaveBeenCalled();
|
||||
|
||||
+30
-30
@@ -58,14 +58,14 @@ describe('ContentAction', () => {
|
||||
it('should register within parent actions list', () => {
|
||||
spyOn(actionList, 'registerAction').and.stub();
|
||||
|
||||
let action = new ContentActionComponent(actionList, null, null);
|
||||
const action = new ContentActionComponent(actionList, null, null);
|
||||
action.ngOnInit();
|
||||
|
||||
expect(actionList.registerAction).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should setup and register model', () => {
|
||||
let action = new ContentActionComponent(actionList, null, null);
|
||||
const action = new ContentActionComponent(actionList, null, null);
|
||||
action.target = 'document';
|
||||
action.title = '<title>';
|
||||
action.icon = '<icon>';
|
||||
@@ -75,14 +75,14 @@ describe('ContentAction', () => {
|
||||
|
||||
expect(documentList.actions.length).toBe(1);
|
||||
|
||||
let model = documentList.actions[0];
|
||||
const model = documentList.actions[0];
|
||||
expect(model.target).toBe(action.target);
|
||||
expect(model.title).toBe(action.title);
|
||||
expect(model.icon).toBe(action.icon);
|
||||
});
|
||||
|
||||
it('should update visibility binding', () => {
|
||||
let action = new ContentActionComponent(actionList, null, null);
|
||||
const action = new ContentActionComponent(actionList, null, null);
|
||||
action.target = 'document';
|
||||
action.title = '<title>';
|
||||
action.icon = '<icon>';
|
||||
@@ -101,11 +101,11 @@ describe('ContentAction', () => {
|
||||
|
||||
it('should get action handler from document actions service', () => {
|
||||
|
||||
let handler = function () {
|
||||
const handler = function () {
|
||||
};
|
||||
spyOn(documentActions, 'getHandler').and.returnValue(handler);
|
||||
|
||||
let action = new ContentActionComponent(actionList, documentActions, null);
|
||||
const action = new ContentActionComponent(actionList, documentActions, null);
|
||||
action.target = 'document';
|
||||
action.handler = '<handler>';
|
||||
action.ngOnInit();
|
||||
@@ -113,16 +113,16 @@ describe('ContentAction', () => {
|
||||
expect(documentActions.getHandler).toHaveBeenCalledWith(action.handler);
|
||||
expect(documentList.actions.length).toBe(1);
|
||||
|
||||
let model = documentList.actions[0];
|
||||
const model = documentList.actions[0];
|
||||
expect(model.handler).toBe(handler);
|
||||
});
|
||||
|
||||
it('should get action handler from folder actions service', () => {
|
||||
let handler = function () {
|
||||
const handler = function () {
|
||||
};
|
||||
spyOn(folderActions, 'getHandler').and.returnValue(handler);
|
||||
|
||||
let action = new ContentActionComponent(actionList, null, folderActions);
|
||||
const action = new ContentActionComponent(actionList, null, folderActions);
|
||||
action.target = 'folder';
|
||||
action.handler = '<handler>';
|
||||
action.ngOnInit();
|
||||
@@ -130,7 +130,7 @@ describe('ContentAction', () => {
|
||||
expect(folderActions.getHandler).toHaveBeenCalledWith(action.handler);
|
||||
expect(documentList.actions.length).toBe(1);
|
||||
|
||||
let model = documentList.actions[0];
|
||||
const model = documentList.actions[0];
|
||||
expect(model.handler).toBe(handler);
|
||||
});
|
||||
|
||||
@@ -138,7 +138,7 @@ describe('ContentAction', () => {
|
||||
spyOn(folderActions, 'getHandler').and.stub();
|
||||
spyOn(documentActions, 'getHandler').and.stub();
|
||||
|
||||
let action = new ContentActionComponent(actionList, documentActions, folderActions);
|
||||
const action = new ContentActionComponent(actionList, documentActions, folderActions);
|
||||
action.handler = '<handler>';
|
||||
|
||||
action.ngOnInit();
|
||||
@@ -151,7 +151,7 @@ describe('ContentAction', () => {
|
||||
spyOn(folderActions, 'getHandler').and.stub();
|
||||
spyOn(documentActions, 'getHandler').and.stub();
|
||||
|
||||
let action = new ContentActionComponent(actionList, documentActions, folderActions);
|
||||
const action = new ContentActionComponent(actionList, documentActions, folderActions);
|
||||
action.handler = '<handler>';
|
||||
action.target = 'document';
|
||||
|
||||
@@ -165,7 +165,7 @@ describe('ContentAction', () => {
|
||||
spyOn(folderActions, 'getHandler').and.stub();
|
||||
spyOn(documentActions, 'getHandler').and.stub();
|
||||
|
||||
let action = new ContentActionComponent(actionList, documentActions, folderActions);
|
||||
const action = new ContentActionComponent(actionList, documentActions, folderActions);
|
||||
action.handler = '<handler>';
|
||||
action.target = 'folder';
|
||||
|
||||
@@ -178,7 +178,7 @@ describe('ContentAction', () => {
|
||||
it('should be case insensitive for document target', () => {
|
||||
spyOn(documentActions, 'getHandler').and.stub();
|
||||
|
||||
let action = new ContentActionComponent(actionList, documentActions, null);
|
||||
const action = new ContentActionComponent(actionList, documentActions, null);
|
||||
action.target = 'DoCuMeNt';
|
||||
action.handler = '<handler>';
|
||||
|
||||
@@ -189,7 +189,7 @@ describe('ContentAction', () => {
|
||||
it('should be case insensitive for folder target', () => {
|
||||
spyOn(folderActions, 'getHandler').and.stub();
|
||||
|
||||
let action = new ContentActionComponent(actionList, null, folderActions);
|
||||
const action = new ContentActionComponent(actionList, null, folderActions);
|
||||
action.target = 'FoLdEr';
|
||||
action.handler = '<handler>';
|
||||
|
||||
@@ -198,46 +198,46 @@ describe('ContentAction', () => {
|
||||
});
|
||||
|
||||
it('should use custom "execute" emitter', (done) => {
|
||||
let emitter = new EventEmitter();
|
||||
const emitter = new EventEmitter();
|
||||
|
||||
emitter.subscribe((e) => {
|
||||
expect(e.value).toBe('<obj>');
|
||||
done();
|
||||
});
|
||||
|
||||
let action = new ContentActionComponent(actionList, null, null);
|
||||
const action = new ContentActionComponent(actionList, null, null);
|
||||
action.target = 'document';
|
||||
action.execute = emitter;
|
||||
|
||||
action.ngOnInit();
|
||||
expect(documentList.actions.length).toBe(1);
|
||||
|
||||
let model = documentList.actions[0];
|
||||
const model = documentList.actions[0];
|
||||
model.execute('<obj>');
|
||||
});
|
||||
|
||||
it('should not find document action handler with missing service', () => {
|
||||
let action = new ContentActionComponent(actionList, null, null);
|
||||
const action = new ContentActionComponent(actionList, null, null);
|
||||
expect(action.getSystemHandler('document', 'name')).toBeNull();
|
||||
});
|
||||
|
||||
it('should not find folder action handler with missing service', () => {
|
||||
let action = new ContentActionComponent(actionList, null, null);
|
||||
const action = new ContentActionComponent(actionList, null, null);
|
||||
expect(action.getSystemHandler('folder', 'name')).toBeNull();
|
||||
});
|
||||
|
||||
it('should find document action handler via service', () => {
|
||||
let handler = <ContentActionHandler> function (obj: any, target?: any) {
|
||||
const handler = <ContentActionHandler> function (obj: any, target?: any) {
|
||||
};
|
||||
let action = new ContentActionComponent(actionList, documentActions, null);
|
||||
const action = new ContentActionComponent(actionList, documentActions, null);
|
||||
spyOn(documentActions, 'getHandler').and.returnValue(handler);
|
||||
expect(action.getSystemHandler('document', 'name')).toBe(handler);
|
||||
});
|
||||
|
||||
it('should find folder action handler via service', () => {
|
||||
let handler = <ContentActionHandler> function (obj: any, target?: any) {
|
||||
const handler = <ContentActionHandler> function (obj: any, target?: any) {
|
||||
};
|
||||
let action = new ContentActionComponent(actionList, null, folderActions);
|
||||
const action = new ContentActionComponent(actionList, null, folderActions);
|
||||
spyOn(folderActions, 'getHandler').and.returnValue(handler);
|
||||
expect(action.getSystemHandler('folder', 'name')).toBe(handler);
|
||||
});
|
||||
@@ -246,7 +246,7 @@ describe('ContentAction', () => {
|
||||
spyOn(folderActions, 'getHandler').and.stub();
|
||||
spyOn(documentActions, 'getHandler').and.stub();
|
||||
|
||||
let action = new ContentActionComponent(actionList, documentActions, folderActions);
|
||||
const action = new ContentActionComponent(actionList, documentActions, folderActions);
|
||||
|
||||
expect(action.getSystemHandler('unknown', 'name')).toBeNull();
|
||||
expect(folderActions.getHandler).not.toHaveBeenCalled();
|
||||
@@ -255,10 +255,10 @@ describe('ContentAction', () => {
|
||||
});
|
||||
|
||||
it('should wire model with custom event handler', async(() => {
|
||||
let action = new ContentActionComponent(actionList, documentActions, folderActions);
|
||||
let file = new FileNode();
|
||||
const action = new ContentActionComponent(actionList, documentActions, folderActions);
|
||||
const file = new FileNode();
|
||||
|
||||
let handler = new EventEmitter();
|
||||
const handler = new EventEmitter();
|
||||
handler.subscribe((e) => {
|
||||
expect(e.value).toBe(file);
|
||||
});
|
||||
@@ -270,7 +270,7 @@ describe('ContentAction', () => {
|
||||
}));
|
||||
|
||||
it('should allow registering model without handler', () => {
|
||||
let action = new ContentActionComponent(actionList, documentActions, folderActions);
|
||||
const action = new ContentActionComponent(actionList, documentActions, folderActions);
|
||||
|
||||
spyOn(actionList, 'registerAction').and.callThrough();
|
||||
action.execute = null;
|
||||
@@ -282,7 +282,7 @@ describe('ContentAction', () => {
|
||||
});
|
||||
|
||||
it('should register on init', () => {
|
||||
let action = new ContentActionComponent(actionList, null, null);
|
||||
const action = new ContentActionComponent(actionList, null, null);
|
||||
spyOn(action, 'register').and.callThrough();
|
||||
|
||||
action.ngOnInit();
|
||||
|
||||
+5
-5
@@ -43,11 +43,11 @@ describe('ContentColumnList', () => {
|
||||
});
|
||||
|
||||
it('should register column within parent document list', () => {
|
||||
let columns = documentList.data.getColumns();
|
||||
const columns = documentList.data.getColumns();
|
||||
expect(columns.length).toBe(0);
|
||||
|
||||
let column = <DataColumn> {};
|
||||
let result = columnList.registerColumn(column);
|
||||
const column = <DataColumn> {};
|
||||
const result = columnList.registerColumn(column);
|
||||
|
||||
expect(result).toBeTruthy();
|
||||
expect(columns.length).toBe(1);
|
||||
@@ -56,13 +56,13 @@ describe('ContentColumnList', () => {
|
||||
|
||||
it('should require document list instance to register action', () => {
|
||||
columnList = new ContentColumnListComponent(null, logService);
|
||||
let col = <DataColumn> {};
|
||||
const col = <DataColumn> {};
|
||||
expect(columnList.registerColumn(col)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should require action instance to register', () => {
|
||||
spyOn(documentList.actions, 'push').and.callThrough();
|
||||
let result = columnList.registerColumn(null);
|
||||
const result = columnList.registerColumn(null);
|
||||
|
||||
expect(result).toBeFalsy();
|
||||
expect(documentList.actions.push).not.toHaveBeenCalled();
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ export class ContentColumnListComponent {
|
||||
*/
|
||||
registerColumn(column: DataColumn): boolean {
|
||||
if (this.documentList && column) {
|
||||
let columns = this.documentList.data.getColumns();
|
||||
const columns = this.documentList.data.getColumns();
|
||||
columns.push(column);
|
||||
return true;
|
||||
}
|
||||
|
||||
+4
-4
@@ -45,18 +45,18 @@ describe('ContentColumn', () => {
|
||||
it('should register model within parent column list', () => {
|
||||
spyOn(columnList, 'registerColumn').and.callThrough();
|
||||
|
||||
let column = new ContentColumnComponent(columnList, logService);
|
||||
const column = new ContentColumnComponent(columnList, logService);
|
||||
column.ngAfterContentInit();
|
||||
|
||||
expect(columnList.registerColumn).toHaveBeenCalled();
|
||||
|
||||
let columns = documentList.data.getColumns();
|
||||
const columns = documentList.data.getColumns();
|
||||
expect(columns.length).toBe(1);
|
||||
expect(columns[0]).toBe(column);
|
||||
});
|
||||
|
||||
it('should setup screen reader title for thumbnail column', () => {
|
||||
let column = new ContentColumnComponent(columnList, logService);
|
||||
const column = new ContentColumnComponent(columnList, logService);
|
||||
column.key = '$thumbnail';
|
||||
column.ngOnInit();
|
||||
|
||||
@@ -64,7 +64,7 @@ describe('ContentColumn', () => {
|
||||
});
|
||||
|
||||
it('should register on init', () => {
|
||||
let column = new ContentColumnComponent(columnList, logService);
|
||||
const column = new ContentColumnComponent(columnList, logService);
|
||||
spyOn(column, 'register').and.callThrough();
|
||||
|
||||
column.ngAfterContentInit();
|
||||
|
||||
@@ -107,7 +107,7 @@ describe('DocumentList', () => {
|
||||
it('should add the custom columns', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
let column = <DataColumn> {
|
||||
const column = <DataColumn> {
|
||||
title: 'title',
|
||||
key: 'source',
|
||||
cssClass: 'css',
|
||||
@@ -116,7 +116,7 @@ describe('DocumentList', () => {
|
||||
format: ''
|
||||
};
|
||||
|
||||
let columns = documentList.data.getColumns();
|
||||
const columns = documentList.data.getColumns();
|
||||
columns.push(column);
|
||||
|
||||
documentList.ngAfterContentInit();
|
||||
@@ -125,8 +125,8 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should call action\'s handler with node', () => {
|
||||
let node = new FileNode();
|
||||
let action = new ContentActionModel();
|
||||
const node = new FileNode();
|
||||
const action = new ContentActionModel();
|
||||
action.handler = () => {
|
||||
};
|
||||
|
||||
@@ -138,8 +138,8 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should call action\'s handler with node and permission', () => {
|
||||
let node = new FileNode();
|
||||
let action = new ContentActionModel();
|
||||
const node = new FileNode();
|
||||
const action = new ContentActionModel();
|
||||
action.handler = () => {
|
||||
};
|
||||
action.permission = 'fake-permission';
|
||||
@@ -151,8 +151,8 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should call action\'s execute with node if it is defined', () => {
|
||||
let node = new FileNode();
|
||||
let action = new ContentActionModel();
|
||||
const node = new FileNode();
|
||||
const action = new ContentActionModel();
|
||||
action.execute = () => {
|
||||
};
|
||||
spyOn(action, 'execute').and.stub();
|
||||
@@ -164,8 +164,8 @@ describe('DocumentList', () => {
|
||||
|
||||
it('should call action\'s execute only after the handler has been executed', () => {
|
||||
const deleteObservable: Subject<any> = new Subject<any>();
|
||||
let node = new FileNode();
|
||||
let action = new ContentActionModel();
|
||||
const node = new FileNode();
|
||||
const action = new ContentActionModel();
|
||||
action.handler = () => deleteObservable;
|
||||
action.execute = () => {
|
||||
};
|
||||
@@ -260,7 +260,7 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should not execute action without node provided', () => {
|
||||
let action = new ContentActionModel();
|
||||
const action = new ContentActionModel();
|
||||
action.handler = function () {
|
||||
};
|
||||
|
||||
@@ -270,15 +270,15 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should not give node actions for empty target', () => {
|
||||
let actions = documentList.getNodeActions(null);
|
||||
const actions = documentList.getNodeActions(null);
|
||||
expect(actions.length).toBe(0);
|
||||
});
|
||||
|
||||
it('should filter content actions for various targets', () => {
|
||||
let folderMenu = new ContentActionModel();
|
||||
const folderMenu = new ContentActionModel();
|
||||
folderMenu.target = 'folder';
|
||||
|
||||
let documentMenu = new ContentActionModel();
|
||||
const documentMenu = new ContentActionModel();
|
||||
documentMenu.target = 'document';
|
||||
|
||||
documentList.actions = [
|
||||
@@ -297,7 +297,7 @@ describe('DocumentList', () => {
|
||||
|
||||
it('should disable the action if there is no permission for the file and disableWithNoPermission true', () => {
|
||||
documentList.currentFolderId = 'fake-node-id';
|
||||
let documentMenu = new ContentActionModel({
|
||||
const documentMenu = new ContentActionModel({
|
||||
disableWithNoPermission: true,
|
||||
permission: 'delete',
|
||||
target: 'document',
|
||||
@@ -308,9 +308,9 @@ describe('DocumentList', () => {
|
||||
documentMenu
|
||||
];
|
||||
|
||||
let nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: ['create', 'update'] } };
|
||||
const nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: ['create', 'update'] } };
|
||||
|
||||
let actions = documentList.getNodeActions(nodeFile);
|
||||
const actions = documentList.getNodeActions(nodeFile);
|
||||
expect(actions.length).toBe(1);
|
||||
expect(actions[0].title).toEqual('FileAction');
|
||||
expect(actions[0].disabled).toBe(true);
|
||||
@@ -382,7 +382,7 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should not disable the action if there is copy permission', () => {
|
||||
let documentMenu = new ContentActionModel({
|
||||
const documentMenu = new ContentActionModel({
|
||||
disableWithNoPermission: true,
|
||||
permission: 'copy',
|
||||
target: 'document',
|
||||
@@ -393,9 +393,9 @@ describe('DocumentList', () => {
|
||||
documentMenu
|
||||
];
|
||||
|
||||
let nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: ['create', 'update'] } };
|
||||
const nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: ['create', 'update'] } };
|
||||
|
||||
let actions = documentList.getNodeActions(nodeFile);
|
||||
const actions = documentList.getNodeActions(nodeFile);
|
||||
expect(actions.length).toBe(1);
|
||||
expect(actions[0].title).toEqual('FileAction');
|
||||
expect(actions[0].disabled).toBeFalsy();
|
||||
@@ -403,7 +403,7 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should disable the action if there is no permission for the folder and disableWithNoPermission true', () => {
|
||||
let documentMenu = new ContentActionModel({
|
||||
const documentMenu = new ContentActionModel({
|
||||
disableWithNoPermission: true,
|
||||
permission: 'delete',
|
||||
target: 'folder',
|
||||
@@ -414,9 +414,9 @@ describe('DocumentList', () => {
|
||||
documentMenu
|
||||
];
|
||||
|
||||
let nodeFile = { entry: { isFolder: true, name: 'xyz', allowableOperations: ['create', 'update'] } };
|
||||
const nodeFile = { entry: { isFolder: true, name: 'xyz', allowableOperations: ['create', 'update'] } };
|
||||
|
||||
let actions = documentList.getNodeActions(nodeFile);
|
||||
const actions = documentList.getNodeActions(nodeFile);
|
||||
expect(actions.length).toBe(1);
|
||||
expect(actions[0].title).toEqual('FolderAction');
|
||||
expect(actions[0].disabled).toBe(true);
|
||||
@@ -424,7 +424,7 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should not disable the action if there is the right permission for the file', () => {
|
||||
let documentMenu = new ContentActionModel({
|
||||
const documentMenu = new ContentActionModel({
|
||||
disableWithNoPermission: true,
|
||||
permission: 'delete',
|
||||
target: 'document',
|
||||
@@ -435,16 +435,16 @@ describe('DocumentList', () => {
|
||||
documentMenu
|
||||
];
|
||||
|
||||
let nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: ['create', 'update', 'delete'] } };
|
||||
const nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: ['create', 'update', 'delete'] } };
|
||||
|
||||
let actions = documentList.getNodeActions(nodeFile);
|
||||
const actions = documentList.getNodeActions(nodeFile);
|
||||
expect(actions.length).toBe(1);
|
||||
expect(actions[0].title).toEqual('FileAction');
|
||||
expect(actions[0].disabled).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should not disable the action if there is the right permission for the folder', () => {
|
||||
let documentMenu = new ContentActionModel({
|
||||
const documentMenu = new ContentActionModel({
|
||||
disableWithNoPermission: true,
|
||||
permission: 'delete',
|
||||
target: 'folder',
|
||||
@@ -455,16 +455,16 @@ describe('DocumentList', () => {
|
||||
documentMenu
|
||||
];
|
||||
|
||||
let nodeFile = { entry: { isFolder: true, name: 'xyz', allowableOperations: ['create', 'update', 'delete'] } };
|
||||
const nodeFile = { entry: { isFolder: true, name: 'xyz', allowableOperations: ['create', 'update', 'delete'] } };
|
||||
|
||||
let actions = documentList.getNodeActions(nodeFile);
|
||||
const actions = documentList.getNodeActions(nodeFile);
|
||||
expect(actions.length).toBe(1);
|
||||
expect(actions[0].title).toEqual('FolderAction');
|
||||
expect(actions[0].disabled).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should not disable the action if there are no permissions for the file and disable with no permission is false', () => {
|
||||
let documentMenu = new ContentActionModel({
|
||||
const documentMenu = new ContentActionModel({
|
||||
permission: 'delete',
|
||||
target: 'document',
|
||||
title: 'FileAction',
|
||||
@@ -475,16 +475,16 @@ describe('DocumentList', () => {
|
||||
documentMenu
|
||||
];
|
||||
|
||||
let nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: null } };
|
||||
const nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: null } };
|
||||
|
||||
let actions = documentList.getNodeActions(nodeFile);
|
||||
const actions = documentList.getNodeActions(nodeFile);
|
||||
expect(actions.length).toBe(1);
|
||||
expect(actions[0].title).toEqual('FileAction');
|
||||
expect(actions[0].disabled).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should not disable the action if there are no permissions for the folder and disable with no permission is false', () => {
|
||||
let documentMenu = new ContentActionModel({
|
||||
const documentMenu = new ContentActionModel({
|
||||
permission: 'delete',
|
||||
target: 'folder',
|
||||
title: 'FolderAction',
|
||||
@@ -495,16 +495,16 @@ describe('DocumentList', () => {
|
||||
documentMenu
|
||||
];
|
||||
|
||||
let nodeFile = { entry: { isFolder: true, name: 'xyz', allowableOperations: null } };
|
||||
const nodeFile = { entry: { isFolder: true, name: 'xyz', allowableOperations: null } };
|
||||
|
||||
let actions = documentList.getNodeActions(nodeFile);
|
||||
const actions = documentList.getNodeActions(nodeFile);
|
||||
expect(actions.length).toBe(1);
|
||||
expect(actions[0].title).toEqual('FolderAction');
|
||||
expect(actions[0].disabled).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should disable the action if there are no permissions for the file and disable with no permission is true', () => {
|
||||
let documentMenu = new ContentActionModel({
|
||||
const documentMenu = new ContentActionModel({
|
||||
permission: 'delete',
|
||||
target: 'document',
|
||||
title: 'FileAction',
|
||||
@@ -515,9 +515,9 @@ describe('DocumentList', () => {
|
||||
documentMenu
|
||||
];
|
||||
|
||||
let nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: null } };
|
||||
const nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: null } };
|
||||
|
||||
let actions = documentList.getNodeActions(nodeFile);
|
||||
const actions = documentList.getNodeActions(nodeFile);
|
||||
expect(actions.length).toBe(1);
|
||||
expect(actions[0].title).toEqual('FileAction');
|
||||
expect(actions[0].disabled).toBeDefined();
|
||||
@@ -525,7 +525,7 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should disable the action if there are no permissions for the folder and disable with no permission is true', () => {
|
||||
let documentMenu = new ContentActionModel({
|
||||
const documentMenu = new ContentActionModel({
|
||||
permission: 'delete',
|
||||
target: 'folder',
|
||||
title: 'FolderAction',
|
||||
@@ -536,9 +536,9 @@ describe('DocumentList', () => {
|
||||
documentMenu
|
||||
];
|
||||
|
||||
let nodeFile = { entry: { isFolder: true, name: 'xyz', allowableOperations: null } };
|
||||
const nodeFile = { entry: { isFolder: true, name: 'xyz', allowableOperations: null } };
|
||||
|
||||
let actions = documentList.getNodeActions(nodeFile);
|
||||
const actions = documentList.getNodeActions(nodeFile);
|
||||
expect(actions.length).toBe(1);
|
||||
expect(actions[0].title).toEqual('FolderAction');
|
||||
expect(actions[0].disabled).toBeDefined();
|
||||
@@ -546,7 +546,7 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should find no content actions', () => {
|
||||
let documentButton = new ContentActionModel();
|
||||
const documentButton = new ContentActionModel();
|
||||
documentButton.target = 'document';
|
||||
documentList.actions = [documentButton];
|
||||
|
||||
@@ -560,8 +560,8 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should emit nodeClick event', (done) => {
|
||||
let node = new FileNode();
|
||||
let disposableClick = documentList.nodeClick.subscribe((e) => {
|
||||
const node = new FileNode();
|
||||
const disposableClick = documentList.nodeClick.subscribe((e) => {
|
||||
expect(e.value).toBe(node);
|
||||
disposableClick.unsubscribe();
|
||||
done();
|
||||
@@ -570,7 +570,7 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should display folder content on click', () => {
|
||||
let node = new FolderNode('<display name>');
|
||||
const node = new FolderNode('<display name>');
|
||||
|
||||
spyOn(documentList, 'loadFolder').and.returnValue(Promise.resolve(true));
|
||||
|
||||
@@ -593,7 +593,7 @@ describe('DocumentList', () => {
|
||||
expect(documentList.navigate).toBe(true);
|
||||
spyOn(documentList, 'loadFolder').and.stub();
|
||||
|
||||
let node = new FileNode();
|
||||
const node = new FileNode();
|
||||
documentList.onNodeClick(node);
|
||||
|
||||
expect(documentList.loadFolder).not.toHaveBeenCalled();
|
||||
@@ -602,7 +602,7 @@ describe('DocumentList', () => {
|
||||
it('should not display folder content on click when navigation is off', () => {
|
||||
spyOn(documentList, 'loadFolder').and.stub();
|
||||
|
||||
let node = new FolderNode('<display name>');
|
||||
const node = new FolderNode('<display name>');
|
||||
documentList.navigate = false;
|
||||
documentList.onNodeClick(node);
|
||||
|
||||
@@ -610,7 +610,7 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should execute context action on callback', () => {
|
||||
let action = {
|
||||
const action = {
|
||||
node: {},
|
||||
model: {}
|
||||
};
|
||||
@@ -629,7 +629,7 @@ describe('DocumentList', () => {
|
||||
it('should subscribe to context action handler', () => {
|
||||
spyOn(documentList, 'loadFolder').and.stub();
|
||||
spyOn(documentList, 'contextActionCallback').and.stub();
|
||||
let value = {};
|
||||
const value = {};
|
||||
documentList.ngOnInit();
|
||||
documentList.contextActionHandler.next(value);
|
||||
expect(documentList.contextActionCallback).toHaveBeenCalledWith(value);
|
||||
@@ -650,8 +650,8 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should emit file preview event on single click', (done) => {
|
||||
let file = new FileNode();
|
||||
let disposablePreview = documentList.preview.subscribe((e) => {
|
||||
const file = new FileNode();
|
||||
const disposablePreview = documentList.preview.subscribe((e) => {
|
||||
expect(e.value).toBe(file);
|
||||
disposablePreview.unsubscribe();
|
||||
done();
|
||||
@@ -661,8 +661,8 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should emit file preview event on double click', (done) => {
|
||||
let file = new FileNode();
|
||||
let disposablePreview = documentList.preview.subscribe((e) => {
|
||||
const file = new FileNode();
|
||||
const disposablePreview = documentList.preview.subscribe((e) => {
|
||||
expect(e.value).toBe(file);
|
||||
disposablePreview.unsubscribe();
|
||||
done();
|
||||
@@ -672,7 +672,7 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should perform folder navigation on single click', () => {
|
||||
let folder = new FolderNode();
|
||||
const folder = new FolderNode();
|
||||
spyOn(documentList, 'navigateTo').and.stub();
|
||||
|
||||
documentList.navigationMode = DocumentListComponent.SINGLE_CLICK_NAVIGATION;
|
||||
@@ -681,7 +681,7 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should perform folder navigation on double click', () => {
|
||||
let folder = new FolderNode();
|
||||
const folder = new FolderNode();
|
||||
spyOn(documentList, 'navigateTo').and.stub();
|
||||
|
||||
documentList.navigationMode = DocumentListComponent.DOUBLE_CLICK_NAVIGATION;
|
||||
@@ -690,7 +690,7 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should not perform folder navigation on double click when single mode', () => {
|
||||
let folder = new FolderNode();
|
||||
const folder = new FolderNode();
|
||||
spyOn(documentList, 'navigateTo').and.stub();
|
||||
|
||||
documentList.navigationMode = DocumentListComponent.SINGLE_CLICK_NAVIGATION;
|
||||
@@ -700,7 +700,7 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should not perform folder navigation on double click when navigation off', () => {
|
||||
let folder = new FolderNode();
|
||||
const folder = new FolderNode();
|
||||
spyOn(documentList, 'navigateTo').and.stub();
|
||||
|
||||
documentList.navigate = false;
|
||||
@@ -711,8 +711,8 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should perform navigation for folder node only', () => {
|
||||
let folder = new FolderNode();
|
||||
let file = new FileNode();
|
||||
const folder = new FolderNode();
|
||||
const file = new FileNode();
|
||||
|
||||
spyOn(documentList, 'loadFolder').and.stub();
|
||||
|
||||
@@ -722,7 +722,7 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should perform navigation through corret linked folder', () => {
|
||||
let linkFolder = new FolderNode();
|
||||
const linkFolder = new FolderNode();
|
||||
linkFolder.entry.id = 'link-folder';
|
||||
linkFolder.entry.nodeType = 'app:folderlink';
|
||||
linkFolder.entry.properties['cm:destination'] = 'normal-folder';
|
||||
@@ -734,7 +734,7 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should require valid node for file preview', () => {
|
||||
let file = new FileNode();
|
||||
const file = new FileNode();
|
||||
file.entry = null;
|
||||
let called = false;
|
||||
|
||||
@@ -750,7 +750,7 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should require valid node for folder navigation', () => {
|
||||
let folder = new FolderNode();
|
||||
const folder = new FolderNode();
|
||||
folder.entry = null;
|
||||
spyOn(documentList, 'navigateTo').and.stub();
|
||||
|
||||
@@ -781,18 +781,18 @@ describe('DocumentList', () => {
|
||||
it('should require node to resolve context menu actions', () => {
|
||||
expect(documentList.getContextActions(null)).toBeNull();
|
||||
|
||||
let file = new FileNode();
|
||||
const file = new FileNode();
|
||||
file.entry = null;
|
||||
|
||||
expect(documentList.getContextActions(file)).toBeNull();
|
||||
});
|
||||
|
||||
it('should fetch context menu actions for a file node', () => {
|
||||
let actionModel: any = {};
|
||||
const actionModel: any = {};
|
||||
spyOn(documentList, 'getNodeActions').and.returnValue([actionModel]);
|
||||
|
||||
let file = new FileNode();
|
||||
let actions = documentList.getContextActions(file);
|
||||
const file = new FileNode();
|
||||
const actions = documentList.getContextActions(file);
|
||||
|
||||
expect(documentList.getNodeActions).toHaveBeenCalledWith(file);
|
||||
expect(actions.length).toBe(1);
|
||||
@@ -802,11 +802,11 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should fetch context menu actions for a folder node', () => {
|
||||
let actionModel: any = {};
|
||||
const actionModel: any = {};
|
||||
spyOn(documentList, 'getNodeActions').and.returnValue([actionModel]);
|
||||
|
||||
let folder = new FolderNode();
|
||||
let actions = documentList.getContextActions(folder);
|
||||
const folder = new FolderNode();
|
||||
const actions = documentList.getContextActions(folder);
|
||||
|
||||
expect(documentList.getNodeActions).toHaveBeenCalledWith(folder);
|
||||
expect(actions.length).toBe(1);
|
||||
@@ -818,19 +818,19 @@ describe('DocumentList', () => {
|
||||
it('should fetch no context menu actions for unknown type', () => {
|
||||
spyOn(documentList, 'getNodeActions').and.stub();
|
||||
|
||||
let node = new FileNode();
|
||||
const node = new FileNode();
|
||||
node.entry.isFile = false;
|
||||
node.entry.isFolder = false;
|
||||
|
||||
let actions = documentList.getContextActions(node);
|
||||
const actions = documentList.getContextActions(node);
|
||||
expect(actions).toBeNull();
|
||||
});
|
||||
|
||||
it('should return null value when no content actions found', () => {
|
||||
spyOn(documentList, 'getNodeActions').and.returnValue([]);
|
||||
|
||||
let file = new FileNode();
|
||||
let actions = documentList.getContextActions(file);
|
||||
const file = new FileNode();
|
||||
const actions = documentList.getContextActions(file);
|
||||
|
||||
expect(actions).toBeNull();
|
||||
expect(documentList.getNodeActions).toHaveBeenCalled();
|
||||
@@ -872,7 +872,7 @@ describe('DocumentList', () => {
|
||||
|
||||
it('should set row filter and reload contents if currentFolderId is set when setting rowFilter', () => {
|
||||
fixture.detectChanges();
|
||||
let filter = <RowFilter> {};
|
||||
const filter = <RowFilter> {};
|
||||
documentList.currentFolderId = 'id';
|
||||
spyOn(documentList.data, 'setFilter').and.callThrough();
|
||||
spyOn(documentListService, 'getFolder').and.callThrough();
|
||||
@@ -894,7 +894,7 @@ describe('DocumentList', () => {
|
||||
|
||||
it('should set image resolver for underlying adapter', () => {
|
||||
fixture.detectChanges();
|
||||
let resolver = <ImageResolver> {};
|
||||
const resolver = <ImageResolver> {};
|
||||
spyOn(documentList.data, 'setImageResolver').and.callThrough();
|
||||
|
||||
documentList.ngOnChanges({ imageResolver: new SimpleChange(null, resolver, true) });
|
||||
@@ -903,7 +903,7 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should emit [nodeClick] event on row click', () => {
|
||||
let node = new NodeMinimalEntry();
|
||||
const node = new NodeMinimalEntry();
|
||||
|
||||
spyOn(documentList, 'onNodeClick').and.callThrough();
|
||||
documentList.onNodeClick(node);
|
||||
@@ -911,7 +911,7 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should emit node-click DOM event', (done) => {
|
||||
let node = new NodeMinimalEntry();
|
||||
const node = new NodeMinimalEntry();
|
||||
|
||||
document.addEventListener('node-click', (customEvent: CustomEvent) => {
|
||||
done();
|
||||
@@ -921,7 +921,7 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should emit [nodeDblClick] event on row double-click', () => {
|
||||
let node = new NodeMinimalEntry();
|
||||
const node = new NodeMinimalEntry();
|
||||
|
||||
spyOn(documentList, 'onNodeDblClick').and.callThrough();
|
||||
documentList.onNodeDblClick(node);
|
||||
@@ -929,7 +929,7 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should emit node-dblclick DOM event', (done) => {
|
||||
let node = new NodeMinimalEntry();
|
||||
const node = new NodeMinimalEntry();
|
||||
|
||||
document.addEventListener('node-dblclick', (customEvent: CustomEvent) => {
|
||||
done();
|
||||
@@ -952,7 +952,7 @@ describe('DocumentList', () => {
|
||||
const error = { message: '{ "error": { "statusCode": 501 } }' };
|
||||
spyOn(documentListService, 'getFolder').and.returnValue(throwError(error));
|
||||
|
||||
let disposableError = documentList.error.subscribe((val) => {
|
||||
const disposableError = documentList.error.subscribe((val) => {
|
||||
expect(val).toBe(error);
|
||||
disposableError.unsubscribe();
|
||||
done();
|
||||
@@ -975,7 +975,7 @@ describe('DocumentList', () => {
|
||||
const error = { message: '{ "error": { "statusCode": 403 } }' };
|
||||
spyOn(documentListService, 'getFolder').and.returnValue(throwError(error));
|
||||
|
||||
let disposableError = documentList.error.subscribe((val) => {
|
||||
const disposableError = documentList.error.subscribe((val) => {
|
||||
expect(val).toBe(error);
|
||||
expect(documentList.noPermission).toBe(true);
|
||||
disposableError.unsubscribe();
|
||||
@@ -1020,7 +1020,7 @@ describe('DocumentList', () => {
|
||||
spyOn(documentListService, 'getFolder').and.returnValue(throwError(error));
|
||||
|
||||
documentList.loadFolder();
|
||||
let clickedFolderNode = new FolderNode('fake-folder-node');
|
||||
const clickedFolderNode = new FolderNode('fake-folder-node');
|
||||
documentList.onNodeDblClick(clickedFolderNode);
|
||||
|
||||
expect(documentList.noPermission).toBeTruthy();
|
||||
@@ -1049,7 +1049,7 @@ describe('DocumentList', () => {
|
||||
it('should emit error when fetch trashcan fails', (done) => {
|
||||
spyOn(apiService.nodesApi, 'getDeletedNodes').and.returnValue(Promise.reject('error'));
|
||||
|
||||
let disposableError = documentList.error.subscribe((val) => {
|
||||
const disposableError = documentList.error.subscribe((val) => {
|
||||
expect(val).toBe('error');
|
||||
disposableError.unsubscribe();
|
||||
done();
|
||||
@@ -1070,7 +1070,7 @@ describe('DocumentList', () => {
|
||||
spyOn(apiService.getInstance().core.sharedlinksApi, 'findSharedLinks')
|
||||
.and.returnValue(Promise.reject('error'));
|
||||
|
||||
let disposableError = documentList.error.subscribe((val) => {
|
||||
const disposableError = documentList.error.subscribe((val) => {
|
||||
expect(val).toBe('error');
|
||||
disposableError.unsubscribe();
|
||||
done();
|
||||
@@ -1089,7 +1089,7 @@ describe('DocumentList', () => {
|
||||
it('should emit error when fetch sites fails', (done) => {
|
||||
spyGetSites.and.returnValue(Promise.reject('error'));
|
||||
|
||||
let disposableError = documentList.error.subscribe((val) => {
|
||||
const disposableError = documentList.error.subscribe((val) => {
|
||||
expect(val).toBe('error');
|
||||
disposableError.unsubscribe();
|
||||
done();
|
||||
@@ -1101,7 +1101,7 @@ describe('DocumentList', () => {
|
||||
it('should assure that sites have name property set', (done) => {
|
||||
fixture.detectChanges();
|
||||
|
||||
let disposableReady = documentList.ready.subscribe((page) => {
|
||||
const disposableReady = documentList.ready.subscribe((page) => {
|
||||
const entriesWithoutName = page.list.entries.filter((item) => !item.entry.name);
|
||||
expect(entriesWithoutName.length).toBe(0);
|
||||
disposableReady.unsubscribe();
|
||||
@@ -1114,7 +1114,7 @@ describe('DocumentList', () => {
|
||||
it('should assure that sites have name property set correctly', (done) => {
|
||||
fixture.detectChanges();
|
||||
|
||||
let disposableReady = documentList.ready.subscribe((page) => {
|
||||
const disposableReady = documentList.ready.subscribe((page) => {
|
||||
const wrongName = page.list.entries.filter((item) => (item.entry.name !== item.entry.title));
|
||||
expect(wrongName.length).toBe(0);
|
||||
disposableReady.unsubscribe();
|
||||
@@ -1136,7 +1136,7 @@ describe('DocumentList', () => {
|
||||
spyOn(apiService.getInstance().core.peopleApi, 'listSiteMembershipsForPerson')
|
||||
.and.returnValue(Promise.reject('error'));
|
||||
|
||||
let disposableError = documentList.error.subscribe((val) => {
|
||||
const disposableError = documentList.error.subscribe((val) => {
|
||||
expect(val).toBe('error');
|
||||
disposableError.unsubscribe();
|
||||
done();
|
||||
@@ -1153,7 +1153,7 @@ describe('DocumentList', () => {
|
||||
documentList.loadFolderByNodeId('-mysites-');
|
||||
expect(peopleApi.listSiteMembershipsForPerson).toHaveBeenCalled();
|
||||
|
||||
let disposableReady = documentList.ready.subscribe((page) => {
|
||||
const disposableReady = documentList.ready.subscribe((page) => {
|
||||
const entriesWithoutName = page.list.entries.filter((item) => !item.entry.name);
|
||||
expect(entriesWithoutName.length).toBe(0);
|
||||
disposableReady.unsubscribe();
|
||||
@@ -1169,7 +1169,7 @@ describe('DocumentList', () => {
|
||||
documentList.loadFolderByNodeId('-mysites-');
|
||||
expect(peopleApi.listSiteMembershipsForPerson).toHaveBeenCalled();
|
||||
|
||||
let disposableReady = documentList.ready.subscribe((page) => {
|
||||
const disposableReady = documentList.ready.subscribe((page) => {
|
||||
const wrongName = page.list.entries.filter((item) => (item.entry.name !== item.entry.title));
|
||||
expect(wrongName.length).toBe(0);
|
||||
disposableReady.unsubscribe();
|
||||
@@ -1188,7 +1188,7 @@ describe('DocumentList', () => {
|
||||
it('should emit error when fetch favorites fails', (done) => {
|
||||
spyFavorite.and.returnValue(Promise.reject('error'));
|
||||
|
||||
let disposableError = documentList.error.subscribe((val) => {
|
||||
const disposableError = documentList.error.subscribe((val) => {
|
||||
expect(val).toBe('error');
|
||||
disposableError.unsubscribe();
|
||||
done();
|
||||
@@ -1200,7 +1200,7 @@ describe('DocumentList', () => {
|
||||
it('should fetch recent', () => {
|
||||
const person = { entry: { id: 'person ' } };
|
||||
|
||||
let getPersonSpy = spyOn(apiService.peopleApi, 'getPerson').and.returnValue(Promise.resolve(person));
|
||||
const getPersonSpy = spyOn(apiService.peopleApi, 'getPerson').and.returnValue(Promise.resolve(person));
|
||||
|
||||
documentList.loadFolderByNodeId('-recent-');
|
||||
|
||||
@@ -1210,7 +1210,7 @@ describe('DocumentList', () => {
|
||||
it('should emit error when fetch recent fails on getPerson call', (done) => {
|
||||
spyOn(apiService.peopleApi, 'getPerson').and.returnValue(Promise.reject('error'));
|
||||
|
||||
let disposableError = documentList.error.subscribe((val) => {
|
||||
const disposableError = documentList.error.subscribe((val) => {
|
||||
expect(val).toBe('error');
|
||||
disposableError.unsubscribe();
|
||||
done();
|
||||
@@ -1222,7 +1222,7 @@ describe('DocumentList', () => {
|
||||
it('should emit error when fetch recent fails on search call', (done) => {
|
||||
spyOn(customResourcesService, 'loadFolderByNodeId').and.returnValue(throwError('error'));
|
||||
|
||||
let disposableError = documentList.error.subscribe((val) => {
|
||||
const disposableError = documentList.error.subscribe((val) => {
|
||||
expect(val).toBe('error');
|
||||
disposableError.unsubscribe();
|
||||
done();
|
||||
@@ -1297,7 +1297,7 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should reset the pagination when enter in a new folder', () => {
|
||||
let folder = new FolderNode();
|
||||
const folder = new FolderNode();
|
||||
documentList.navigationMode = DocumentListComponent.SINGLE_CLICK_NAVIGATION;
|
||||
documentList.updatePagination({
|
||||
maxItems: 10,
|
||||
|
||||
@@ -334,7 +334,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
|
||||
getContextActions(node: NodeEntry) {
|
||||
if (node && node.entry) {
|
||||
let actions = this.getNodeActions(node);
|
||||
const actions = this.getNodeActions(node);
|
||||
if (actions && actions.length > 0) {
|
||||
return actions.map((currentAction: ContentActionModel) => {
|
||||
return {
|
||||
@@ -419,7 +419,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
this.data.setColumns(schema);
|
||||
}
|
||||
|
||||
let columns = this.data.getColumns();
|
||||
const columns = this.data.getColumns();
|
||||
if (!columns || columns.length === 0) {
|
||||
this.setupDefaultColumns(this._currentFolderId);
|
||||
}
|
||||
@@ -445,7 +445,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
|
||||
if (this.data) {
|
||||
if (changes.node && changes.node.currentValue) {
|
||||
let merge = this._pagination ? this._pagination.merge : false;
|
||||
const merge = this._pagination ? this._pagination.merge : false;
|
||||
|
||||
this.data.loadPage(changes.node.currentValue, merge);
|
||||
this.onDataReady(changes.node.currentValue);
|
||||
@@ -492,7 +492,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
return actions;
|
||||
}
|
||||
|
||||
let actionsByTarget = this.actions
|
||||
const actionsByTarget = this.actions
|
||||
.filter((entry) => {
|
||||
const isVisible = (typeof entry.visible === 'function')
|
||||
? entry.visible(node)
|
||||
@@ -653,7 +653,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
}
|
||||
|
||||
getSourceNodeWithPath(nodeId: string): Observable<NodeEntry> {
|
||||
let getSourceObservable = this.documentListService.getFolderNode(nodeId, this.includeFields);
|
||||
const getSourceObservable = this.documentListService.getFolderNode(nodeId, this.includeFields);
|
||||
|
||||
getSourceObservable.subscribe((nodeEntry: NodeEntry) => {
|
||||
this.folderNode = nodeEntry.entry;
|
||||
@@ -784,8 +784,8 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
|
||||
onShowRowContextMenu(event: DataCellEvent) {
|
||||
if (this.contextMenuActions) {
|
||||
let args = event.value;
|
||||
let node = (<ShareDataRow> args.row).node;
|
||||
const args = event.value;
|
||||
const node = (<ShareDataRow> args.row).node;
|
||||
if (node) {
|
||||
args.actions = this.getContextActions(node) || [];
|
||||
}
|
||||
@@ -794,8 +794,8 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
|
||||
onShowRowActionsMenu(event: DataCellEvent) {
|
||||
if (this.contentActions) {
|
||||
let args = event.value;
|
||||
let node = (<ShareDataRow> args.row).node;
|
||||
const args = event.value;
|
||||
const node = (<ShareDataRow> args.row).node;
|
||||
if (node) {
|
||||
args.actions = this.getNodeActions(node) || [];
|
||||
}
|
||||
@@ -804,9 +804,9 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
|
||||
onExecuteRowAction(event: DataRowActionEvent) {
|
||||
if (this.contentActions) {
|
||||
let args = event.value;
|
||||
let node = (<ShareDataRow> args.row).node;
|
||||
let action = (<ContentActionModel> args.action);
|
||||
const args = event.value;
|
||||
const node = (<ShareDataRow> args.row).node;
|
||||
const action = (<ContentActionModel> args.action);
|
||||
this.executeContentAction(node, action);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ describe('ShareDataTableAdapter', () => {
|
||||
let contentService: ContentService;
|
||||
|
||||
beforeEach(() => {
|
||||
let imageUrl: string = 'http://<addresss>';
|
||||
const imageUrl: string = 'http://<addresss>';
|
||||
contentService = new ContentService(null, null, null, null);
|
||||
documentListService = new DocumentListService(null, contentService, null, null, null);
|
||||
spyOn(documentListService, 'getDocumentThumbnailUrl').and.returnValue(imageUrl);
|
||||
@@ -59,8 +59,8 @@ describe('ShareDataTableAdapter', () => {
|
||||
});
|
||||
|
||||
it('should setup rows and columns with constructor', () => {
|
||||
let schema = [<DataColumn> {}];
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, schema);
|
||||
const schema = [<DataColumn> {}];
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, schema);
|
||||
|
||||
expect(adapter.getRows()).toEqual([]);
|
||||
expect(adapter.getColumns()).toEqual(schema);
|
||||
@@ -72,15 +72,15 @@ describe('ShareDataTableAdapter', () => {
|
||||
});
|
||||
|
||||
it('should set new columns', () => {
|
||||
let columns = [<DataColumn> {}, <DataColumn> {}];
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
const columns = [<DataColumn> {}, <DataColumn> {}];
|
||||
const 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, contentService, columns);
|
||||
const columns = [<DataColumn> {}, <DataColumn> {}];
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, columns);
|
||||
|
||||
expect(adapter.getColumns()).toEqual(columns);
|
||||
adapter.setColumns(null);
|
||||
@@ -88,8 +88,8 @@ describe('ShareDataTableAdapter', () => {
|
||||
});
|
||||
|
||||
it('should set new rows', () => {
|
||||
let rows = [<DataRow> {}, <DataRow> {}];
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
const rows = [<DataRow> {}, <DataRow> {}];
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
expect(adapter.getRows()).toEqual([]);
|
||||
adapter.setRows(rows);
|
||||
@@ -97,8 +97,8 @@ describe('ShareDataTableAdapter', () => {
|
||||
});
|
||||
|
||||
it('should reset rows', () => {
|
||||
let rows = [<DataRow> {}, <DataRow> {}];
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
const rows = [<DataRow> {}, <DataRow> {}];
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
adapter.setRows(rows);
|
||||
expect(adapter.getRows()).toEqual(rows);
|
||||
@@ -108,61 +108,61 @@ describe('ShareDataTableAdapter', () => {
|
||||
});
|
||||
|
||||
it('should sort new rows', () => {
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
spyOn(adapter, 'sort').and.callThrough();
|
||||
|
||||
let rows = [<DataRow> {}];
|
||||
const rows = [<DataRow> {}];
|
||||
adapter.setRows(rows);
|
||||
|
||||
expect(adapter.sort).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should fail when getting value for missing row', () => {
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
let check = () => {
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
const check = () => {
|
||||
return adapter.getValue(null, <DataColumn> {});
|
||||
};
|
||||
expect(check).toThrowError(adapter.ERR_ROW_NOT_FOUND);
|
||||
});
|
||||
|
||||
it('should fail when getting value for missing column', () => {
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
let check = () => {
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
const check = () => {
|
||||
return adapter.getValue(<DataRow> {}, null);
|
||||
};
|
||||
expect(check).toThrowError(adapter.ERR_COL_NOT_FOUND);
|
||||
});
|
||||
|
||||
it('should return date value as string', () => {
|
||||
let rawValue = new Date(2015, 6, 15, 21, 43, 11); // Wed Jul 15 2015 21:43:11 GMT+0100 (BST);
|
||||
const rawValue = new Date(2015, 6, 15, 21, 43, 11); // Wed Jul 15 2015 21:43:11 GMT+0100 (BST);
|
||||
|
||||
let file = new FileNode();
|
||||
const file = new FileNode();
|
||||
file.entry.createdAt = rawValue;
|
||||
|
||||
let col = <DataColumn> {
|
||||
const col = <DataColumn> {
|
||||
key: 'createdAt',
|
||||
type: 'string'
|
||||
};
|
||||
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
const row = new ShareDataRow(file, contentService, null);
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
const value = adapter.getValue(row, col);
|
||||
expect(value).toBe(rawValue);
|
||||
});
|
||||
|
||||
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, contentService, null);
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let file = new FileNode();
|
||||
const file = new FileNode();
|
||||
file.entry.content.mimeType = null;
|
||||
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
const row = new ShareDataRow(file, contentService, null);
|
||||
const col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
const value = adapter.getValue(row, col);
|
||||
expect(value).toContain(`assets/images/ft_ic_miscellaneous`);
|
||||
expect(value).toContain(`svg`);
|
||||
});
|
||||
@@ -170,42 +170,42 @@ 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, contentService, null);
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let file = new FileNode();
|
||||
const file = new FileNode();
|
||||
file.entry.content = null;
|
||||
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
const row = new ShareDataRow(file, contentService, null);
|
||||
const col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
const value = adapter.getValue(row, col);
|
||||
expect(value).toContain(`assets/images/ft_ic_miscellaneous`);
|
||||
expect(value).toContain(`svg`);
|
||||
});
|
||||
|
||||
it('should return image value unmodified', () => {
|
||||
let imageUrl = 'http://<address>';
|
||||
const imageUrl = 'http://<address>';
|
||||
|
||||
let file = new FileNode();
|
||||
const file = new FileNode();
|
||||
file.entry['icon'] = imageUrl;
|
||||
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
let col = <DataColumn> { type: 'image', key: 'icon' };
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
const row = new ShareDataRow(file, contentService, null);
|
||||
const col = <DataColumn> { type: 'image', key: 'icon' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
const value = adapter.getValue(row, col);
|
||||
expect(value).toBe(imageUrl);
|
||||
});
|
||||
|
||||
it('should resolve folder icon', () => {
|
||||
spyOn(documentListService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_folder.svg`);
|
||||
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let row = new ShareDataRow(new FolderNode(), contentService, null);
|
||||
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
const row = new ShareDataRow(new FolderNode(), contentService, null);
|
||||
const col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
const value = adapter.getValue(row, col);
|
||||
expect(value).toContain(`assets/images/ft_ic_folder`);
|
||||
expect(value).toContain(`svg`);
|
||||
});
|
||||
@@ -213,12 +213,12 @@ 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, contentService, null);
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let row = new ShareDataRow(new SmartFolderNode(), contentService, null);
|
||||
let col = <DataColumn> { type: 'folder', key: '$thumbnail' };
|
||||
const row = new ShareDataRow(new SmartFolderNode(), contentService, null);
|
||||
const col = <DataColumn> { type: 'folder', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
const value = adapter.getValue(row, col);
|
||||
expect(value).toContain(`assets/images/ft_ic_smart_folder`);
|
||||
expect(value).toContain(`svg`);
|
||||
});
|
||||
@@ -226,12 +226,12 @@ 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, contentService, null);
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let row = new ShareDataRow(new LinkFolderNode(), contentService, null);
|
||||
let col = <DataColumn> { type: 'folder', key: '$thumbnail' };
|
||||
const row = new ShareDataRow(new LinkFolderNode(), contentService, null);
|
||||
const col = <DataColumn> { type: 'folder', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
const value = adapter.getValue(row, col);
|
||||
expect(value).toContain(`assets/images/ft_ic_folder_shortcut_link`);
|
||||
expect(value).toContain(`svg`);
|
||||
});
|
||||
@@ -239,26 +239,26 @@ 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, contentService, null);
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let row = new ShareDataRow(new RuleFolderNode(), contentService, null);
|
||||
let col = <DataColumn> { type: 'folder', key: '$thumbnail' };
|
||||
const row = new ShareDataRow(new RuleFolderNode(), contentService, null);
|
||||
const col = <DataColumn> { type: 'folder', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
const value = adapter.getValue(row, col);
|
||||
expect(value).toContain(`assets/images/ft_ic_folder_rule`);
|
||||
expect(value).toContain(`svg`);
|
||||
});
|
||||
|
||||
it('should resolve file thumbnail', () => {
|
||||
let imageUrl = 'http://<addresss>';
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
const imageUrl = 'http://<addresss>';
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
adapter.thumbnails = true;
|
||||
|
||||
let file = new FileNode();
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
const file = new FileNode();
|
||||
const row = new ShareDataRow(file, contentService, null);
|
||||
const col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
const value = adapter.getValue(row, col);
|
||||
expect(value).toBe(imageUrl);
|
||||
expect(documentListService.getDocumentThumbnailUrl).toHaveBeenCalledWith(file);
|
||||
});
|
||||
@@ -266,45 +266,45 @@ 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, contentService, null);
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let file = new FileNode();
|
||||
const file = new FileNode();
|
||||
file.entry.isFile = false;
|
||||
file.entry.isFolder = false;
|
||||
file.entry.content = null;
|
||||
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
const row = new ShareDataRow(file, contentService, null);
|
||||
const col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
const value = adapter.getValue(row, col);
|
||||
expect(value).toContain(`assets/images/ft_ic_miscellaneous`);
|
||||
expect(value).toContain(`svg`);
|
||||
});
|
||||
|
||||
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, contentService, null);
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let file = new FileNode();
|
||||
const file = new FileNode();
|
||||
file.entry.isFile = false;
|
||||
file.entry.isFolder = false;
|
||||
file.entry.content.mimeType = 'image/png';
|
||||
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
const row = new ShareDataRow(file, contentService, null);
|
||||
const col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
const value = adapter.getValue(row, col);
|
||||
expect(value).toContain(`assets/images/ft_ic_raster_image`);
|
||||
expect(value).toContain(`svg`);
|
||||
});
|
||||
|
||||
it('should put folders on top upon sort', () => {
|
||||
let file1 = new FileNode('file1');
|
||||
let file2 = new FileNode('file2');
|
||||
let folder = new FolderNode();
|
||||
const file1 = new FileNode('file1');
|
||||
const file2 = new FileNode('file2');
|
||||
const folder = new FolderNode();
|
||||
|
||||
let col = <DataColumn> { key: 'name' };
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, [col]);
|
||||
const col = <DataColumn> { key: 'name' };
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, [col]);
|
||||
adapter.setSorting(new DataSorting('name', 'asc'));
|
||||
|
||||
adapter.setRows([
|
||||
@@ -313,21 +313,21 @@ describe('ShareDataTableAdapter', () => {
|
||||
new ShareDataRow(folder, contentService, null)
|
||||
]);
|
||||
|
||||
let sorted = adapter.getRows();
|
||||
const sorted = adapter.getRows();
|
||||
expect((<ShareDataRow> sorted[0]).node).toBe(folder);
|
||||
expect((<ShareDataRow> sorted[1]).node).toBe(file1);
|
||||
expect((<ShareDataRow> sorted[2]).node).toBe(file2);
|
||||
});
|
||||
|
||||
it('should sort by dates up to ms', () => {
|
||||
let file1 = new FileNode('file1');
|
||||
const file1 = new FileNode('file1');
|
||||
file1.entry['dateProp'] = new Date(2016, 6, 30, 13, 14, 1);
|
||||
|
||||
let file2 = new FileNode('file2');
|
||||
const file2 = new FileNode('file2');
|
||||
file2.entry['dateProp'] = new Date(2016, 6, 30, 13, 14, 2);
|
||||
|
||||
let col = <DataColumn> { key: 'dateProp' };
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, [col]);
|
||||
const col = <DataColumn> { key: 'dateProp' };
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, [col]);
|
||||
|
||||
adapter.setRows([
|
||||
new ShareDataRow(file2, contentService, null),
|
||||
@@ -336,7 +336,7 @@ describe('ShareDataTableAdapter', () => {
|
||||
|
||||
adapter.sort('dateProp', 'asc');
|
||||
|
||||
let rows = adapter.getRows();
|
||||
const rows = adapter.getRows();
|
||||
expect((<ShareDataRow> rows[0]).node).toBe(file1);
|
||||
expect((<ShareDataRow> rows[1]).node).toBe(file2);
|
||||
|
||||
@@ -346,18 +346,18 @@ describe('ShareDataTableAdapter', () => {
|
||||
});
|
||||
|
||||
it('should sort by file size', () => {
|
||||
let file1 = new FileNode('file1');
|
||||
let file2 = new FileNode('file2');
|
||||
let file3 = new FileNode('file3');
|
||||
let file4 = new FileNode('file4');
|
||||
const file1 = new FileNode('file1');
|
||||
const file2 = new FileNode('file2');
|
||||
const file3 = new FileNode('file3');
|
||||
const file4 = new FileNode('file4');
|
||||
|
||||
file1.entry.content.sizeInBytes = 146; // 146 bytes
|
||||
file2.entry.content.sizeInBytes = 10075; // 9.84 KB
|
||||
file3.entry.content.sizeInBytes = 4224120; // 4.03 MB
|
||||
file4.entry.content.sizeInBytes = 2852791665; // 2.66 GB
|
||||
|
||||
let col = <DataColumn> { key: 'content.sizeInBytes' };
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, [col]);
|
||||
const col = <DataColumn> { key: 'content.sizeInBytes' };
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, [col]);
|
||||
|
||||
adapter.setRows([
|
||||
new ShareDataRow(file3, contentService, null),
|
||||
@@ -367,7 +367,7 @@ describe('ShareDataTableAdapter', () => {
|
||||
]);
|
||||
|
||||
adapter.sort('content.sizeInBytes', 'asc');
|
||||
let rows = adapter.getRows();
|
||||
const rows = adapter.getRows();
|
||||
|
||||
expect((<ShareDataRow> rows[0]).node).toBe(file1);
|
||||
expect((<ShareDataRow> rows[1]).node).toBe(file2);
|
||||
@@ -382,15 +382,15 @@ describe('ShareDataTableAdapter', () => {
|
||||
});
|
||||
|
||||
it('should sort by name', () => {
|
||||
let file1 = new FileNode('file1');
|
||||
let file2 = new FileNode('file11');
|
||||
let file3 = new FileNode('file20');
|
||||
let file4 = new FileNode('file11-1'); // auto rename
|
||||
let file5 = new FileNode('a');
|
||||
let file6 = new FileNode('b');
|
||||
const file1 = new FileNode('file1');
|
||||
const file2 = new FileNode('file11');
|
||||
const file3 = new FileNode('file20');
|
||||
const file4 = new FileNode('file11-1'); // auto rename
|
||||
const file5 = new FileNode('a');
|
||||
const file6 = new FileNode('b');
|
||||
|
||||
let col = <DataColumn> { key: 'name' };
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, [col]);
|
||||
const col = <DataColumn> { key: 'name' };
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, [col]);
|
||||
|
||||
adapter.setRows([
|
||||
new ShareDataRow(file4, contentService, null),
|
||||
@@ -402,7 +402,7 @@ describe('ShareDataTableAdapter', () => {
|
||||
]);
|
||||
|
||||
adapter.sort('name', 'asc');
|
||||
let rows = adapter.getRows();
|
||||
const rows = adapter.getRows();
|
||||
|
||||
expect((<ShareDataRow> rows[0]).node).toBe(file5);
|
||||
expect((<ShareDataRow> rows[1]).node).toBe(file6);
|
||||
@@ -423,8 +423,8 @@ describe('ShareDataTableAdapter', () => {
|
||||
describe('ShareDataRow', () => {
|
||||
|
||||
it('should wrap node', () => {
|
||||
let file = new FileNode();
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
const file = new FileNode();
|
||||
const row = new ShareDataRow(file, contentService, null);
|
||||
expect(row.node).toBe(file);
|
||||
});
|
||||
|
||||
@@ -435,37 +435,37 @@ describe('ShareDataTableAdapter', () => {
|
||||
});
|
||||
|
||||
it('should resolve value from node entry', () => {
|
||||
let file = new FileNode('test');
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
const file = new FileNode('test');
|
||||
const 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, contentService, null);
|
||||
const file = new FileNode('test');
|
||||
const row = new ShareDataRow(file, contentService, null);
|
||||
|
||||
expect(row.hasValue('name')).toBeTruthy();
|
||||
expect(row.hasValue('missing')).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should be set as drop target when user has permission for that node', () => {
|
||||
let file = new FolderNode('test');
|
||||
const file = new FolderNode('test');
|
||||
file.entry['allowableOperations'] = ['create'];
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
const 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, contentService, null);
|
||||
const file = new FolderNode('test');
|
||||
const 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, contentService, null);
|
||||
const file = new FileNode('test');
|
||||
const row = new ShareDataRow(file, contentService, null);
|
||||
|
||||
expect(row.isDropTarget).toBeFalsy();
|
||||
});
|
||||
|
||||
@@ -96,8 +96,8 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
if (!col) {
|
||||
throw new Error(this.ERR_COL_NOT_FOUND);
|
||||
}
|
||||
let dataRow: ShareDataRow = <ShareDataRow> row;
|
||||
let value: any = row.getValue(col.key);
|
||||
const dataRow: ShareDataRow = <ShareDataRow> row;
|
||||
const value: any = row.getValue(col.key);
|
||||
if (dataRow.cache[col.key] !== undefined) {
|
||||
return dataRow.cache[col.key];
|
||||
}
|
||||
@@ -105,7 +105,7 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
if (col.key === '$thumbnail') {
|
||||
|
||||
if (this.imageResolver) {
|
||||
let resolved = this.imageResolver(row, col);
|
||||
const resolved = this.imageResolver(row, col);
|
||||
if (resolved) {
|
||||
return resolved;
|
||||
}
|
||||
@@ -136,7 +136,7 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
if (col.type === 'image') {
|
||||
|
||||
if (this.imageResolver) {
|
||||
let resolved = this.imageResolver(row, col);
|
||||
const resolved = this.imageResolver(row, col);
|
||||
if (resolved) {
|
||||
return resolved;
|
||||
}
|
||||
@@ -157,7 +157,7 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
}
|
||||
|
||||
sort(key?: string, direction?: string): void {
|
||||
let sorting = this.sorting || new DataSorting();
|
||||
const sorting = this.sorting || new DataSorting();
|
||||
if (key) {
|
||||
sorting.key = key;
|
||||
sorting.direction = direction || 'asc';
|
||||
@@ -186,13 +186,13 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
}
|
||||
|
||||
isSmartFolder(node: any) {
|
||||
let nodeAspects = this.getNodeAspectNames(node);
|
||||
const nodeAspects = this.getNodeAspectNames(node);
|
||||
return nodeAspects.indexOf('smf:customConfigSmartFolder') > -1 ||
|
||||
(nodeAspects.indexOf('smf:systemConfigSmartFolder') > -1);
|
||||
}
|
||||
|
||||
isRuleFolder(node: any) {
|
||||
let nodeAspects = this.getNodeAspectNames(node);
|
||||
const nodeAspects = this.getNodeAspectNames(node);
|
||||
return nodeAspects.indexOf('rule:rules') > -1 ||
|
||||
(nodeAspects.indexOf('rule:rules') > -1);
|
||||
}
|
||||
@@ -249,7 +249,7 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
let shareDataRows: ShareDataRow[] = [];
|
||||
|
||||
if (nodePaging && nodePaging.list) {
|
||||
let nodeEntries: NodeEntry[] = nodePaging.list.entries;
|
||||
const nodeEntries: NodeEntry[] = nodePaging.list.entries;
|
||||
if (nodeEntries && nodeEntries.length > 0) {
|
||||
shareDataRows = nodeEntries.map((item) => new ShareDataRow(item, this.contentService, this.permissionsStyle, this.thumbnailService));
|
||||
|
||||
@@ -260,11 +260,11 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
if (this.sortingMode !== 'server') {
|
||||
// Sort by first sortable or just first column
|
||||
if (this.columns && this.columns.length > 0) {
|
||||
let sorting = this.getSorting();
|
||||
const sorting = this.getSorting();
|
||||
if (sorting) {
|
||||
this.sortRows(shareDataRows, sorting);
|
||||
} else {
|
||||
let sortable = this.columns.filter((c) => c.sortable);
|
||||
const sortable = this.columns.filter((c) => c.sortable);
|
||||
if (sortable.length > 0) {
|
||||
this.sort(sortable[0].key, 'asc');
|
||||
} else {
|
||||
@@ -277,8 +277,8 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
}
|
||||
|
||||
if (merge) {
|
||||
let listPrunedDuplicate = shareDataRows.filter((elementToFilter: any) => {
|
||||
let isPresent = this.rows.find((currentRow: any) => {
|
||||
const listPrunedDuplicate = shareDataRows.filter((elementToFilter: any) => {
|
||||
const isPresent = this.rows.find((currentRow: any) => {
|
||||
return currentRow.obj.entry.id === elementToFilter.obj.entry.id;
|
||||
});
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ export class CustomResourcesService {
|
||||
* @returns List of favorite files
|
||||
*/
|
||||
loadFavorites(pagination: PaginationModel, includeFields: string[] = []): Observable<NodePaging> {
|
||||
let includeFieldsRequest = this.getIncludesFields(includeFields);
|
||||
const includeFieldsRequest = this.getIncludesFields(includeFields);
|
||||
|
||||
const options = {
|
||||
maxItems: pagination.maxItems,
|
||||
@@ -115,7 +115,7 @@ export class CustomResourcesService {
|
||||
return new Observable((observer) => {
|
||||
this.apiService.favoritesApi.getFavorites('-me-', options)
|
||||
.then((result: FavoritePaging) => {
|
||||
let page: FavoritePaging = {
|
||||
const page: FavoritePaging = {
|
||||
list: {
|
||||
entries: result.list.entries
|
||||
.map(({ entry: { target } }: any) => ({
|
||||
@@ -157,7 +157,7 @@ export class CustomResourcesService {
|
||||
return new Observable((observer) => {
|
||||
this.apiService.peopleApi.listSiteMembershipsForPerson('-me-', options)
|
||||
.then((result: SiteRolePaging) => {
|
||||
let page: SiteMemberPaging = new SiteMemberPaging( {
|
||||
const page: SiteMemberPaging = new SiteMemberPaging( {
|
||||
list: {
|
||||
entries: result.list.entries
|
||||
.map(({ entry: { site } }: any) => {
|
||||
@@ -219,7 +219,7 @@ export class CustomResourcesService {
|
||||
* @returns List of deleted items
|
||||
*/
|
||||
loadTrashcan(pagination: PaginationModel, includeFields: string[] = []): Observable<DeletedNodesPaging> {
|
||||
let includeFieldsRequest = this.getIncludesFields(includeFields);
|
||||
const includeFieldsRequest = this.getIncludesFields(includeFields);
|
||||
|
||||
const options = {
|
||||
include: includeFieldsRequest,
|
||||
@@ -239,7 +239,7 @@ export class CustomResourcesService {
|
||||
* @returns List of shared links
|
||||
*/
|
||||
loadSharedLinks(pagination: PaginationModel, includeFields: string[] = []): Observable<SharedLinkPaging> {
|
||||
let includeFieldsRequest = this.getIncludesFields(includeFields);
|
||||
const includeFieldsRequest = this.getIncludesFields(includeFields);
|
||||
|
||||
const options = {
|
||||
include: includeFieldsRequest,
|
||||
|
||||
@@ -22,14 +22,12 @@ import { FileNode, FolderNode } from '../../mock';
|
||||
import { ContentActionHandler } from '../models/content-action.model';
|
||||
import { DocumentActionsService } from './document-actions.service';
|
||||
import { DocumentListService } from './document-list.service';
|
||||
import { NodeActionsService } from './node-actions.service';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
describe('DocumentActionsService', () => {
|
||||
|
||||
let service: DocumentActionsService;
|
||||
let documentListService: DocumentListService;
|
||||
let nodeActionsService: NodeActionsService;
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
@@ -38,8 +36,8 @@ describe('DocumentActionsService', () => {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
let contentService = new ContentService(null, null, null, null);
|
||||
let alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
||||
const contentService = new ContentService(null, null, null, null);
|
||||
const alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
||||
|
||||
documentListService = new DocumentListService(null, contentService, alfrescoApiService, null, null);
|
||||
service = new DocumentActionsService(null, null, new TranslationMock(), documentListService, contentService);
|
||||
@@ -54,7 +52,7 @@ describe('DocumentActionsService', () => {
|
||||
});
|
||||
|
||||
it('should register custom action handler', () => {
|
||||
let handler: ContentActionHandler = function (obj: any) {
|
||||
const handler: ContentActionHandler = function (obj: any) {
|
||||
};
|
||||
service.setHandler('<key>', handler);
|
||||
expect(service.getHandler('<key>')).toBe(handler);
|
||||
@@ -65,7 +63,7 @@ describe('DocumentActionsService', () => {
|
||||
});
|
||||
|
||||
it('should be case insensitive for keys', () => {
|
||||
let handler: ContentActionHandler = function (obj: any) {
|
||||
const handler: ContentActionHandler = function (obj: any) {
|
||||
};
|
||||
service.setHandler('<key>', handler);
|
||||
expect(service.getHandler('<KEY>')).toBe(handler);
|
||||
@@ -77,10 +75,10 @@ describe('DocumentActionsService', () => {
|
||||
});
|
||||
|
||||
it('should allow action execution only when service available', () => {
|
||||
let file = new FileNode();
|
||||
const file = new FileNode();
|
||||
expect(service.canExecuteAction(file)).toBeTruthy();
|
||||
|
||||
service = new DocumentActionsService(nodeActionsService, null, null);
|
||||
service = new DocumentActionsService(null, null, null);
|
||||
expect(service.canExecuteAction(file)).toBeFalsy();
|
||||
});
|
||||
|
||||
@@ -91,7 +89,7 @@ describe('DocumentActionsService', () => {
|
||||
});
|
||||
|
||||
it('should set new handler only by key', () => {
|
||||
let handler: ContentActionHandler = function (obj: any) {
|
||||
const handler: ContentActionHandler = function (obj: any) {
|
||||
};
|
||||
expect(service.setHandler(null, handler)).toBeFalsy();
|
||||
expect(service.setHandler('', handler)).toBeFalsy();
|
||||
@@ -112,7 +110,7 @@ describe('DocumentActionsService', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
let file = new FileNode();
|
||||
const file = new FileNode();
|
||||
service.getHandler('delete')(file);
|
||||
|
||||
});
|
||||
@@ -120,7 +118,7 @@ describe('DocumentActionsService', () => {
|
||||
it('should call the error on the returned Observable if there are no permissions', (done) => {
|
||||
spyOn(documentListService, 'deleteNode').and.returnValue(of(true));
|
||||
|
||||
let file = new FileNode();
|
||||
const file = new FileNode();
|
||||
const deleteObservable = service.getHandler('delete')(file);
|
||||
|
||||
deleteObservable.subscribe({
|
||||
@@ -134,9 +132,9 @@ describe('DocumentActionsService', () => {
|
||||
it('should delete the file node if there is the delete permission', () => {
|
||||
spyOn(documentListService, 'deleteNode').and.returnValue(of(true));
|
||||
|
||||
let permission = 'delete';
|
||||
let file = new FileNode();
|
||||
let fileWithPermission: any = file;
|
||||
const permission = 'delete';
|
||||
const file = new FileNode();
|
||||
const fileWithPermission: any = file;
|
||||
fileWithPermission.entry.allowableOperations = [permission];
|
||||
service.getHandler('delete')(fileWithPermission, null, permission);
|
||||
|
||||
@@ -153,9 +151,9 @@ describe('DocumentActionsService', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
let permission = 'delete';
|
||||
let file = new FileNode();
|
||||
let fileWithPermission: any = file;
|
||||
const permission = 'delete';
|
||||
const file = new FileNode();
|
||||
const fileWithPermission: any = file;
|
||||
fileWithPermission.entry.allowableOperations = ['create', 'update'];
|
||||
service.getHandler('delete')(fileWithPermission, null, permission);
|
||||
});
|
||||
@@ -163,9 +161,9 @@ describe('DocumentActionsService', () => {
|
||||
it('should delete the file node if there is the delete and others permission ', () => {
|
||||
spyOn(documentListService, 'deleteNode').and.returnValue(of(true));
|
||||
|
||||
let permission = 'delete';
|
||||
let file = new FileNode();
|
||||
let fileWithPermission: any = file;
|
||||
const permission = 'delete';
|
||||
const file = new FileNode();
|
||||
const fileWithPermission: any = file;
|
||||
fileWithPermission.entry.allowableOperations = ['create', 'update', permission];
|
||||
service.getHandler('delete')(fileWithPermission, null, permission);
|
||||
|
||||
@@ -179,9 +177,9 @@ describe('DocumentActionsService', () => {
|
||||
it('should delete file node', () => {
|
||||
spyOn(documentListService, 'deleteNode').and.returnValue(of(true));
|
||||
|
||||
let permission = 'delete';
|
||||
let file = new FileNode();
|
||||
let fileWithPermission: any = file;
|
||||
const permission = 'delete';
|
||||
const file = new FileNode();
|
||||
const fileWithPermission: any = file;
|
||||
fileWithPermission.entry.allowableOperations = [permission];
|
||||
const deleteObservable = service.getHandler('delete')(fileWithPermission, null, permission);
|
||||
|
||||
@@ -192,13 +190,13 @@ describe('DocumentActionsService', () => {
|
||||
it('should support deletion only file node', () => {
|
||||
spyOn(documentListService, 'deleteNode').and.returnValue(of(true));
|
||||
|
||||
let folder = new FolderNode();
|
||||
const folder = new FolderNode();
|
||||
service.getHandler('delete')(folder);
|
||||
expect(documentListService.deleteNode).not.toHaveBeenCalled();
|
||||
|
||||
let permission = 'delete';
|
||||
let file = new FileNode();
|
||||
let fileWithPermission: any = file;
|
||||
const permission = 'delete';
|
||||
const file = new FileNode();
|
||||
const fileWithPermission: any = file;
|
||||
fileWithPermission.entry.allowableOperations = [permission];
|
||||
service.getHandler('delete')(fileWithPermission, null, permission);
|
||||
expect(documentListService.deleteNode).toHaveBeenCalled();
|
||||
@@ -207,7 +205,7 @@ describe('DocumentActionsService', () => {
|
||||
it('should require node id to delete', () => {
|
||||
spyOn(documentListService, 'deleteNode').and.returnValue(of(true));
|
||||
|
||||
let file = new FileNode();
|
||||
const file = new FileNode();
|
||||
file.entry.id = null;
|
||||
service.getHandler('delete')(file);
|
||||
|
||||
@@ -221,10 +219,10 @@ describe('DocumentActionsService', () => {
|
||||
});
|
||||
spyOn(documentListService, 'deleteNode').and.returnValue(of(true));
|
||||
|
||||
let target = jasmine.createSpyObj('obj', ['reload']);
|
||||
let permission = 'delete';
|
||||
let file = new FileNode();
|
||||
let fileWithPermission: any = file;
|
||||
const target = jasmine.createSpyObj('obj', ['reload']);
|
||||
const permission = 'delete';
|
||||
const file = new FileNode();
|
||||
const fileWithPermission: any = file;
|
||||
fileWithPermission.entry.allowableOperations = [permission];
|
||||
service.getHandler('delete')(fileWithPermission, target, permission);
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ export class DocumentActionsService {
|
||||
*/
|
||||
getHandler(key: string): ContentActionHandler {
|
||||
if (key) {
|
||||
let lKey = key.toLowerCase();
|
||||
const lKey = key.toLowerCase();
|
||||
return this.handlers[lKey] || null;
|
||||
}
|
||||
return null;
|
||||
@@ -65,7 +65,7 @@ export class DocumentActionsService {
|
||||
*/
|
||||
setHandler(key: string, handler: ContentActionHandler): boolean {
|
||||
if (key) {
|
||||
let lKey = key.toLowerCase();
|
||||
const lKey = key.toLowerCase();
|
||||
this.handlers[lKey] = handler;
|
||||
return true;
|
||||
}
|
||||
@@ -125,10 +125,10 @@ export class DocumentActionsService {
|
||||
if (this.contentService.hasAllowableOperations(node.entry, permission)) {
|
||||
handlerObservable = this.documentListService.deleteNode(node.entry.id);
|
||||
handlerObservable.subscribe(() => {
|
||||
let message = this.translation.instant('CORE.DELETE_NODE.SINGULAR', { name: node.entry.name });
|
||||
const message = this.translation.instant('CORE.DELETE_NODE.SINGULAR', { name: node.entry.name });
|
||||
this.success.next(message);
|
||||
}, () => {
|
||||
let message = this.translation.instant('CORE.DELETE_NODE.ERROR_SINGULAR', { name: node.entry.name });
|
||||
const message = this.translation.instant('CORE.DELETE_NODE.ERROR_SINGULAR', { name: node.entry.name });
|
||||
this.error.next(message);
|
||||
});
|
||||
return handlerObservable;
|
||||
|
||||
@@ -26,7 +26,7 @@ describe('DocumentListService', () => {
|
||||
let service: DocumentListService;
|
||||
let alfrescoApiService: AlfrescoApiService;
|
||||
|
||||
let fakeFolder = {
|
||||
const fakeFolder = {
|
||||
'list': {
|
||||
'pagination': { 'count': 1, 'hasMoreItems': false, 'totalItems': 1, 'skipCount': 0, 'maxItems': 20 },
|
||||
'entries': [{
|
||||
@@ -67,8 +67,8 @@ describe('DocumentListService', () => {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
let logService = new LogService(new AppConfigServiceMock(null));
|
||||
let contentService = new ContentService(null, null, null, null);
|
||||
const logService = new LogService(new AppConfigServiceMock(null));
|
||||
const contentService = new ContentService(null, null, null, null);
|
||||
alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
||||
service = new DocumentListService(null, contentService, alfrescoApiService, logService, null);
|
||||
jasmine.Ajax.install();
|
||||
@@ -98,7 +98,7 @@ describe('DocumentListService', () => {
|
||||
});
|
||||
|
||||
it('should add the includeTypes in the request Node Children if required', () => {
|
||||
let spyGetNodeInfo = spyOn(alfrescoApiService.getInstance().nodes, 'getNodeChildren').and.callThrough();
|
||||
const spyGetNodeInfo = spyOn(alfrescoApiService.getInstance().nodes, 'getNodeChildren').and.callThrough();
|
||||
|
||||
service.getFolder('/fake-root/fake-name', {}, ['isLocked']);
|
||||
|
||||
@@ -110,7 +110,7 @@ describe('DocumentListService', () => {
|
||||
});
|
||||
|
||||
it('should not add the includeTypes in the request Node Children if is duplicated', () => {
|
||||
let spyGetNodeInfo = spyOn(alfrescoApiService.getInstance().nodes, 'getNodeChildren').and.callThrough();
|
||||
const spyGetNodeInfo = spyOn(alfrescoApiService.getInstance().nodes, 'getNodeChildren').and.callThrough();
|
||||
|
||||
service.getFolder('/fake-root/fake-name', {}, ['allowableOperations']);
|
||||
|
||||
@@ -122,7 +122,7 @@ describe('DocumentListService', () => {
|
||||
});
|
||||
|
||||
it('should add the includeTypes in the request getFolderNode if required', () => {
|
||||
let spyGetNodeInfo = spyOn(alfrescoApiService.getInstance().nodes, 'getNode').and.callThrough();
|
||||
const spyGetNodeInfo = spyOn(alfrescoApiService.getInstance().nodes, 'getNode').and.callThrough();
|
||||
|
||||
service.getFolderNode('test-id', ['isLocked']);
|
||||
|
||||
@@ -133,7 +133,7 @@ describe('DocumentListService', () => {
|
||||
});
|
||||
|
||||
it('should not add the includeTypes in the request getFolderNode if is duplicated', () => {
|
||||
let spyGetNodeInfo = spyOn(alfrescoApiService.getInstance().nodes, 'getNode').and.callThrough();
|
||||
const spyGetNodeInfo = spyOn(alfrescoApiService.getInstance().nodes, 'getNode').and.callThrough();
|
||||
|
||||
service.getFolderNode('test-id', ['allowableOperations']);
|
||||
|
||||
|
||||
@@ -86,10 +86,10 @@ export class DocumentListService {
|
||||
rootNodeId = opts.rootFolderId;
|
||||
}
|
||||
|
||||
let includeFieldsRequest = ['path', 'properties', 'allowableOperations', 'permissions', 'aspectNames', ...includeFields]
|
||||
const includeFieldsRequest = ['path', 'properties', 'allowableOperations', 'permissions', 'aspectNames', ...includeFields]
|
||||
.filter((element, index, array) => index === array.indexOf(element));
|
||||
|
||||
let params: any = {
|
||||
const params: any = {
|
||||
includeSource: true,
|
||||
include: includeFieldsRequest
|
||||
};
|
||||
@@ -123,10 +123,10 @@ export class DocumentListService {
|
||||
*/
|
||||
getNode(nodeId: string, includeFields: string[] = []): Observable<NodeEntry> {
|
||||
|
||||
let includeFieldsRequest = ['path', 'properties', 'allowableOperations', 'permissions', ...includeFields]
|
||||
const includeFieldsRequest = ['path', 'properties', 'allowableOperations', 'permissions', ...includeFields]
|
||||
.filter((element, index, array) => index === array.indexOf(element));
|
||||
|
||||
let opts: any = {
|
||||
const opts: any = {
|
||||
includeSource: true,
|
||||
include: includeFieldsRequest
|
||||
};
|
||||
@@ -142,10 +142,10 @@ export class DocumentListService {
|
||||
*/
|
||||
getFolderNode(nodeId: string, includeFields: string[] = []): Observable<NodeEntry> {
|
||||
|
||||
let includeFieldsRequest = ['path', 'properties', 'allowableOperations', 'permissions', 'aspectNames', ...includeFields]
|
||||
const includeFieldsRequest = ['path', 'properties', 'allowableOperations', 'permissions', 'aspectNames', ...includeFields]
|
||||
.filter((element, index, array) => index === array.indexOf(element));
|
||||
|
||||
let opts: any = {
|
||||
const opts: any = {
|
||||
includeSource: true,
|
||||
include: includeFieldsRequest
|
||||
};
|
||||
|
||||
@@ -35,17 +35,17 @@ describe('FolderActionsService', () => {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
let appConfig: AppConfigService = TestBed.get(AppConfigService);
|
||||
const appConfig: AppConfigService = TestBed.get(AppConfigService);
|
||||
appConfig.config.ecmHost = 'http://localhost:9876/ecm';
|
||||
|
||||
let contentService = new ContentService(null, null, null, null);
|
||||
let alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
||||
const contentService = new ContentService(null, null, null, null);
|
||||
const alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
||||
documentListService = new DocumentListService(null, contentService, alfrescoApiService, null, null);
|
||||
service = new FolderActionsService(null, documentListService, contentService, new TranslationMock());
|
||||
});
|
||||
|
||||
it('should register custom action handler', () => {
|
||||
let handler: ContentActionHandler = function () {
|
||||
const handler: ContentActionHandler = function () {
|
||||
};
|
||||
service.setHandler('<key>', handler);
|
||||
expect(service.getHandler('<key>')).toBe(handler);
|
||||
@@ -56,7 +56,7 @@ describe('FolderActionsService', () => {
|
||||
});
|
||||
|
||||
it('should be case insensitive for keys', () => {
|
||||
let handler: ContentActionHandler = function () {
|
||||
const handler: ContentActionHandler = function () {
|
||||
};
|
||||
service.setHandler('<key>', handler);
|
||||
expect(service.getHandler('<KEY>')).toBe(handler);
|
||||
@@ -68,7 +68,7 @@ describe('FolderActionsService', () => {
|
||||
});
|
||||
|
||||
it('should allow action execution only when service available', () => {
|
||||
let folder = new FolderNode();
|
||||
const folder = new FolderNode();
|
||||
expect(service.canExecuteAction(folder)).toBeTruthy();
|
||||
});
|
||||
|
||||
@@ -79,7 +79,7 @@ describe('FolderActionsService', () => {
|
||||
});
|
||||
|
||||
it('should set new handler only by key', () => {
|
||||
let handler: ContentActionHandler = function () {
|
||||
const handler: ContentActionHandler = function () {
|
||||
};
|
||||
expect(service.setHandler(null, handler)).toBeFalsy();
|
||||
expect(service.setHandler('', handler)).toBeFalsy();
|
||||
@@ -100,7 +100,7 @@ describe('FolderActionsService', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
let folder = new FolderNode();
|
||||
const folder = new FolderNode();
|
||||
service.getHandler('delete')(folder);
|
||||
|
||||
});
|
||||
@@ -113,9 +113,9 @@ describe('FolderActionsService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
let permission = 'delete';
|
||||
let folder = new FolderNode();
|
||||
let folderWithPermission: any = folder;
|
||||
const permission = 'delete';
|
||||
const folder = new FolderNode();
|
||||
const folderWithPermission: any = folder;
|
||||
folderWithPermission.entry.allowableOperations = [permission];
|
||||
const deleteObservable = service.getHandler('delete')(folderWithPermission, null, permission);
|
||||
|
||||
@@ -138,8 +138,8 @@ describe('FolderActionsService', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
let folder = new FolderNode();
|
||||
let folderWithPermission: any = folder;
|
||||
const folder = new FolderNode();
|
||||
const folderWithPermission: any = folder;
|
||||
folderWithPermission.entry.allowableOperations = ['create', 'update'];
|
||||
service.getHandler('delete')(folderWithPermission);
|
||||
});
|
||||
@@ -152,8 +152,8 @@ describe('FolderActionsService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
let folder = new FolderNode();
|
||||
let folderWithPermission: any = folder;
|
||||
const folder = new FolderNode();
|
||||
const folderWithPermission: any = folder;
|
||||
folderWithPermission.entry.allowableOperations = ['create', 'update'];
|
||||
const deleteObservable = service.getHandler('delete')(folderWithPermission);
|
||||
|
||||
@@ -174,9 +174,9 @@ describe('FolderActionsService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
let permission = 'delete';
|
||||
let folder = new FolderNode();
|
||||
let folderWithPermission: any = folder;
|
||||
const permission = 'delete';
|
||||
const folder = new FolderNode();
|
||||
const folderWithPermission: any = folder;
|
||||
folderWithPermission.entry.allowableOperations = ['create', 'update', permission];
|
||||
service.getHandler('delete')(folderWithPermission, null, permission);
|
||||
|
||||
@@ -191,13 +191,13 @@ describe('FolderActionsService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
let permission = 'delete';
|
||||
let file = new FileNode();
|
||||
const permission = 'delete';
|
||||
const file = new FileNode();
|
||||
service.getHandler('delete')(file);
|
||||
expect(documentListService.deleteNode).not.toHaveBeenCalled();
|
||||
|
||||
let folder = new FolderNode();
|
||||
let folderWithPermission: any = folder;
|
||||
const folder = new FolderNode();
|
||||
const folderWithPermission: any = folder;
|
||||
folderWithPermission.entry.allowableOperations = [permission];
|
||||
service.getHandler('delete')(folderWithPermission, null, permission);
|
||||
expect(documentListService.deleteNode).toHaveBeenCalled();
|
||||
@@ -211,7 +211,7 @@ describe('FolderActionsService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
let folder = new FolderNode();
|
||||
const folder = new FolderNode();
|
||||
folder.entry.id = null;
|
||||
service.getHandler('delete')(folder);
|
||||
|
||||
@@ -226,13 +226,13 @@ describe('FolderActionsService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
let permission = 'delete';
|
||||
let target = jasmine.createSpyObj('obj', ['reload']);
|
||||
let folder = new FolderNode();
|
||||
let folderWithPermission: any = folder;
|
||||
const permission = 'delete';
|
||||
const target = jasmine.createSpyObj('obj', ['reload']);
|
||||
const folder = new FolderNode();
|
||||
const folderWithPermission: any = folder;
|
||||
folderWithPermission.entry.allowableOperations = [permission];
|
||||
|
||||
let deleteHandler = service.getHandler('delete')(folderWithPermission, target, permission);
|
||||
const deleteHandler = service.getHandler('delete')(folderWithPermission, target, permission);
|
||||
|
||||
deleteHandler.subscribe(() => {
|
||||
expect(target.reload).toHaveBeenCalled();
|
||||
@@ -255,10 +255,10 @@ describe('FolderActionsService', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
let permission = 'delete';
|
||||
let target = jasmine.createSpyObj('obj', ['reload']);
|
||||
let folder = new FolderNode();
|
||||
let folderWithPermission: any = folder;
|
||||
const permission = 'delete';
|
||||
const target = jasmine.createSpyObj('obj', ['reload']);
|
||||
const folder = new FolderNode();
|
||||
const folderWithPermission: any = folder;
|
||||
folderWithPermission.entry.allowableOperations = [permission];
|
||||
|
||||
service.getHandler('delete')(folderWithPermission, target, permission);
|
||||
|
||||
@@ -49,7 +49,7 @@ export class FolderActionsService {
|
||||
*/
|
||||
getHandler(key: string): ContentActionHandler {
|
||||
if (key) {
|
||||
let lKey = key.toLowerCase();
|
||||
const lKey = key.toLowerCase();
|
||||
return this.handlers[lKey] || null;
|
||||
}
|
||||
return null;
|
||||
@@ -63,7 +63,7 @@ export class FolderActionsService {
|
||||
*/
|
||||
setHandler(key: string, handler: ContentActionHandler): boolean {
|
||||
if (key) {
|
||||
let lKey = key.toLowerCase();
|
||||
const lKey = key.toLowerCase();
|
||||
this.handlers[lKey] = handler;
|
||||
return true;
|
||||
}
|
||||
@@ -125,10 +125,10 @@ export class FolderActionsService {
|
||||
target.reload();
|
||||
}
|
||||
|
||||
let message = this.translation.instant('CORE.DELETE_NODE.SINGULAR', { name: node.entry.name });
|
||||
const message = this.translation.instant('CORE.DELETE_NODE.SINGULAR', { name: node.entry.name });
|
||||
this.success.next(message);
|
||||
}, () => {
|
||||
let message = this.translation.instant('CORE.DELETE_NODE.ERROR_SINGULAR', { name: node.entry.name });
|
||||
const message = this.translation.instant('CORE.DELETE_NODE.ERROR_SINGULAR', { name: node.entry.name });
|
||||
this.error.next(message);
|
||||
});
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ describe('NodeActionsService', () => {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
let appConfig: AppConfigService = TestBed.get(AppConfigService);
|
||||
const appConfig: AppConfigService = TestBed.get(AppConfigService);
|
||||
appConfig.config.ecmHost = 'http://localhost:9876/ecm';
|
||||
|
||||
service = TestBed.get(NodeActionsService);
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ describe('AddPermissionDialog', () => {
|
||||
|
||||
let fixture: ComponentFixture<AddPermissionDialogComponent>;
|
||||
let element: HTMLElement;
|
||||
let data: AddPermissionDialogData = {
|
||||
const data: AddPermissionDialogData = {
|
||||
title: 'dead or alive you are coming with me',
|
||||
nodeId: 'fake-node-id',
|
||||
confirm: new Subject<NodeEntry[]> ()
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ describe('AddPermissionPanelComponent', () => {
|
||||
});
|
||||
|
||||
function typeWordIntoSearchInput(word: string): void {
|
||||
let inputDebugElement = debugElement.query(By.css('#searchInput'));
|
||||
const inputDebugElement = debugElement.query(By.css('#searchInput'));
|
||||
inputDebugElement.nativeElement.value = word;
|
||||
inputDebugElement.nativeElement.focus();
|
||||
inputDebugElement.nativeElement.dispatchEvent(new Event('input'));
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@ describe('AddPermissionComponent', () => {
|
||||
fixture.componentInstance.currentNode = new Node({ id: 'fake-node-id' });
|
||||
spyOn(nodePermissionService, 'updateNodePermissions').and.returnValue(of({ id: 'fake-node-id' }));
|
||||
|
||||
let spySuccess = spyOn(fixture.componentInstance, 'success');
|
||||
const spySuccess = spyOn(fixture.componentInstance, 'success');
|
||||
fixture.componentInstance.applySelection();
|
||||
expect(spySuccess).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ describe('InheritPermissionDirective', () => {
|
||||
|
||||
it('should not update the node when node has no permission', async(() => {
|
||||
spyOn(nodeService, 'getNode').and.returnValue(of(fakeNodeWithInheritNoPermission));
|
||||
let spyUpdateNode = spyOn(nodeService, 'updateNode');
|
||||
const spyUpdateNode = spyOn(nodeService, 'updateNode');
|
||||
component.updatedNode = true;
|
||||
fixture.detectChanges();
|
||||
const buttonPermission: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#sample-button-permission');
|
||||
|
||||
+3
-3
@@ -120,7 +120,7 @@ describe('PermissionDisplayComponent', () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let options: any = fixture.debugElement.queryAll(By.css('mat-option'));
|
||||
const options: any = fixture.debugElement.queryAll(By.css('mat-option'));
|
||||
expect(options).not.toBeNull();
|
||||
expect(options.length).toBe(4);
|
||||
expect(options[0].nativeElement.innerText).toContain('SiteCollaborator');
|
||||
@@ -145,7 +145,7 @@ describe('PermissionDisplayComponent', () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let options: any = fixture.debugElement.queryAll(By.css('mat-option'));
|
||||
const options: any = fixture.debugElement.queryAll(By.css('mat-option'));
|
||||
expect(options).not.toBeNull();
|
||||
expect(options.length).toBe(5);
|
||||
expect(options[0].nativeElement.innerText).toContain('Contributor');
|
||||
@@ -178,7 +178,7 @@ describe('PermissionDisplayComponent', () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let options: any = fixture.debugElement.queryAll(By.css('mat-option'));
|
||||
const options: any = fixture.debugElement.queryAll(By.css('mat-option'));
|
||||
expect(options).not.toBeNull();
|
||||
expect(options.length).toBe(5);
|
||||
options[3].triggerEventHandler('click', {});
|
||||
|
||||
+5
-5
@@ -69,16 +69,16 @@ export class PermissionListComponent implements OnInit {
|
||||
}
|
||||
|
||||
private getPermissionList(node: Node): PermissionDisplayModel[] {
|
||||
let allPermissions: PermissionDisplayModel[] = [];
|
||||
const allPermissions: PermissionDisplayModel[] = [];
|
||||
if (node.permissions.locallySet) {
|
||||
node.permissions.locallySet.map((permissionElement: PermissionElement) => {
|
||||
let permission = new PermissionDisplayModel(permissionElement);
|
||||
const permission = new PermissionDisplayModel(permissionElement);
|
||||
allPermissions.push(permission);
|
||||
});
|
||||
}
|
||||
if (node.permissions.inherited) {
|
||||
node.permissions.inherited.map((permissionElement: PermissionElement) => {
|
||||
let permissionInherited = new PermissionDisplayModel(permissionElement);
|
||||
const permissionInherited = new PermissionDisplayModel(permissionElement);
|
||||
permissionInherited.isInherited = true;
|
||||
allPermissions.push(permissionInherited);
|
||||
});
|
||||
@@ -87,7 +87,7 @@ export class PermissionListComponent implements OnInit {
|
||||
}
|
||||
|
||||
saveNewRole(event: any, permissionRow: PermissionDisplayModel) {
|
||||
let updatedPermissionRole: PermissionElement = this.buildUpdatedPermission(event.value, permissionRow);
|
||||
const updatedPermissionRole: PermissionElement = this.buildUpdatedPermission(event.value, permissionRow);
|
||||
this.nodePermissionService.updatePermissionRole(this.actualNode, updatedPermissionRole)
|
||||
.subscribe((node: Node) => {
|
||||
this.update.emit(updatedPermissionRole);
|
||||
@@ -95,7 +95,7 @@ export class PermissionListComponent implements OnInit {
|
||||
}
|
||||
|
||||
private buildUpdatedPermission(newRole: string, permissionRow: PermissionDisplayModel): PermissionElement {
|
||||
let permissionRole: PermissionElement = {};
|
||||
const permissionRole: PermissionElement = {};
|
||||
permissionRole.accessStatus = permissionRow.accessStatus;
|
||||
permissionRole.name = newRole;
|
||||
permissionRole.authorityId = permissionRow.authorityId;
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ describe('NodePermissionDialogService', () => {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
let appConfig: AppConfigService = TestBed.get(AppConfigService);
|
||||
const appConfig: AppConfigService = TestBed.get(AppConfigService);
|
||||
appConfig.config.ecmHost = 'http://localhost:9876/ecm';
|
||||
service = TestBed.get(NodePermissionDialogService);
|
||||
materialDialog = TestBed.get(MatDialog);
|
||||
|
||||
@@ -58,7 +58,7 @@ export class NodePermissionDialogService {
|
||||
this.openDialog(data, 'adf-add-permission-dialog', '630px');
|
||||
return confirm;
|
||||
} else {
|
||||
let errors = new Error(JSON.stringify({ error: { statusCode: 403 } }));
|
||||
const errors = new Error(JSON.stringify({ error: { statusCode: 403 } }));
|
||||
errors.message = 'PERMISSION_MANAGER.ERROR.NOT-ALLOWED';
|
||||
return throwError(errors);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ describe('NodePermissionService', () => {
|
||||
});
|
||||
|
||||
function returnUpdatedNode(nodeId, nodeBody) {
|
||||
let fakeNode: Node = new Node({});
|
||||
const fakeNode: Node = new Node({});
|
||||
fakeNode.id = 'fake-updated-node';
|
||||
fakeNode.permissions = nodeBody.permissions;
|
||||
return of(fakeNode);
|
||||
@@ -149,7 +149,7 @@ describe('NodePermissionService', () => {
|
||||
}));
|
||||
|
||||
it('should be able to update locally permissions on the node without locally set permissions', async(() => {
|
||||
let fakeNodeCopy = JSON.parse(JSON.stringify(fakeNodeWithoutPermissions));
|
||||
const fakeNodeCopy = JSON.parse(JSON.stringify(fakeNodeWithoutPermissions));
|
||||
fakeNodeCopy.permissions.locallySet = undefined;
|
||||
spyOn(nodeService, 'updateNode').and.callFake((nodeId, permissionBody) => returnUpdatedNode(nodeId, permissionBody));
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ export class NodePermissionService {
|
||||
.pipe(
|
||||
switchMap((siteNodeList: any) => {
|
||||
if ( siteNodeList.list.entries.length > 0 ) {
|
||||
let siteName = siteNodeList.list.entries[0].entry.name;
|
||||
const siteName = siteNodeList.list.entries[0].entry.name;
|
||||
return this.getGroupMembersBySiteName(siteName);
|
||||
} else {
|
||||
return of(node.permissions.settable);
|
||||
@@ -59,7 +59,7 @@ export class NodePermissionService {
|
||||
* @returns Node with updated permission
|
||||
*/
|
||||
updatePermissionRole(node: Node, updatedPermissionRole: PermissionElement): Observable<Node> {
|
||||
let permissionBody = { permissions: { locallySet: []} };
|
||||
const permissionBody = { permissions: { locallySet: []} };
|
||||
const index = node.permissions.locallySet.map((permission) => permission.authorityId).indexOf(updatedPermissionRole.authorityId);
|
||||
permissionBody.permissions.locallySet = permissionBody.permissions.locallySet.concat(node.permissions.locallySet);
|
||||
if (index !== -1) {
|
||||
@@ -95,7 +95,7 @@ export class NodePermissionService {
|
||||
* @returns Node with updated permissions
|
||||
*/
|
||||
updateLocallySetPermissions(node: Node, nodes: NodeEntry[], nodeRole: string[]): Observable<Node> {
|
||||
let permissionBody = { permissions: { locallySet: []} };
|
||||
const permissionBody = { permissions: { locallySet: []} };
|
||||
const permissionList = this.transformNodeToPermissionElement(nodes, nodeRole[0]);
|
||||
const duplicatedPermissions = this.getDuplicatedPermissions(node.permissions.locallySet, permissionList);
|
||||
if (duplicatedPermissions.length > 0) {
|
||||
@@ -108,7 +108,7 @@ export class NodePermissionService {
|
||||
}
|
||||
|
||||
private getDuplicatedPermissions(nodeLocallySet: PermissionElement[], permissionListAdded: PermissionElement[]): PermissionElement[] {
|
||||
let duplicatePermissions: PermissionElement[] = [];
|
||||
const duplicatePermissions: PermissionElement[] = [];
|
||||
if (nodeLocallySet) {
|
||||
permissionListAdded.forEach((permission: PermissionElement) => {
|
||||
const duplicate = nodeLocallySet.find((localPermission) => this.isEqualPermission(localPermission, permission));
|
||||
@@ -128,7 +128,7 @@ export class NodePermissionService {
|
||||
|
||||
private transformNodeToPermissionElement(nodes: NodeEntry[], nodeRole: any): PermissionElement[] {
|
||||
return nodes.map((node) => {
|
||||
let newPermissionElement: PermissionElement = <PermissionElement> {
|
||||
const newPermissionElement: PermissionElement = <PermissionElement> {
|
||||
'authorityId': node.entry.properties['cm:authorityName'] ?
|
||||
node.entry.properties['cm:authorityName'] :
|
||||
node.entry.properties['cm:userName'],
|
||||
@@ -146,7 +146,7 @@ export class NodePermissionService {
|
||||
* @returns Node with modified permissions
|
||||
*/
|
||||
removePermission(node: Node, permissionToRemove: PermissionElement): Observable<Node> {
|
||||
let permissionBody = { permissions: { locallySet: [] } };
|
||||
const permissionBody = { permissions: { locallySet: [] } };
|
||||
const index = node.permissions.locallySet.map((permission) => permission.authorityId).indexOf(permissionToRemove.authorityId);
|
||||
if (index !== -1) {
|
||||
node.permissions.locallySet.splice(index, 1);
|
||||
@@ -160,7 +160,7 @@ export class NodePermissionService {
|
||||
return this.getGroupMemberByGroupName(groupName)
|
||||
.pipe(
|
||||
map((groupMemberPaging: GroupMemberPaging) => {
|
||||
let displayResult: string[] = [];
|
||||
const displayResult: string[] = [];
|
||||
groupMemberPaging.list.entries.forEach((member: GroupMemberEntry) => {
|
||||
displayResult.push(this.formattedRoleName(member.entry.displayName, 'site_' + siteName));
|
||||
});
|
||||
|
||||
@@ -103,7 +103,7 @@ describe('SearchControlComponent', () => {
|
||||
});
|
||||
|
||||
function typeWordIntoSearchInput(word: string): void {
|
||||
let inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
const inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
inputDebugElement.nativeElement.value = word;
|
||||
inputDebugElement.nativeElement.focus();
|
||||
inputDebugElement.nativeElement.dispatchEvent(new Event('input'));
|
||||
@@ -120,7 +120,7 @@ describe('SearchControlComponent', () => {
|
||||
of({ entry: { list: [] } })
|
||||
);
|
||||
|
||||
let searchDisposable = component.searchChange.subscribe((value) => {
|
||||
const searchDisposable = component.searchChange.subscribe((value) => {
|
||||
expect(value).toBe('customSearchTerm');
|
||||
searchDisposable.unsubscribe();
|
||||
done();
|
||||
@@ -161,7 +161,7 @@ describe('SearchControlComponent', () => {
|
||||
it('should still fire an event when user inputs a search term less than 3 characters', (done) => {
|
||||
searchServiceSpy.and.returnValue(of(JSON.parse(JSON.stringify(results))));
|
||||
|
||||
let searchDisposable = component.searchChange.subscribe((value) => {
|
||||
const searchDisposable = component.searchChange.subscribe((value) => {
|
||||
expect(value).toBe('cu');
|
||||
searchDisposable.unsubscribe();
|
||||
});
|
||||
@@ -182,7 +182,7 @@ describe('SearchControlComponent', () => {
|
||||
});
|
||||
|
||||
it('search button should be hide', () => {
|
||||
let searchButton: any = element.querySelector('#adf-search-button');
|
||||
const searchButton: any = element.querySelector('#adf-search-button');
|
||||
expect(searchButton).toBe(null);
|
||||
});
|
||||
|
||||
@@ -202,7 +202,7 @@ describe('SearchControlComponent', () => {
|
||||
|
||||
it('should set browser autocomplete to off by default', async(() => {
|
||||
fixture.detectChanges();
|
||||
let attr = element.querySelector('#adf-control-input').getAttribute('autocomplete');
|
||||
const attr = element.querySelector('#adf-control-input').getAttribute('autocomplete');
|
||||
expect(attr).toBe('off');
|
||||
}));
|
||||
|
||||
@@ -219,7 +219,7 @@ describe('SearchControlComponent', () => {
|
||||
}));
|
||||
|
||||
xit('should fire a search when a enter key is pressed', (done) => {
|
||||
let searchDisposable = component.submit.subscribe((value) => {
|
||||
const searchDisposable = component.submit.subscribe((value) => {
|
||||
expect(value).toBe('TEST');
|
||||
searchDisposable.unsubscribe();
|
||||
done();
|
||||
@@ -229,9 +229,9 @@ describe('SearchControlComponent', () => {
|
||||
searchServiceSpy.and.returnValue(of(JSON.parse(JSON.stringify(results))));
|
||||
|
||||
fixture.detectChanges();
|
||||
let inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
const inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
typeWordIntoSearchInput('TEST');
|
||||
let enterKeyEvent: any = new Event('keyup');
|
||||
const enterKeyEvent: any = new Event('keyup');
|
||||
enterKeyEvent.keyCode = '13';
|
||||
inputDebugElement.nativeElement.dispatchEvent(enterKeyEvent);
|
||||
});
|
||||
@@ -253,7 +253,7 @@ describe('SearchControlComponent', () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let resultElement: Element = element.querySelector('#autocomplete-search-result-list');
|
||||
const resultElement: Element = element.querySelector('#autocomplete-search-result-list');
|
||||
expect(resultElement).not.toBe(null);
|
||||
done();
|
||||
});
|
||||
@@ -268,7 +268,7 @@ describe('SearchControlComponent', () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let noResultElement: Element = element.querySelector('#search_no_result');
|
||||
const noResultElement: Element = element.querySelector('#search_no_result');
|
||||
expect(noResultElement).not.toBe(null);
|
||||
done();
|
||||
});
|
||||
@@ -279,7 +279,7 @@ describe('SearchControlComponent', () => {
|
||||
searchServiceSpy.and.returnValue(of(JSON.parse(JSON.stringify(results))));
|
||||
fixture.detectChanges();
|
||||
|
||||
let inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
const inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
typeWordIntoSearchInput('NO RES');
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
@@ -300,12 +300,12 @@ describe('SearchControlComponent', () => {
|
||||
searchServiceSpy.and.returnValue(of(JSON.parse(JSON.stringify(results))));
|
||||
fixture.detectChanges();
|
||||
|
||||
let inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
const inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
typeWordIntoSearchInput('TEST');
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let resultElement: HTMLElement = <HTMLElement> element.querySelector('#result_option_0');
|
||||
const resultElement: HTMLElement = <HTMLElement> element.querySelector('#result_option_0');
|
||||
resultElement.focus();
|
||||
expect(resultElement).not.toBe(null);
|
||||
inputDebugElement.nativeElement.dispatchEvent(new KeyboardEvent('keypress', { key: 'TAB' }));
|
||||
@@ -321,14 +321,14 @@ describe('SearchControlComponent', () => {
|
||||
searchServiceSpy.and.returnValue(of(JSON.parse(JSON.stringify(results))));
|
||||
fixture.detectChanges();
|
||||
|
||||
let inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
const inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
typeWordIntoSearchInput('TEST');
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let resultElement: HTMLElement = <HTMLElement> element.querySelector('#result_option_0');
|
||||
expect(resultElement).not.toBeNull();
|
||||
let escapeEvent: any = new Event('ESCAPE');
|
||||
const escapeEvent: any = new Event('ESCAPE');
|
||||
escapeEvent.keyCode = 27;
|
||||
inputDebugElement.triggerEventHandler('keydown', escapeEvent);
|
||||
fixture.whenStable().then(() => {
|
||||
@@ -345,14 +345,14 @@ describe('SearchControlComponent', () => {
|
||||
searchServiceSpy.and.returnValue(of(JSON.parse(JSON.stringify(results))));
|
||||
fixture.detectChanges();
|
||||
|
||||
let inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
const inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
typeWordIntoSearchInput('TEST');
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let resultElement: HTMLElement = <HTMLElement> element.querySelector('#result_option_0');
|
||||
expect(resultElement).not.toBeNull();
|
||||
let escapeEvent: any = new Event('ENTER');
|
||||
const escapeEvent: any = new Event('ENTER');
|
||||
escapeEvent.keyCode = 13;
|
||||
inputDebugElement.triggerEventHandler('keydown', escapeEvent);
|
||||
fixture.whenStable().then(() => {
|
||||
@@ -369,8 +369,8 @@ describe('SearchControlComponent', () => {
|
||||
searchServiceSpy.and.returnValue(of(JSON.parse(JSON.stringify(results))));
|
||||
fixture.detectChanges();
|
||||
|
||||
let inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
let escapeEvent: any = new Event('ESCAPE');
|
||||
const inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
const escapeEvent: any = new Event('ESCAPE');
|
||||
escapeEvent.keyCode = 27;
|
||||
inputDebugElement.nativeElement.focus();
|
||||
inputDebugElement.nativeElement.dispatchEvent(escapeEvent);
|
||||
@@ -399,7 +399,7 @@ describe('SearchControlComponent', () => {
|
||||
searchServiceSpy.and.returnValue(of(JSON.parse(JSON.stringify(results))));
|
||||
fixture.detectChanges();
|
||||
typeWordIntoSearchInput('TEST');
|
||||
let inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
const inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
@@ -415,7 +415,7 @@ describe('SearchControlComponent', () => {
|
||||
xit('should select the second item on autocomplete list when ARROW DOWN is pressed on list', (done) => {
|
||||
searchServiceSpy.and.returnValue(of(JSON.parse(JSON.stringify(results))));
|
||||
fixture.detectChanges();
|
||||
let inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
const inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
typeWordIntoSearchInput('TEST');
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
@@ -426,7 +426,7 @@ describe('SearchControlComponent', () => {
|
||||
fixture.detectChanges();
|
||||
expect(document.activeElement.id).toBe('result_option_0');
|
||||
|
||||
let firstElement = debugElement.query(By.css('#result_option_0'));
|
||||
const firstElement = debugElement.query(By.css('#result_option_0'));
|
||||
firstElement.triggerEventHandler('keyup.arrowdown', { target: firstElement.nativeElement });
|
||||
fixture.detectChanges();
|
||||
expect(document.activeElement.id).toBe('result_option_1');
|
||||
@@ -437,7 +437,7 @@ describe('SearchControlComponent', () => {
|
||||
xit('should focus the input search when ARROW UP is pressed on the first list item', (done) => {
|
||||
searchServiceSpy.and.returnValue(of(JSON.parse(JSON.stringify(results))));
|
||||
fixture.detectChanges();
|
||||
let inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
const inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
typeWordIntoSearchInput('TEST');
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
@@ -448,7 +448,7 @@ describe('SearchControlComponent', () => {
|
||||
fixture.detectChanges();
|
||||
expect(document.activeElement.id).toBe('result_option_0');
|
||||
|
||||
let firstElement = debugElement.query(By.css('#result_option_0'));
|
||||
const firstElement = debugElement.query(By.css('#result_option_0'));
|
||||
firstElement.triggerEventHandler('keyup.arrowup', { target: firstElement.nativeElement });
|
||||
fixture.detectChanges();
|
||||
expect(document.activeElement.id).toBe('adf-control-input');
|
||||
@@ -465,7 +465,7 @@ describe('SearchControlComponent', () => {
|
||||
|
||||
tick(100);
|
||||
|
||||
let searchButton: DebugElement = debugElement.query(By.css('#adf-search-button'));
|
||||
const searchButton: DebugElement = debugElement.query(By.css('#adf-search-button'));
|
||||
component.subscriptAnimationState = 'active';
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -490,7 +490,7 @@ describe('SearchControlComponent', () => {
|
||||
|
||||
tick(100);
|
||||
|
||||
let searchButton: DebugElement = debugElement.query(By.css('#adf-search-button'));
|
||||
const searchButton: DebugElement = debugElement.query(By.css('#adf-search-button'));
|
||||
searchButton.triggerEventHandler('click', null);
|
||||
|
||||
tick(100);
|
||||
@@ -506,10 +506,10 @@ describe('SearchControlComponent', () => {
|
||||
fixture.detectChanges();
|
||||
tick(100);
|
||||
|
||||
let searchButton: DebugElement = debugElement.query(By.css('#adf-search-button'));
|
||||
const searchButton: DebugElement = debugElement.query(By.css('#adf-search-button'));
|
||||
searchButton.triggerEventHandler('click', null);
|
||||
|
||||
let inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
const inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
|
||||
tick(100);
|
||||
fixture.detectChanges();
|
||||
@@ -525,7 +525,7 @@ describe('SearchControlComponent', () => {
|
||||
|
||||
tick(100);
|
||||
|
||||
let searchButton: DebugElement = debugElement.query(By.css('#adf-search-button'));
|
||||
const searchButton: DebugElement = debugElement.query(By.css('#adf-search-button'));
|
||||
component.subscriptAnimationState = 'active';
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -554,7 +554,7 @@ describe('SearchControlComponent', () => {
|
||||
|
||||
tick(100);
|
||||
|
||||
let inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
const inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
component.subscriptAnimationState = 'active';
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -579,7 +579,7 @@ describe('SearchControlComponent', () => {
|
||||
it('should emit a option clicked event when item is clicked', (done) => {
|
||||
spyOn(component, 'isSearchBarActive').and.returnValue(true);
|
||||
searchServiceSpy.and.returnValue(of(JSON.parse(JSON.stringify(results))));
|
||||
let clickDisposable = component.optionClicked.subscribe((item) => {
|
||||
const clickDisposable = component.optionClicked.subscribe((item) => {
|
||||
expect(item.entry.id).toBe('123');
|
||||
clickDisposable.unsubscribe();
|
||||
done();
|
||||
@@ -589,7 +589,7 @@ describe('SearchControlComponent', () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let firstOption: DebugElement = debugElement.query(By.css('#result_name_0'));
|
||||
const firstOption: DebugElement = debugElement.query(By.css('#result_name_0'));
|
||||
firstOption.nativeElement.click();
|
||||
});
|
||||
});
|
||||
@@ -597,7 +597,7 @@ describe('SearchControlComponent', () => {
|
||||
it('should set deactivate the search after element is clicked', (done) => {
|
||||
spyOn(component, 'isSearchBarActive').and.returnValue(true);
|
||||
searchServiceSpy.and.returnValue(of(JSON.parse(JSON.stringify(results))));
|
||||
let clickDisposable = component.optionClicked.subscribe((item) => {
|
||||
const clickDisposable = component.optionClicked.subscribe((item) => {
|
||||
expect(component.subscriptAnimationState).toBe('inactive');
|
||||
clickDisposable.unsubscribe();
|
||||
done();
|
||||
@@ -608,7 +608,7 @@ describe('SearchControlComponent', () => {
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let firstOption: DebugElement = debugElement.query(By.css('#result_name_0'));
|
||||
const firstOption: DebugElement = debugElement.query(By.css('#result_name_0'));
|
||||
firstOption.nativeElement.click();
|
||||
});
|
||||
});
|
||||
@@ -616,7 +616,7 @@ describe('SearchControlComponent', () => {
|
||||
it('should NOT reset the search term after element is clicked', (done) => {
|
||||
spyOn(component, 'isSearchBarActive').and.returnValue(true);
|
||||
searchServiceSpy.and.returnValue(of(JSON.parse(JSON.stringify(results))));
|
||||
let clickDisposable = component.optionClicked.subscribe((item) => {
|
||||
const clickDisposable = component.optionClicked.subscribe((item) => {
|
||||
expect(component.searchTerm).not.toBeFalsy();
|
||||
expect(component.searchTerm).toBe('TEST');
|
||||
clickDisposable.unsubscribe();
|
||||
@@ -628,7 +628,7 @@ describe('SearchControlComponent', () => {
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let firstOption: DebugElement = debugElement.query(By.css('#result_name_0'));
|
||||
const firstOption: DebugElement = debugElement.query(By.css('#result_name_0'));
|
||||
firstOption.nativeElement.click();
|
||||
});
|
||||
});
|
||||
@@ -649,7 +649,7 @@ describe('SearchControlComponent', () => {
|
||||
searchServiceSpy.and.returnValue(of(noResult));
|
||||
fixtureCustom.detectChanges();
|
||||
|
||||
let inputDebugElement = fixtureCustom.debugElement.query(By.css('#adf-control-input'));
|
||||
const inputDebugElement = fixtureCustom.debugElement.query(By.css('#adf-control-input'));
|
||||
inputDebugElement.nativeElement.value = 'SOMETHING';
|
||||
inputDebugElement.nativeElement.focus();
|
||||
inputDebugElement.nativeElement.dispatchEvent(new Event('input'));
|
||||
|
||||
@@ -217,20 +217,20 @@ export class SearchControlComponent implements OnInit, OnDestroy {
|
||||
|
||||
selectFirstResult() {
|
||||
if ( this.listResultElement && this.listResultElement.length > 0) {
|
||||
let firstElement: MatListItem = <MatListItem> this.listResultElement.first;
|
||||
const firstElement: MatListItem = <MatListItem> this.listResultElement.first;
|
||||
firstElement._getHostElement().focus();
|
||||
}
|
||||
}
|
||||
|
||||
onRowArrowDown($event: KeyboardEvent): void {
|
||||
let nextElement: any = this.getNextElementSibling(<Element> $event.target);
|
||||
const nextElement: any = this.getNextElementSibling(<Element> $event.target);
|
||||
if (nextElement) {
|
||||
nextElement.focus();
|
||||
}
|
||||
}
|
||||
|
||||
onRowArrowUp($event: KeyboardEvent): void {
|
||||
let previousElement: any = this.getPreviousElementSibling(<Element> $event.target);
|
||||
const previousElement: any = this.getPreviousElementSibling(<Element> $event.target);
|
||||
if (previousElement) {
|
||||
previousElement.focus();
|
||||
} else {
|
||||
|
||||
+2
-2
@@ -29,8 +29,8 @@ describe('SearchDateRangeComponent', () => {
|
||||
describe('component class', () => {
|
||||
|
||||
let component: SearchDateRangeComponent;
|
||||
let fromDate = '2016-10-16';
|
||||
let toDate = '2017-10-16';
|
||||
const fromDate = '2016-10-16';
|
||||
const toDate = '2017-10-16';
|
||||
const localeFixture = 'it';
|
||||
const dateFormatFixture = 'DD-MMM-YY';
|
||||
|
||||
|
||||
+1
-1
@@ -127,7 +127,7 @@ export class SearchFilterList<T> implements Iterable<T> {
|
||||
|
||||
[Symbol.iterator](): Iterator<T> {
|
||||
let pointer = 0;
|
||||
let items = this.visibleItems;
|
||||
const items = this.visibleItems;
|
||||
|
||||
return {
|
||||
next(): IteratorResult<T> {
|
||||
|
||||
+1
-1
@@ -589,7 +589,7 @@ describe('SearchFilterComponent', () => {
|
||||
expect(queryBuilder.removeUserFacetBucket).toHaveBeenCalledTimes(3);
|
||||
expect(queryBuilder.update).toHaveBeenCalled();
|
||||
|
||||
for (let entry of component.responseFacets[0].buckets.items) {
|
||||
for (const entry of component.responseFacets[0].buckets.items) {
|
||||
expect(entry.checked).toBeFalsy();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -93,7 +93,7 @@ export class SearchFilterComponent implements OnInit, OnDestroy {
|
||||
private updateSelectedBuckets() {
|
||||
if (this.responseFacets) {
|
||||
this.selectedBuckets = [];
|
||||
for (let field of this.responseFacets) {
|
||||
for (const field of this.responseFacets) {
|
||||
if (field.buckets) {
|
||||
this.selectedBuckets.push(
|
||||
...this.queryBuilder.getUserFacetBuckets(field.field)
|
||||
@@ -146,7 +146,7 @@ export class SearchFilterComponent implements OnInit, OnDestroy {
|
||||
|
||||
resetSelectedBuckets(field: FacetField) {
|
||||
if (field && field.buckets) {
|
||||
for (let bucket of field.buckets.items) {
|
||||
for (const bucket of field.buckets.items) {
|
||||
bucket.checked = false;
|
||||
this.queryBuilder.removeUserFacetBucket(field, bucket);
|
||||
}
|
||||
@@ -158,7 +158,7 @@ export class SearchFilterComponent implements OnInit, OnDestroy {
|
||||
resetAllSelectedBuckets() {
|
||||
this.responseFacets.forEach((field) => {
|
||||
if (field && field.buckets) {
|
||||
for (let bucket of field.buckets.items) {
|
||||
for (const bucket of field.buckets.items) {
|
||||
bucket.checked = false;
|
||||
this.queryBuilder.removeUserFacetBucket(field, bucket);
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ export class SearchTriggerDirective implements ControlValueAccessor, OnDestroy {
|
||||
|
||||
handleInput(event: KeyboardEvent): void {
|
||||
if (document.activeElement === event.target) {
|
||||
let inputValue: string = (event.target as HTMLInputElement).value;
|
||||
const inputValue: string = (event.target as HTMLInputElement).value;
|
||||
this.onChange(inputValue);
|
||||
if (inputValue) {
|
||||
this.searchPanel.keyPressedStream.next(inputValue);
|
||||
@@ -177,7 +177,7 @@ export class SearchTriggerDirective implements ControlValueAccessor, OnDestroy {
|
||||
private isPanelOptionClicked(event: MouseEvent) {
|
||||
let isPanelOption: boolean = false;
|
||||
if ( event ) {
|
||||
let clickTarget = event.target as HTMLElement;
|
||||
const clickTarget = event.target as HTMLElement;
|
||||
isPanelOption = !this.isNoResultOption(event) &&
|
||||
!!this.searchPanel.panel &&
|
||||
!!this.searchPanel.panel.nativeElement.contains(clickTarget);
|
||||
|
||||
@@ -87,7 +87,7 @@ describe('SearchComponent', () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let message: HTMLElement = <HTMLElement> element.querySelector('#component-result-message');
|
||||
const message: HTMLElement = <HTMLElement> element.querySelector('#component-result-message');
|
||||
expect(message.textContent).toBe('ERROR');
|
||||
done();
|
||||
});
|
||||
@@ -103,13 +103,13 @@ describe('SearchComponent', () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let optionShowed = element.querySelectorAll('#autocomplete-search-result-list');
|
||||
const optionShowed = element.querySelectorAll('#autocomplete-search-result-list');
|
||||
expect(optionShowed).not.toBeNull();
|
||||
component.forceHidePanel();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let elementList = element.querySelector('#adf-search-results-content');
|
||||
const elementList = element.querySelector('#adf-search-results-content');
|
||||
expect(elementList.classList).toContain('adf-search-hide');
|
||||
done();
|
||||
});
|
||||
@@ -125,9 +125,9 @@ describe('SearchComponent', () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let optionShowed = element.querySelectorAll('#autocomplete-search-result-list > li').length;
|
||||
const optionShowed = element.querySelectorAll('#autocomplete-search-result-list > li').length;
|
||||
expect(optionShowed).toBe(1);
|
||||
let folderOption: HTMLElement = <HTMLElement> element.querySelector('#result_option_0');
|
||||
const folderOption: HTMLElement = <HTMLElement> element.querySelector('#result_option_0');
|
||||
expect(folderOption.textContent.trim()).toBe('MyDoc');
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -208,7 +208,7 @@ export class SearchQueryBuilderService {
|
||||
* @returns The finished query
|
||||
*/
|
||||
buildQuery(): QueryBody {
|
||||
let query = this.getFinalQuery();
|
||||
const query = this.getFinalQuery();
|
||||
|
||||
const include = this.config.include || [];
|
||||
if (include.length === 0) {
|
||||
|
||||
@@ -216,7 +216,7 @@ describe('DropdownSitesComponent', () => {
|
||||
fixture.detectChanges();
|
||||
debug.query(By.css('.mat-select-trigger')).triggerEventHandler('click', null);
|
||||
fixture.detectChanges();
|
||||
let options: any = debug.queryAll(By.css('mat-option'));
|
||||
const options: any = debug.queryAll(By.css('mat-option'));
|
||||
expect(options[0].nativeElement.innerText).toContain('DROPDOWN.MY_FILES_OPTION');
|
||||
});
|
||||
}));
|
||||
@@ -229,7 +229,7 @@ describe('DropdownSitesComponent', () => {
|
||||
fixture.detectChanges();
|
||||
debug.query(By.css('.mat-select-trigger')).triggerEventHandler('click', null);
|
||||
fixture.detectChanges();
|
||||
let options: any = debug.queryAll(By.css('mat-option'));
|
||||
const options: any = debug.queryAll(By.css('mat-option'));
|
||||
expect(options[0].nativeElement.innerText).not.toContain('DROPDOWN.MY_FILES_OPTION');
|
||||
});
|
||||
}));
|
||||
@@ -304,7 +304,7 @@ describe('DropdownSitesComponent', () => {
|
||||
fixture.detectChanges();
|
||||
debug.query(By.css('.mat-select-trigger')).triggerEventHandler('click', null);
|
||||
fixture.detectChanges();
|
||||
let options: any = debug.queryAll(By.css('mat-option'));
|
||||
const options: any = debug.queryAll(By.css('mat-option'));
|
||||
expect(options[1].nativeElement.innerText).toContain('fake-test-site');
|
||||
expect(options[2].nativeElement.innerText).toContain('fake-test-2');
|
||||
});
|
||||
@@ -317,7 +317,7 @@ describe('DropdownSitesComponent', () => {
|
||||
fixture.detectChanges();
|
||||
debug.query(By.css('.mat-select-trigger')).triggerEventHandler('click', null);
|
||||
fixture.detectChanges();
|
||||
let options: any = debug.queryAll(By.css('mat-option'));
|
||||
const options: any = debug.queryAll(By.css('mat-option'));
|
||||
options[1].nativeElement.click();
|
||||
fixture.detectChanges();
|
||||
});
|
||||
@@ -489,7 +489,7 @@ describe('DropdownSitesComponent', () => {
|
||||
debug.query(By.css('.mat-select-trigger')).triggerEventHandler('click', null);
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
let options: any = debug.queryAll(By.css('mat-option'));
|
||||
const options: any = debug.queryAll(By.css('mat-option'));
|
||||
expect(options[1].nativeElement.innerText).toContain('FAKE-SITE-PUBLIC');
|
||||
expect(options[2].nativeElement.innerText).toContain('FAKE-PRIVATE-SITE-MEMBER');
|
||||
expect(options[3]).toBeUndefined();
|
||||
@@ -513,7 +513,7 @@ describe('DropdownSitesComponent', () => {
|
||||
debug.query(By.css('.mat-select-trigger')).triggerEventHandler('click', null);
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
let options: any = debug.queryAll(By.css('mat-option'));
|
||||
const options: any = debug.queryAll(By.css('mat-option'));
|
||||
expect(options[1].nativeElement.innerText).toContain('FAKE-MODERATED-SITE');
|
||||
expect(options[2].nativeElement.innerText).toContain('FAKE-SITE-PUBLIC');
|
||||
expect(options[3].nativeElement.innerText).toContain('FAKE-PRIVATE-SITE-MEMBER');
|
||||
|
||||
@@ -114,7 +114,7 @@ export class DropdownSitesComponent implements OnInit {
|
||||
}
|
||||
|
||||
private loadSiteList() {
|
||||
let extendedOptions: any = {
|
||||
const extendedOptions: any = {
|
||||
skipCount: this.skipCount,
|
||||
maxItems: this.MAX_ITEMS
|
||||
};
|
||||
@@ -131,7 +131,7 @@ export class DropdownSitesComponent implements OnInit {
|
||||
this.siteList = this.relations === Relations.Members ? this.filteredResultsByMember(sitePaging) : sitePaging;
|
||||
|
||||
if (!this.hideMyFiles) {
|
||||
let siteEntry = new SiteEntry({
|
||||
const siteEntry = new SiteEntry({
|
||||
entry: {
|
||||
id: '-my-',
|
||||
guid: '-my-',
|
||||
@@ -147,7 +147,7 @@ export class DropdownSitesComponent implements OnInit {
|
||||
}
|
||||
|
||||
} else {
|
||||
let siteList: SitePaging = this.relations === Relations.Members ? this.filteredResultsByMember(sitePaging) : sitePaging;
|
||||
const siteList: SitePaging = this.relations === Relations.Members ? this.filteredResultsByMember(sitePaging) : sitePaging;
|
||||
|
||||
this.siteList.list.entries = this.siteList.list.entries.concat(siteList.list.entries);
|
||||
this.siteList.list.pagination = sitePaging.list.pagination;
|
||||
|
||||
@@ -67,7 +67,7 @@ describe('Like component', () => {
|
||||
}
|
||||
}));
|
||||
|
||||
let likeButton: any = element.querySelector('#adf-like-test-id');
|
||||
const likeButton: any = element.querySelector('#adf-like-test-id');
|
||||
likeButton.click();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
@@ -81,7 +81,7 @@ describe('Like component', () => {
|
||||
|
||||
component.isLike = true;
|
||||
|
||||
let likeButton: any = element.querySelector('#adf-like-test-id');
|
||||
const likeButton: any = element.querySelector('#adf-like-test-id');
|
||||
likeButton.click();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
|
||||
@@ -125,7 +125,7 @@ describe('Rating component', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
let starThree: any = element.querySelector('#adf-colored-star-3');
|
||||
const starThree: any = element.querySelector('#adf-colored-star-3');
|
||||
starThree.click();
|
||||
});
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ export class RatingComponent implements OnChanges {
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
let ratingObserver = this.ratingService.getRating(this.nodeId, this.ratingType);
|
||||
const ratingObserver = this.ratingService.getRating(this.nodeId, this.ratingType);
|
||||
|
||||
ratingObserver.subscribe(
|
||||
(ratingEntry: RatingEntry) => {
|
||||
|
||||
@@ -43,8 +43,8 @@ describe('Rating service', () => {
|
||||
});
|
||||
|
||||
it('Should get rating return an Observable', (done) => {
|
||||
let ratingType: string = 'fiveStar';
|
||||
let nodeId: string = 'fake-node-id';
|
||||
const ratingType: string = 'fiveStar';
|
||||
const nodeId: string = 'fake-node-id';
|
||||
|
||||
service.getRating(nodeId, ratingType).subscribe((data) => {
|
||||
expect(data.entry.myRating).toBe('1');
|
||||
@@ -66,8 +66,8 @@ describe('Rating service', () => {
|
||||
});
|
||||
|
||||
it('Should post rating return an Observable', (done) => {
|
||||
let ratingType: string = 'fiveStar';
|
||||
let nodeId: string = 'fake-node-id';
|
||||
const ratingType: string = 'fiveStar';
|
||||
const nodeId: string = 'fake-node-id';
|
||||
|
||||
service.postRating(nodeId, ratingType, 3).subscribe((data) => {
|
||||
expect(data.entry.myRating).toBe('3');
|
||||
|
||||
@@ -51,7 +51,7 @@ export class RatingService {
|
||||
* @returns Details about the rating, including the new value
|
||||
*/
|
||||
postRating(nodeId: string, ratingType: string, vote: any): Observable<RatingEntry | {}> {
|
||||
let ratingBody: RatingBody = new RatingBody({
|
||||
const ratingBody: RatingBody = new RatingBody({
|
||||
'id': ratingType,
|
||||
'myRating': vote
|
||||
});
|
||||
|
||||
@@ -65,7 +65,7 @@ export class TagService {
|
||||
const tagBody = new TagBody();
|
||||
tagBody.tag = tagName;
|
||||
|
||||
let observableAdd = from(this.apiService.getInstance().core.tagsApi.addTag(nodeId, tagBody));
|
||||
const observableAdd = from(this.apiService.getInstance().core.tagsApi.addTag(nodeId, tagBody));
|
||||
|
||||
observableAdd.subscribe((tagEntry: TagEntry) => {
|
||||
this.refresh.emit(tagEntry);
|
||||
|
||||
@@ -44,7 +44,7 @@ describe('TagActionsComponent', () => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
let dataTag = {
|
||||
const dataTag = {
|
||||
'list': {
|
||||
'pagination': {
|
||||
'count': 3,
|
||||
@@ -103,7 +103,7 @@ describe('TagActionsComponent', () => {
|
||||
component.result.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
let deleteButton: any = element.querySelector('#tag_delete_test1');
|
||||
const deleteButton: any = element.querySelector('#tag_delete_test1');
|
||||
deleteButton.click();
|
||||
|
||||
expect(jasmine.Ajax.requests.at(1).url)
|
||||
@@ -140,7 +140,7 @@ describe('TagActionsComponent', () => {
|
||||
component.result.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
let addButton: any = element.querySelector('#add-tag');
|
||||
const addButton: any = element.querySelector('#add-tag');
|
||||
addButton.click();
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
@@ -172,7 +172,7 @@ describe('TagActionsComponent', () => {
|
||||
component.result.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
let addButton: any = element.querySelector('#add-tag');
|
||||
const addButton: any = element.querySelector('#add-tag');
|
||||
addButton.click();
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
@@ -195,7 +195,7 @@ describe('TagActionsComponent', () => {
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
let addButton: any = element.querySelector('#add-tag');
|
||||
const addButton: any = element.querySelector('#add-tag');
|
||||
expect(addButton.disabled).toEqual(true);
|
||||
});
|
||||
|
||||
@@ -212,7 +212,7 @@ describe('TagActionsComponent', () => {
|
||||
component.result.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
let addButton: any = element.querySelector('#add-tag');
|
||||
const addButton: any = element.querySelector('#add-tag');
|
||||
addButton.click();
|
||||
});
|
||||
|
||||
@@ -230,7 +230,7 @@ describe('TagActionsComponent', () => {
|
||||
component.newTagName = 'fake-tag-name';
|
||||
|
||||
component.result.subscribe(() => {
|
||||
let addButton: any = element.querySelector('#add-tag');
|
||||
const addButton: any = element.querySelector('#add-tag');
|
||||
expect(addButton.disabled).toEqual(true);
|
||||
done();
|
||||
});
|
||||
@@ -249,7 +249,7 @@ describe('TagActionsComponent', () => {
|
||||
component.result.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
let addButton: any = element.querySelector('#add-tag');
|
||||
const addButton: any = element.querySelector('#add-tag');
|
||||
expect(addButton.disabled).toEqual(false);
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -24,7 +24,7 @@ import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
|
||||
describe('TagList', () => {
|
||||
|
||||
let dataTag = {
|
||||
const dataTag = {
|
||||
'list': {
|
||||
'pagination': {
|
||||
'count': 3,
|
||||
@@ -51,7 +51,7 @@ describe('TagList', () => {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
let appConfig: AppConfigService = TestBed.get(AppConfigService);
|
||||
const appConfig: AppConfigService = TestBed.get(AppConfigService);
|
||||
appConfig.config.ecmHost = 'http://localhost:9876/ecm';
|
||||
|
||||
tagService = TestBed.get(TagService);
|
||||
|
||||
@@ -24,7 +24,7 @@ import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
|
||||
describe('TagNodeList', () => {
|
||||
|
||||
let dataTag = {
|
||||
const dataTag = {
|
||||
'list': {
|
||||
'pagination': {
|
||||
'count': 3,
|
||||
@@ -51,7 +51,7 @@ describe('TagNodeList', () => {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
let appConfig: AppConfigService = TestBed.get(AppConfigService);
|
||||
const appConfig: AppConfigService = TestBed.get(AppConfigService);
|
||||
appConfig.config.ecmHost = 'http://localhost:9876/ecm';
|
||||
|
||||
fixture = TestBed.createComponent(TagNodeListComponent);
|
||||
@@ -94,7 +94,7 @@ describe('TagNodeList', () => {
|
||||
component.results.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
let deleteButton: any = element.querySelector('#tag_chips_delete_test1');
|
||||
const deleteButton: any = element.querySelector('#tag_chips_delete_test1');
|
||||
deleteButton.click();
|
||||
|
||||
expect(tagService.removeTag).toHaveBeenCalledWith('fake-node-id', '0ee933fa-57fc-4587-8a77-b787e814f1d2');
|
||||
@@ -111,7 +111,7 @@ describe('TagNodeList', () => {
|
||||
component.results.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
let deleteButton: any = element.querySelector('#tag_chips_delete_test1');
|
||||
const deleteButton: any = element.querySelector('#tag_chips_delete_test1');
|
||||
expect(deleteButton).toBeNull();
|
||||
done();
|
||||
});
|
||||
@@ -126,7 +126,7 @@ describe('TagNodeList', () => {
|
||||
component.results.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
let deleteButton: any = element.querySelector('#tag_chips_delete_test1');
|
||||
const deleteButton: any = element.querySelector('#tag_chips_delete_test1');
|
||||
expect(deleteButton).not.toBeNull();
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -32,19 +32,19 @@ describe('TreeViewComponent', () => {
|
||||
let treeService: TreeViewService;
|
||||
let component: any;
|
||||
|
||||
let fakeNodeList: TreeBaseNode[] = [
|
||||
const fakeNodeList: TreeBaseNode[] = [
|
||||
<TreeBaseNode> {
|
||||
nodeId: 'fake-node-id', name: 'fake-node-name', level: 0, expandable: true,
|
||||
node: { entry: { name: 'fake-node-name', id: 'fake-node-id' } }
|
||||
}
|
||||
];
|
||||
|
||||
let fakeChildrenList: TreeBaseNode[] = [
|
||||
const fakeChildrenList: TreeBaseNode[] = [
|
||||
<TreeBaseNode> { nodeId: 'fake-child-id', name: 'fake-child-name', level: 0, expandable: true, node: {} },
|
||||
<TreeBaseNode> { nodeId: 'fake-second-id', name: 'fake-second-name', level: 0, expandable: true, node: {} }
|
||||
];
|
||||
|
||||
let fakeNextChildrenList: TreeBaseNode[] = [
|
||||
const fakeNextChildrenList: TreeBaseNode[] = [
|
||||
<TreeBaseNode> {
|
||||
nodeId: 'fake-next-child-id',
|
||||
name: 'fake-next-child-name',
|
||||
@@ -61,7 +61,7 @@ describe('TreeViewComponent', () => {
|
||||
}
|
||||
];
|
||||
|
||||
let returnRootOrChildrenNode = function (nodeId: string) {
|
||||
const returnRootOrChildrenNode = function (nodeId: string) {
|
||||
if (nodeId === '9999999') {
|
||||
return of(fakeNodeList);
|
||||
} else if (nodeId === 'fake-second-id') {
|
||||
@@ -101,7 +101,7 @@ describe('TreeViewComponent', () => {
|
||||
}));
|
||||
|
||||
it('should show the subfolders when the folder is clicked', async(() => {
|
||||
let rootFolderButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#button-fake-node-name');
|
||||
const rootFolderButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#button-fake-node-name');
|
||||
expect(rootFolderButton).not.toBeNull();
|
||||
rootFolderButton.click();
|
||||
fixture.detectChanges();
|
||||
@@ -117,7 +117,7 @@ describe('TreeViewComponent', () => {
|
||||
component.ngOnChanges({ 'nodeId': changeNodeId });
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
let rootFolderButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#button-fake-next-child-name');
|
||||
const rootFolderButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#button-fake-next-child-name');
|
||||
expect(rootFolderButton).not.toBeNull();
|
||||
rootFolderButton.click();
|
||||
fixture.detectChanges();
|
||||
@@ -137,13 +137,13 @@ describe('TreeViewComponent', () => {
|
||||
expect(nodeClicked.entry.id).toBe('fake-node-id');
|
||||
done();
|
||||
});
|
||||
let rootFolderButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#button-fake-node-name');
|
||||
const rootFolderButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#button-fake-node-name');
|
||||
expect(rootFolderButton).not.toBeNull();
|
||||
rootFolderButton.click();
|
||||
});
|
||||
|
||||
it('should change the icon of the opened folders', async(() => {
|
||||
let rootFolderButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#button-fake-node-name');
|
||||
const rootFolderButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#button-fake-node-name');
|
||||
expect(rootFolderButton).not.toBeNull();
|
||||
expect(element.querySelector('#button-fake-node-name .mat-icon').textContent.trim()).toBe('folder');
|
||||
rootFolderButton.click();
|
||||
@@ -154,13 +154,13 @@ describe('TreeViewComponent', () => {
|
||||
}));
|
||||
|
||||
it('should show the subfolders of a subfolder if there are any', async(() => {
|
||||
let rootFolderButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#button-fake-node-name');
|
||||
const rootFolderButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#button-fake-node-name');
|
||||
expect(rootFolderButton).not.toBeNull();
|
||||
rootFolderButton.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(element.querySelector('#fake-second-name-tree-child-node')).not.toBeNull();
|
||||
let childButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#button-fake-second-name');
|
||||
const childButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#button-fake-second-name');
|
||||
expect(childButton).not.toBeNull();
|
||||
childButton.click();
|
||||
fixture.detectChanges();
|
||||
@@ -172,7 +172,7 @@ describe('TreeViewComponent', () => {
|
||||
}));
|
||||
|
||||
it('should hide the subfolders when clicked again', async(() => {
|
||||
let rootFolderButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#button-fake-node-name');
|
||||
const rootFolderButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#button-fake-node-name');
|
||||
expect(rootFolderButton).not.toBeNull();
|
||||
rootFolderButton.click();
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -27,11 +27,11 @@ describe('TreeViewService', () => {
|
||||
let service: TreeViewService;
|
||||
let nodeService: NodesApiService;
|
||||
|
||||
let fakeNodeList = { list: { entries: [
|
||||
const fakeNodeList = { list: { entries: [
|
||||
{ entry: { id: 'fake-node-id', name: 'fake-node-name', isFolder: true } }
|
||||
] } };
|
||||
|
||||
let fakeMixedNodeList = { list: { entries: [
|
||||
const fakeMixedNodeList = { list: { entries: [
|
||||
{ entry: { id: 'fake-node-id', name: 'fake-node-name', isFolder: true } },
|
||||
{ entry: { id: 'fake-file-id', name: 'fake-file-name', isFolder: false } }
|
||||
] } };
|
||||
|
||||
@@ -116,7 +116,7 @@ export abstract class UploadBase implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private uploadQueue(files: FileModel[]) {
|
||||
let filteredFiles = files
|
||||
const filteredFiles = files
|
||||
.filter(this.isFileAcceptable.bind(this))
|
||||
.filter(this.isFileSizeAcceptable.bind(this));
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy {
|
||||
|
||||
this.uploadService.fileDeleted.subscribe((objId) => {
|
||||
if (this.filesUploadingList) {
|
||||
let file = this.filesUploadingList.find((item) => {
|
||||
const file = this.filesUploadingList.find((item) => {
|
||||
return item.data.entry.id === objId;
|
||||
});
|
||||
if (file) {
|
||||
|
||||
@@ -23,7 +23,7 @@ import { FileUploadingListRowComponent } from './file-uploading-list-row.compone
|
||||
describe('FileUploadingListRowComponent', () => {
|
||||
let fixture: ComponentFixture<FileUploadingListRowComponent>;
|
||||
let component: FileUploadingListRowComponent;
|
||||
let file = new FileModel(<File> { name: 'fake-name' });
|
||||
const file = new FileModel(<File> { name: 'fake-name' });
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
|
||||
@@ -26,15 +26,15 @@ import { NodeEntry } from '@alfresco/js-api';
|
||||
|
||||
describe('UploadButtonComponent', () => {
|
||||
|
||||
let file = { name: 'fake-name-1', size: 10, webkitRelativePath: 'fake-folder1/fake-name-1.json' };
|
||||
let fakeEvent = {
|
||||
const file = { name: 'fake-name-1', size: 10, webkitRelativePath: 'fake-folder1/fake-name-1.json' };
|
||||
const fakeEvent = {
|
||||
currentTarget: {
|
||||
files: [file]
|
||||
},
|
||||
target: { value: 'fake-name-1' }
|
||||
};
|
||||
|
||||
let fakeFolderNodeWithPermission = new NodeEntry({
|
||||
const fakeFolderNodeWithPermission = new NodeEntry({
|
||||
entry: {
|
||||
allowableOperations: [
|
||||
'create',
|
||||
@@ -82,21 +82,21 @@ describe('UploadButtonComponent', () => {
|
||||
|
||||
it('should render upload-single-file button as default', () => {
|
||||
component.multipleFiles = false;
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
const compiled = fixture.debugElement.nativeElement;
|
||||
fixture.detectChanges();
|
||||
expect(compiled.querySelector('#upload-single-file')).toBeDefined();
|
||||
});
|
||||
|
||||
it('should render upload-multiple-file button if multipleFiles is true', () => {
|
||||
component.multipleFiles = true;
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
const compiled = fixture.debugElement.nativeElement;
|
||||
fixture.detectChanges();
|
||||
expect(compiled.querySelector('#upload-multiple-files')).toBeDefined();
|
||||
});
|
||||
|
||||
it('should render an uploadFolder button if uploadFolder is true', () => {
|
||||
component.uploadFolders = true;
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
const compiled = fixture.debugElement.nativeElement;
|
||||
fixture.detectChanges();
|
||||
expect(compiled.querySelector('#uploadFolder')).toBeDefined();
|
||||
});
|
||||
@@ -104,7 +104,7 @@ describe('UploadButtonComponent', () => {
|
||||
it('should disable uploadFolder button if disabled is true', () => {
|
||||
component.disabled = true;
|
||||
component.uploadFolders = true;
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
const compiled = fixture.debugElement.nativeElement;
|
||||
fixture.detectChanges();
|
||||
expect(compiled.querySelector('#uploadFolder').getAttribute('disabled')).toBe('true');
|
||||
});
|
||||
@@ -112,7 +112,7 @@ describe('UploadButtonComponent', () => {
|
||||
it('should disable upload-single-file button if disabled is true', () => {
|
||||
component.disabled = true;
|
||||
component.multipleFiles = false;
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
const compiled = fixture.debugElement.nativeElement;
|
||||
fixture.detectChanges();
|
||||
expect(compiled.querySelector('#upload-single-file').getAttribute('disabled')).toBe('true');
|
||||
});
|
||||
@@ -182,7 +182,7 @@ describe('UploadButtonComponent', () => {
|
||||
});
|
||||
|
||||
it('should by default the title of the button get from the JSON file', () => {
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
const compiled = fixture.debugElement.nativeElement;
|
||||
fixture.detectChanges();
|
||||
component.uploadFolders = false;
|
||||
component.multipleFiles = false;
|
||||
@@ -199,7 +199,7 @@ describe('UploadButtonComponent', () => {
|
||||
});
|
||||
|
||||
it('should staticTitle properties change the title of the upload buttons', () => {
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
const compiled = fixture.debugElement.nativeElement;
|
||||
component.staticTitle = 'test-text';
|
||||
component.uploadFolders = false;
|
||||
component.multipleFiles = false;
|
||||
|
||||
@@ -78,7 +78,7 @@ export class UploadButtonComponent extends UploadBase implements OnInit, OnChang
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
let rootFolderId = changes['rootFolderId'];
|
||||
const rootFolderId = changes['rootFolderId'];
|
||||
if (rootFolderId && rootFolderId.currentValue) {
|
||||
this.checkPermission();
|
||||
}
|
||||
@@ -89,7 +89,7 @@ export class UploadButtonComponent extends UploadBase implements OnInit, OnChang
|
||||
}
|
||||
|
||||
onFilesAdded($event: any): void {
|
||||
let files: File[] = FileUtils.toFileArray($event.currentTarget.files);
|
||||
const files: File[] = FileUtils.toFileArray($event.currentTarget.files);
|
||||
|
||||
if (this.hasAllowableOperations) {
|
||||
this.uploadFiles(files);
|
||||
@@ -102,7 +102,7 @@ export class UploadButtonComponent extends UploadBase implements OnInit, OnChang
|
||||
|
||||
onDirectoryAdded($event: any): void {
|
||||
if (this.hasAllowableOperations) {
|
||||
let files: File[] = FileUtils.toFileArray($event.currentTarget.files);
|
||||
const files: File[] = FileUtils.toFileArray($event.currentTarget.files);
|
||||
this.uploadFiles(files);
|
||||
} else {
|
||||
this.permissionEvent.emit(new PermissionModel({ type: 'content', action: 'upload', permission: 'create' }));
|
||||
@@ -113,7 +113,7 @@ export class UploadButtonComponent extends UploadBase implements OnInit, OnChang
|
||||
|
||||
checkPermission() {
|
||||
if (this.rootFolderId) {
|
||||
let opts: any = {
|
||||
const opts: any = {
|
||||
includeSource: true,
|
||||
include: ['allowableOperations']
|
||||
};
|
||||
|
||||
@@ -163,7 +163,7 @@ describe('UploadDragAreaComponent', () => {
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue');
|
||||
fixture.detectChanges();
|
||||
|
||||
let itemEntity = {
|
||||
const itemEntity = {
|
||||
isDirectory: true,
|
||||
createReader: () => {
|
||||
return {
|
||||
@@ -187,20 +187,20 @@ describe('UploadDragAreaComponent', () => {
|
||||
spyOn(uploadService, 'addToQueue');
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue');
|
||||
|
||||
let fakeItem = {
|
||||
const fakeItem = {
|
||||
fullPath: '/folder-fake/file-fake.png',
|
||||
isDirectory: false,
|
||||
isFile: true,
|
||||
relativeFolder: '/',
|
||||
name: 'file-fake.png',
|
||||
file: (callbackFile) => {
|
||||
let fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
|
||||
const fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
|
||||
callbackFile(fileFake);
|
||||
}
|
||||
};
|
||||
fixture.detectChanges();
|
||||
|
||||
let fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
|
||||
const fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
|
||||
detail: { data: getFakeShareDataRow([]), files: [fakeItem] }
|
||||
});
|
||||
component.onUploadFiles(fakeCustomEvent);
|
||||
@@ -288,19 +288,19 @@ describe('UploadDragAreaComponent', () => {
|
||||
}));
|
||||
|
||||
it('should upload a file when user has create permission on target folder', async(() => {
|
||||
let fakeItem = {
|
||||
const fakeItem = {
|
||||
fullPath: '/folder-fake/file-fake.png',
|
||||
isDirectory: false,
|
||||
isFile: true,
|
||||
name: 'file-fake.png',
|
||||
relativeFolder: '/',
|
||||
file: (callbackFile) => {
|
||||
let fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
|
||||
const fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
|
||||
callbackFile(fileFake);
|
||||
}
|
||||
};
|
||||
|
||||
let fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
|
||||
const fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
|
||||
detail: {
|
||||
data: getFakeShareDataRow(),
|
||||
files: [fakeItem]
|
||||
@@ -313,14 +313,14 @@ describe('UploadDragAreaComponent', () => {
|
||||
|
||||
it('should upload a file to a specific target folder when dropped onto one', async(() => {
|
||||
|
||||
let fakeItem = {
|
||||
const fakeItem = {
|
||||
fullPath: '/folder-fake/file-fake.png',
|
||||
isDirectory: false,
|
||||
isFile: true,
|
||||
name: 'file-fake.png',
|
||||
relativeFolder: '/',
|
||||
file: (callbackFile) => {
|
||||
let fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
|
||||
const fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
|
||||
callbackFile(fileFake);
|
||||
}
|
||||
};
|
||||
@@ -330,7 +330,7 @@ describe('UploadDragAreaComponent', () => {
|
||||
expect(fileList.options.path).toBe('pippo/');
|
||||
});
|
||||
|
||||
let fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
|
||||
const fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
|
||||
detail: {
|
||||
data: getFakeShareDataRow(),
|
||||
files: [fakeItem]
|
||||
@@ -342,14 +342,14 @@ describe('UploadDragAreaComponent', () => {
|
||||
|
||||
it('should upload a folder to a specific target folder when dropped onto one', async(() => {
|
||||
|
||||
let fakeItem = {
|
||||
const fakeItem = {
|
||||
fullPath: '/folder-fake/file-fake.png',
|
||||
isDirectory: false,
|
||||
isFile: true,
|
||||
name: 'file-fake.png',
|
||||
relativeFolder: '/super',
|
||||
file: (callbackFile) => {
|
||||
let fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
|
||||
const fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
|
||||
callbackFile(fileFake);
|
||||
}
|
||||
};
|
||||
@@ -359,7 +359,7 @@ describe('UploadDragAreaComponent', () => {
|
||||
expect(fileList.options.path).toBe('pippo/super');
|
||||
});
|
||||
|
||||
let fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
|
||||
const fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
|
||||
detail: {
|
||||
data: getFakeShareDataRow(),
|
||||
files: [fakeItem]
|
||||
@@ -371,14 +371,14 @@ describe('UploadDragAreaComponent', () => {
|
||||
|
||||
it('should upload the file in the current folder when the target is file', async(() => {
|
||||
|
||||
let fakeItem = {
|
||||
const fakeItem = {
|
||||
fullPath: '/folder-fake/file-fake.png',
|
||||
isDirectory: false,
|
||||
isFile: true,
|
||||
name: 'file-fake.png',
|
||||
relativeFolder: '/',
|
||||
file: (callbackFile) => {
|
||||
let fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
|
||||
const fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
|
||||
callbackFile(fileFake);
|
||||
}
|
||||
};
|
||||
@@ -388,7 +388,7 @@ describe('UploadDragAreaComponent', () => {
|
||||
expect(fileList.options.path).toBe('/');
|
||||
});
|
||||
|
||||
let fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
|
||||
const fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
|
||||
detail: {
|
||||
data: getFakeFileShareRow(),
|
||||
files: [fakeItem]
|
||||
@@ -404,14 +404,14 @@ describe('UploadDragAreaComponent', () => {
|
||||
it('should raise an error if upload a file goes wrong', (done) => {
|
||||
spyOn(uploadService, 'getUploadPromise').and.callThrough();
|
||||
|
||||
let fakeItem = {
|
||||
const fakeItem = {
|
||||
fullPath: '/folder-fake/file-fake.png',
|
||||
isDirectory: false,
|
||||
isFile: true,
|
||||
relativeFolder: '/',
|
||||
name: 'file-fake.png',
|
||||
file: (callbackFile) => {
|
||||
let fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
|
||||
const fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
|
||||
callbackFile(fileFake);
|
||||
}
|
||||
};
|
||||
@@ -424,7 +424,7 @@ describe('UploadDragAreaComponent', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
let fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
|
||||
const fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
|
||||
detail: {
|
||||
data: getFakeShareDataRow(),
|
||||
files: [fakeItem]
|
||||
|
||||
@@ -94,9 +94,9 @@ export class UploadDragAreaComponent extends UploadBase implements NodeAllowable
|
||||
onUploadFiles(event: CustomEvent) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
let isAllowed: boolean = this.contentService.hasAllowableOperations(event.detail.data.obj.entry, AllowableOperationsEnum.CREATE);
|
||||
const isAllowed: boolean = this.contentService.hasAllowableOperations(event.detail.data.obj.entry, AllowableOperationsEnum.CREATE);
|
||||
if (isAllowed) {
|
||||
let fileInfo: FileInfo[] = event.detail.files;
|
||||
const fileInfo: FileInfo[] = event.detail.files;
|
||||
if (this.isTargetNodeFolder(event)) {
|
||||
const destinationFolderName = event.detail.data.obj.entry.name;
|
||||
fileInfo.map((file) => file.relativeFolder = destinationFolderName ? destinationFolderName.concat(file.relativeFolder) : file.relativeFolder);
|
||||
|
||||
@@ -23,7 +23,7 @@ describe('FileDraggableDirective', () => {
|
||||
let component: FileDraggableDirective;
|
||||
|
||||
beforeEach( () => {
|
||||
let el = new ElementRef(null);
|
||||
const el = new ElementRef(null);
|
||||
component = new FileDraggableDirective(el, null);
|
||||
});
|
||||
|
||||
@@ -33,7 +33,7 @@ describe('FileDraggableDirective', () => {
|
||||
|
||||
it('should not allow drag and drop when disabled', () => {
|
||||
component.enabled = false;
|
||||
let event = new CustomEvent('custom-event');
|
||||
const event = new CustomEvent('custom-event');
|
||||
spyOn(event, 'preventDefault').and.stub();
|
||||
component.onDropFiles(event);
|
||||
component.onDragEnter(event);
|
||||
|
||||
@@ -176,9 +176,9 @@ describe('VersionListComponent', () => {
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let versionFileName = fixture.debugElement.query(By.css('.adf-version-list-item-name')).nativeElement.innerText;
|
||||
let versionIdText = fixture.debugElement.query(By.css('.adf-version-list-item-version')).nativeElement.innerText;
|
||||
let versionComment = fixture.debugElement.query(By.css('.adf-version-list-item-comment')).nativeElement.innerText;
|
||||
const versionFileName = fixture.debugElement.query(By.css('.adf-version-list-item-name')).nativeElement.innerText;
|
||||
const versionIdText = fixture.debugElement.query(By.css('.adf-version-list-item-version')).nativeElement.innerText;
|
||||
const versionComment = fixture.debugElement.query(By.css('.adf-version-list-item-comment')).nativeElement.innerText;
|
||||
|
||||
expect(versionFileName).toBe('test-file-name');
|
||||
expect(versionIdText).toBe('1.0');
|
||||
@@ -208,7 +208,7 @@ describe('VersionListComponent', () => {
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let versionCommentEl = fixture.debugElement.query(By.css('.adf-version-list-item-comment'));
|
||||
const versionCommentEl = fixture.debugElement.query(By.css('.adf-version-list-item-comment'));
|
||||
|
||||
expect(versionCommentEl).toBeNull();
|
||||
done();
|
||||
@@ -332,7 +332,7 @@ describe('VersionListComponent', () => {
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let menuButton = fixture.nativeElement.querySelector('[id="adf-version-list-action-menu-button-1.0"]');
|
||||
const menuButton = fixture.nativeElement.querySelector('[id="adf-version-list-action-menu-button-1.0"]');
|
||||
|
||||
expect(menuButton).not.toBeNull();
|
||||
done();
|
||||
@@ -345,7 +345,7 @@ describe('VersionListComponent', () => {
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let menuButton = fixture.nativeElement.querySelector('[id="adf-version-list-action-menu-button-1.0"]');
|
||||
const menuButton = fixture.nativeElement.querySelector('[id="adf-version-list-action-menu-button-1.0"]');
|
||||
|
||||
expect(menuButton).toBeNull();
|
||||
done();
|
||||
@@ -379,10 +379,10 @@ describe('VersionListComponent', () => {
|
||||
it('should disable delete action if is not allowed', (done) => {
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let menuButton = fixture.nativeElement.querySelector('[id="adf-version-list-action-menu-button-1.1"]');
|
||||
const menuButton = fixture.nativeElement.querySelector('[id="adf-version-list-action-menu-button-1.1"]');
|
||||
menuButton.click();
|
||||
|
||||
let deleteButton: any = document.querySelector('[id="adf-version-list-action-delete-1.1"]');
|
||||
const deleteButton: any = document.querySelector('[id="adf-version-list-action-delete-1.1"]');
|
||||
|
||||
expect(deleteButton.disabled).toBe(true);
|
||||
done();
|
||||
@@ -392,10 +392,10 @@ describe('VersionListComponent', () => {
|
||||
it('should disable restore action if is not allowed', (done) => {
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let menuButton = fixture.nativeElement.querySelector('[id="adf-version-list-action-menu-button-1.1"]');
|
||||
const menuButton = fixture.nativeElement.querySelector('[id="adf-version-list-action-menu-button-1.1"]');
|
||||
menuButton.click();
|
||||
|
||||
let restoreButton: any = document.querySelector('[id="adf-version-list-action-restore-1.1"]');
|
||||
const restoreButton: any = document.querySelector('[id="adf-version-list-action-restore-1.1"]');
|
||||
|
||||
expect(restoreButton.disabled).toBe(true);
|
||||
done();
|
||||
@@ -429,10 +429,10 @@ describe('VersionListComponent', () => {
|
||||
it('should enable delete action if is allowed', (done) => {
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let menuButton = fixture.nativeElement.querySelector('[id="adf-version-list-action-menu-button-1.1"]');
|
||||
const menuButton = fixture.nativeElement.querySelector('[id="adf-version-list-action-menu-button-1.1"]');
|
||||
menuButton.click();
|
||||
|
||||
let deleteButton: any = document.querySelector('[id="adf-version-list-action-delete-1.1"]');
|
||||
const deleteButton: any = document.querySelector('[id="adf-version-list-action-delete-1.1"]');
|
||||
|
||||
expect(deleteButton.disabled).toBe(false);
|
||||
done();
|
||||
@@ -442,10 +442,10 @@ describe('VersionListComponent', () => {
|
||||
it('should enable restore action if is allowed', (done) => {
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let menuButton = fixture.nativeElement.querySelector('[id="adf-version-list-action-menu-button-1.1"]');
|
||||
const menuButton = fixture.nativeElement.querySelector('[id="adf-version-list-action-menu-button-1.1"]');
|
||||
menuButton.click();
|
||||
|
||||
let restoreButton: any = document.querySelector('[id="adf-version-list-action-restore-1.1"]');
|
||||
const restoreButton: any = document.querySelector('[id="adf-version-list-action-restore-1.1"]');
|
||||
|
||||
expect(restoreButton.disabled).toBe(false);
|
||||
done();
|
||||
|
||||
@@ -78,7 +78,7 @@ describe('VersionManagerComponent', () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let versionCommentEl = fixture.debugElement.query(By.css('.adf-version-list-item-comment'));
|
||||
const versionCommentEl = fixture.debugElement.query(By.css('.adf-version-list-item-comment'));
|
||||
|
||||
expect(versionCommentEl).not.toBeNull();
|
||||
expect(versionCommentEl.nativeElement.innerText).toBe(expectedComment);
|
||||
@@ -91,7 +91,7 @@ describe('VersionManagerComponent', () => {
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let versionCommentEl = fixture.debugElement.query(By.css('.adf-version-list-item-comment'));
|
||||
const versionCommentEl = fixture.debugElement.query(By.css('.adf-version-list-item-comment'));
|
||||
|
||||
expect(versionCommentEl).toBeNull();
|
||||
});
|
||||
@@ -128,7 +128,7 @@ describe('VersionManagerComponent', () => {
|
||||
it('should upload button be visible after click on add new version button', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
let showUploadButton = fixture.debugElement.query(By.css('#adf-show-version-upload-button'));
|
||||
const showUploadButton = fixture.debugElement.query(By.css('#adf-show-version-upload-button'));
|
||||
|
||||
showUploadButton.nativeElement.click();
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ describe('WebscriptComponent', () => {
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
let appConfig: AppConfigService = TestBed.get(AppConfigService);
|
||||
const appConfig: AppConfigService = TestBed.get(AppConfigService);
|
||||
appConfig.config.ecmHost = 'http://localhost:9876/ecm';
|
||||
|
||||
fixture = TestBed.createComponent(WebscriptComponent);
|
||||
@@ -162,7 +162,7 @@ describe('WebscriptComponent', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
let dataTable = {
|
||||
const dataTable = {
|
||||
data: [
|
||||
{id: 1, name: 'Name 1'},
|
||||
{id: 2, name: 'Name 2'}
|
||||
@@ -200,7 +200,7 @@ describe('WebscriptComponent', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
let dataTable = {
|
||||
const dataTable = {
|
||||
data: [
|
||||
{id: 1, name: 'Name 1'},
|
||||
{id: 2, name: 'Name 2'}
|
||||
|
||||
@@ -119,7 +119,7 @@ export class WebscriptComponent implements OnChanges {
|
||||
* @returns the data as datatable
|
||||
*/
|
||||
showDataAsDataTable(data: any) {
|
||||
let datatableData: any = null;
|
||||
const datatableData: any = null;
|
||||
try {
|
||||
|
||||
if (!data.schema) {
|
||||
|
||||
Reference in New Issue
Block a user