mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[ADF-1873] Remove all deprecated code from ADF (#4145)
* remove deprecated code part 1 * remove deprecation step 2 * fix spellcheck * fix * fix lint * fix not used import * remove deprecation * fix test first part after remove deprecation * fix test * fix sidebar demo shell
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
<header
|
||||
mat-dialog-title
|
||||
data-automation-id="content-node-selector-title">{{title || data?.title}}
|
||||
data-automation-id="content-node-selector-title">{{data?.title}}
|
||||
</header>
|
||||
|
||||
<mat-dialog-content>
|
||||
<adf-content-node-selector-panel
|
||||
[currentFolderId]="currentFolderId || data?.currentFolderId"
|
||||
[dropdownHideMyFiles]="dropdownHideMyFiles || data?.dropdownHideMyFiles"
|
||||
[dropdownSiteList]="dropdownSiteList || data?.dropdownSiteList"
|
||||
[rowFilter]="rowFilter || data?.rowFilter"
|
||||
[imageResolver]="imageResolver || data?.imageResolver"
|
||||
[currentFolderId]="data?.currentFolderId"
|
||||
[dropdownHideMyFiles]="data?.dropdownHideMyFiles"
|
||||
[dropdownSiteList]="data?.dropdownSiteList"
|
||||
[rowFilter]="data?.rowFilter"
|
||||
[imageResolver]="data?.imageResolver"
|
||||
[isSelectionValid]="data?.isSelectionValid"
|
||||
[breadcrumbTransform]="data?.breadcrumbTransform"
|
||||
[excludeSiteContent]="data?.excludeSiteContent"
|
||||
|
||||
@@ -15,12 +15,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Inject, ViewEncapsulation, Input } from '@angular/core';
|
||||
import { Component, Inject, ViewEncapsulation } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA } from '@angular/material';
|
||||
import { Node, SitePaging } from '@alfresco/js-api';
|
||||
import { Node } from '@alfresco/js-api';
|
||||
import { ContentNodeSelectorComponentData } from './content-node-selector.component-data.interface';
|
||||
import { RowFilter } from '../document-list/data/row-filter.model';
|
||||
import { ImageResolver } from '../document-list/data/image-resolver.model';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-content-node-selector',
|
||||
@@ -30,48 +28,6 @@ import { ImageResolver } from '../document-list/data/image-resolver.model';
|
||||
})
|
||||
export class ContentNodeSelectorComponent {
|
||||
|
||||
/**
|
||||
* @deprecated in 2.1.0
|
||||
*/
|
||||
@Input()
|
||||
title: string = null;
|
||||
|
||||
/**
|
||||
* @deprecated in 2.1.0
|
||||
*/
|
||||
@Input()
|
||||
currentFolderId: string = null;
|
||||
|
||||
/**
|
||||
* @deprecated in 2.1.0
|
||||
*/
|
||||
@Input()
|
||||
dropdownHideMyFiles: boolean = false;
|
||||
|
||||
/**
|
||||
* @deprecated in 2.1.0
|
||||
*/
|
||||
@Input()
|
||||
dropdownSiteList: SitePaging = null;
|
||||
|
||||
/**
|
||||
* @deprecated in 2.1.0
|
||||
*/
|
||||
@Input()
|
||||
rowFilter: RowFilter = null;
|
||||
|
||||
/**
|
||||
* @deprecated in 2.1.0
|
||||
*/
|
||||
@Input()
|
||||
imageResolver: ImageResolver = null;
|
||||
|
||||
/**
|
||||
* @deprecated in 2.1.0
|
||||
*/
|
||||
@Input()
|
||||
pageSize: number;
|
||||
|
||||
buttonActionName: string;
|
||||
chosenNode: Node[];
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ describe('ShareDialogComponent', () => {
|
||||
|
||||
it('should open a confirmation dialog when unshare button is triggered', () => {
|
||||
spyOn(matDialog, 'open').and.returnValue({ beforeClose: () => of(false) });
|
||||
spyOn(sharedLinksApiService, 'deleteSharedLink');
|
||||
spyOn(sharedLinksApiService, 'deleteSharedLink').and.callThrough();
|
||||
node.entry.properties['qshare:sharedId'] = 'sharedId';
|
||||
|
||||
component.data = {
|
||||
@@ -167,7 +167,7 @@ describe('ShareDialogComponent', () => {
|
||||
|
||||
it('should unshare file when confirmation dialog returns true', fakeAsync(() => {
|
||||
spyOn(matDialog, 'open').and.returnValue({ beforeClose: () => of(true) });
|
||||
spyOn(sharedLinksApiService, 'deleteSharedLink');
|
||||
spyOn(sharedLinksApiService, 'deleteSharedLink').and.callThrough();
|
||||
node.entry.properties['qshare:sharedId'] = 'sharedId';
|
||||
|
||||
component.data = {
|
||||
@@ -187,7 +187,7 @@ describe('ShareDialogComponent', () => {
|
||||
|
||||
it('should not unshare file when confirmation dialog returns false', fakeAsync(() => {
|
||||
spyOn(matDialog, 'open').and.returnValue({ beforeClose: () => of(false) });
|
||||
spyOn(sharedLinksApiService, 'deleteSharedLink');
|
||||
spyOn(sharedLinksApiService, 'deleteSharedLink').and.callThrough();
|
||||
node.entry.properties['qshare:sharedId'] = 'sharedId';
|
||||
|
||||
component.data = {
|
||||
|
||||
@@ -72,6 +72,7 @@ describe('DocumentList', () => {
|
||||
customResourcesService = TestBed.get(CustomResourcesService);
|
||||
|
||||
documentList.ngOnInit();
|
||||
documentList.currentFolderId = 'no-node';
|
||||
|
||||
spyGetSites = spyOn(apiService.sitesApi, 'getSites').and.returnValue(Promise.resolve(fakeGetSitesAnswer));
|
||||
spyFavorite = spyOn(apiService.favoritesApi, 'getFavorites').and.returnValue(Promise.resolve({ list: [] }));
|
||||
@@ -246,20 +247,17 @@ describe('DocumentList', () => {
|
||||
expect(documentList.dataTable.resetSelection).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should empty template be present when no element are present', (done) => {
|
||||
fixture.detectChanges();
|
||||
documentList.folderNode = new NodeMinimal();
|
||||
documentList.folderNode.id = '1d26e465-dea3-42f3-b415-faa8364b9692';
|
||||
|
||||
it('should empty template be present when no element are present', () => {
|
||||
spyOn(documentList, 'loadFolderNodesByFolderNodeId').and.returnValue(Promise.resolve(''));
|
||||
spyOn(documentList, 'loadFolder').and.callThrough();
|
||||
spyOn(documentListService, 'getFolderNode').and.returnValue(of({ entry: { id: 'fake-node' } }));
|
||||
spyOn(documentListService, 'getFolder').and.returnValue(of(fakeNodeAnswerWithNOEntries));
|
||||
|
||||
let disposableReady = documentList.ready.subscribe(() => {
|
||||
expect(element.querySelector('#adf-document-list-empty')).toBeDefined();
|
||||
disposableReady.unsubscribe();
|
||||
done();
|
||||
});
|
||||
documentList.currentFolderId = '1d26e465-dea3-42f3-b415-faa8364b9692';
|
||||
fixture.detectChanges();
|
||||
|
||||
documentList.reload();
|
||||
expect(element.querySelector('#adf-document-list-empty')).toBeDefined();
|
||||
});
|
||||
|
||||
it('should not execute action without node provided', () => {
|
||||
@@ -959,10 +957,9 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should load folder by ID on init', () => {
|
||||
documentList.currentFolderId = '1d26e465-dea3-42f3-b415-faa8364b9692';
|
||||
spyOn(documentList, 'loadFolder').and.returnValue(Promise.resolve());
|
||||
|
||||
documentList.ngOnChanges({ folderNode: new SimpleChange(null, documentList.currentFolderId, true) });
|
||||
documentList.ngOnChanges({ currentFolderId: new SimpleChange(null, '1d26e465-dea3-42f3-b415-faa8364b9692', true) });
|
||||
expect(documentList.loadFolder).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -1294,7 +1291,6 @@ describe('DocumentList', () => {
|
||||
spyOn(documentList, 'reload').and.stub();
|
||||
|
||||
documentList.maxItems = 0;
|
||||
documentList.skipCount = 0;
|
||||
|
||||
documentList.updatePagination({
|
||||
maxItems: 10,
|
||||
@@ -1313,32 +1309,6 @@ describe('DocumentList', () => {
|
||||
expect(documentList.reload).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should NOT reload data on ngOnChanges upon reset of skipCount to 0', () => {
|
||||
spyOn(documentList, 'reload').and.stub();
|
||||
|
||||
documentList.maxItems = 10;
|
||||
documentList.skipCount = 10;
|
||||
|
||||
const firstChange = true;
|
||||
documentList.ngOnChanges({ skipCount: new SimpleChange(undefined, 0, !firstChange) });
|
||||
|
||||
expect(documentList.reload).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should reload data upon changing pagination setting skipCount to 0', () => {
|
||||
spyOn(documentList, 'reload').and.stub();
|
||||
|
||||
documentList.maxItems = 5;
|
||||
documentList.skipCount = 5;
|
||||
|
||||
documentList.updatePagination({
|
||||
maxItems: 5,
|
||||
skipCount: 0
|
||||
});
|
||||
|
||||
expect(documentList.reload).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should add includeFields in the server request when present', () => {
|
||||
fixture.detectChanges();
|
||||
documentList.currentFolderId = 'fake-id';
|
||||
|
||||
@@ -173,13 +173,6 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
@Input()
|
||||
currentFolderId: string = null;
|
||||
|
||||
/**
|
||||
* Currently displayed folder node
|
||||
* @deprecated 2.3.0 - use currentFolderId or node
|
||||
*/
|
||||
@Input()
|
||||
folderNode: Node = null;
|
||||
|
||||
/** The Document list will show all the nodes contained in the NodePaging entity */
|
||||
@Input()
|
||||
node: NodePaging = null;
|
||||
@@ -188,20 +181,6 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
@Input()
|
||||
maxItems: number;
|
||||
|
||||
/**
|
||||
* Number of elements to skip over for pagination purposes
|
||||
* @deprecated 2.3.0 - define it in pagination
|
||||
*/
|
||||
@Input()
|
||||
skipCount: number = 0;
|
||||
|
||||
/**
|
||||
* Set document list to work in infinite scrolling mode
|
||||
* @deprecated 2.3.0
|
||||
*/
|
||||
@Input()
|
||||
enableInfiniteScrolling: boolean = false;
|
||||
|
||||
/** Emitted when the user clicks a list node */
|
||||
@Output()
|
||||
nodeClick: EventEmitter<NodeEntityEvent> = new EventEmitter<NodeEntityEvent>();
|
||||
@@ -239,6 +218,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
data: ShareDataTableAdapter;
|
||||
noPermission: boolean = false;
|
||||
selection = new Array<NodeEntry>();
|
||||
folderNode: Node = null;
|
||||
|
||||
private _pagination: BehaviorSubject<PaginationModel>;
|
||||
private layoutPresets = {};
|
||||
@@ -272,11 +252,6 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @deprecated 2.3.0 define it in pagination */
|
||||
get supportedPageSizes(): number[] {
|
||||
return this.preferences.getDefaultPageSizes();
|
||||
}
|
||||
|
||||
get hasCustomLayout(): boolean {
|
||||
return this.columnList && this.columnList.columns && this.columnList.columns.length > 0;
|
||||
}
|
||||
@@ -296,7 +271,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
|
||||
get pagination(): BehaviorSubject<PaginationModel> {
|
||||
if (!this._pagination) {
|
||||
let maxItems = this.maxItems || this.preferences.paginationSize;
|
||||
let maxItems = this.maxItems || this.preferences.paginationSize;
|
||||
let defaultPagination = <PaginationModel> {
|
||||
maxItems: maxItems,
|
||||
skipCount: 0,
|
||||
@@ -337,7 +312,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
ngOnInit() {
|
||||
this.rowMenuCache = {};
|
||||
this.loadLayoutPresets();
|
||||
this.data = new ShareDataTableAdapter(this.documentListService, this.thumbnailService, null, this.getDefaultSorting(), this.sortingMode);
|
||||
this.data = new ShareDataTableAdapter(this.documentListService, this.thumbnailService, this.contentService, null, this.getDefaultSorting(), this.sortingMode);
|
||||
this.data.thumbnails = this.thumbnails;
|
||||
this.data.permissionsStyle = this.permissionsStyle;
|
||||
|
||||
@@ -375,7 +350,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
}
|
||||
|
||||
if (!this.data) {
|
||||
this.data = new ShareDataTableAdapter(this.documentListService, this.thumbnailService, schema, this.getDefaultSorting(), this.sortingMode);
|
||||
this.data = new ShareDataTableAdapter(this.documentListService, this.thumbnailService, this.contentService, schema, this.getDefaultSorting(), this.sortingMode);
|
||||
} else if (schema && schema.length > 0) {
|
||||
this.data.setColumns(schema);
|
||||
}
|
||||
@@ -404,11 +379,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
}
|
||||
}
|
||||
|
||||
if (changes.folderNode && changes.folderNode.currentValue) {
|
||||
this.currentFolderId = changes.folderNode.currentValue.id;
|
||||
this.resetNewFolderPagination();
|
||||
this.loadFolder();
|
||||
} else if (changes.currentFolderId &&
|
||||
if (changes.currentFolderId &&
|
||||
changes.currentFolderId.currentValue &&
|
||||
changes.currentFolderId.currentValue !== changes.currentFolderId.previousValue) {
|
||||
this.resetNewFolderPagination();
|
||||
@@ -600,12 +571,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
this.setupDefaultColumns(this.currentFolderId);
|
||||
}
|
||||
|
||||
if (this.folderNode) {
|
||||
return this.loadFolderNodesByFolderNodeId(this.folderNode.id, this.pagination.getValue())
|
||||
.catch((err) => this.handleError(err));
|
||||
} else {
|
||||
this.loadFolderByNodeId(this.currentFolderId);
|
||||
}
|
||||
this.loadFolderByNodeId(this.currentFolderId);
|
||||
}
|
||||
|
||||
loadFolderByNodeId(nodeId: string) {
|
||||
|
||||
@@ -15,10 +15,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { DataRow, ObjectUtils, ThumbnailService } from '@alfresco/adf-core';
|
||||
import { DataRow, ObjectUtils, ThumbnailService, ContentService } from '@alfresco/adf-core';
|
||||
import { MinimalNode, NodeEntry } from '@alfresco/js-api';
|
||||
import { PermissionStyleModel } from './../models/permissions-style.model';
|
||||
import { DocumentListService } from './../services/document-list.service';
|
||||
|
||||
export class ShareDataRow implements DataRow {
|
||||
|
||||
@@ -34,7 +33,7 @@ export class ShareDataRow implements DataRow {
|
||||
}
|
||||
|
||||
constructor(private obj: NodeEntry,
|
||||
private documentListService: DocumentListService,
|
||||
private contentService: ContentService,
|
||||
private permissionsStyle: PermissionStyleModel[],
|
||||
private thumbnailService?: ThumbnailService) {
|
||||
if (!obj) {
|
||||
@@ -55,7 +54,7 @@ export class ShareDataRow implements DataRow {
|
||||
|
||||
if (this.applyPermissionStyleToFolder(nodeEntity.entry, currentPermissionsStyle) || this.applyPermissionStyleToFile(nodeEntity.entry, currentPermissionsStyle)) {
|
||||
|
||||
if (this.documentListService.hasPermission(nodeEntity.entry, currentPermissionsStyle.permission)) {
|
||||
if (this.contentService.hasPermission(nodeEntity.entry, currentPermissionsStyle.permission)) {
|
||||
permissionsClasses += ` ${currentPermissionsStyle.css}`;
|
||||
}
|
||||
}
|
||||
@@ -74,7 +73,7 @@ export class ShareDataRow implements DataRow {
|
||||
}
|
||||
|
||||
isFolderAndHasPermissionToUpload(nodeEntry: NodeEntry): boolean {
|
||||
return this.isFolder(nodeEntry) && this.documentListService.hasPermission(nodeEntry.entry, 'create');
|
||||
return this.isFolder(nodeEntry) && this.contentService.hasPermission(nodeEntry.entry, 'create');
|
||||
}
|
||||
|
||||
isFolder(nodeEntry: NodeEntry): boolean {
|
||||
|
||||
@@ -24,21 +24,22 @@ import { ShareDataTableAdapter } from './share-datatable-adapter';
|
||||
describe('ShareDataTableAdapter', () => {
|
||||
|
||||
let documentListService: DocumentListService;
|
||||
let contentService: ContentService;
|
||||
|
||||
beforeEach(() => {
|
||||
let imageUrl: string = 'http://<addresss>';
|
||||
let contentService = new ContentService(null, null, null, null);
|
||||
contentService = new ContentService(null, null, null, null);
|
||||
documentListService = new DocumentListService(null, contentService, null, null, null);
|
||||
spyOn(documentListService, 'getDocumentThumbnailUrl').and.returnValue(imageUrl);
|
||||
});
|
||||
|
||||
it('should use client sorting by default', () => {
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, []);
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, []);
|
||||
expect(adapter.sortingMode).toBe('client');
|
||||
});
|
||||
|
||||
it('should not be case sensitive for sorting mode value', () => {
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, []);
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, []);
|
||||
|
||||
adapter.sortingMode = 'CLIENT';
|
||||
expect(adapter.sortingMode).toBe('client');
|
||||
@@ -48,7 +49,7 @@ describe('ShareDataTableAdapter', () => {
|
||||
});
|
||||
|
||||
it('should fallback to client sorting for unknown values', () => {
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, []);
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, []);
|
||||
|
||||
adapter.sortingMode = 'SeRvEr';
|
||||
expect(adapter.sortingMode).toBe('server');
|
||||
@@ -59,27 +60,27 @@ describe('ShareDataTableAdapter', () => {
|
||||
|
||||
it('should setup rows and columns with constructor', () => {
|
||||
let schema = [<DataColumn> {}];
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, schema);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, schema);
|
||||
|
||||
expect(adapter.getRows()).toEqual([]);
|
||||
expect(adapter.getColumns()).toEqual(schema);
|
||||
});
|
||||
|
||||
it('should setup columns when constructor is missing schema', () => {
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
expect(adapter.getColumns()).toEqual([]);
|
||||
});
|
||||
|
||||
it('should set new columns', () => {
|
||||
let columns = [<DataColumn> {}, <DataColumn> {}];
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
adapter.setColumns(columns);
|
||||
expect(adapter.getColumns()).toEqual(columns);
|
||||
});
|
||||
|
||||
it('should reset columns', () => {
|
||||
let columns = [<DataColumn> {}, <DataColumn> {}];
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, columns);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, columns);
|
||||
|
||||
expect(adapter.getColumns()).toEqual(columns);
|
||||
adapter.setColumns(null);
|
||||
@@ -88,7 +89,7 @@ describe('ShareDataTableAdapter', () => {
|
||||
|
||||
it('should set new rows', () => {
|
||||
let rows = [<DataRow> {}, <DataRow> {}];
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
expect(adapter.getRows()).toEqual([]);
|
||||
adapter.setRows(rows);
|
||||
@@ -97,7 +98,7 @@ describe('ShareDataTableAdapter', () => {
|
||||
|
||||
it('should reset rows', () => {
|
||||
let rows = [<DataRow> {}, <DataRow> {}];
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
adapter.setRows(rows);
|
||||
expect(adapter.getRows()).toEqual(rows);
|
||||
@@ -107,7 +108,7 @@ describe('ShareDataTableAdapter', () => {
|
||||
});
|
||||
|
||||
it('should sort new rows', () => {
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
spyOn(adapter, 'sort').and.callThrough();
|
||||
|
||||
let rows = [<DataRow> {}];
|
||||
@@ -117,7 +118,7 @@ describe('ShareDataTableAdapter', () => {
|
||||
});
|
||||
|
||||
it('should fail when getting value for missing row', () => {
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
let check = () => {
|
||||
return adapter.getValue(null, <DataColumn> {});
|
||||
};
|
||||
@@ -125,7 +126,7 @@ describe('ShareDataTableAdapter', () => {
|
||||
});
|
||||
|
||||
it('should fail when getting value for missing column', () => {
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
let check = () => {
|
||||
return adapter.getValue(<DataRow> {}, null);
|
||||
};
|
||||
@@ -143,8 +144,8 @@ describe('ShareDataTableAdapter', () => {
|
||||
type: 'string'
|
||||
};
|
||||
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
expect(value).toBe(rawValue);
|
||||
@@ -153,12 +154,12 @@ describe('ShareDataTableAdapter', () => {
|
||||
it('should generate fallback icon for a file thumbnail with missing mime type', () => {
|
||||
spyOn(documentListService, 'getDefaultMimeTypeIcon').and.returnValue(`assets/images/ft_ic_miscellaneous.svg`);
|
||||
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let file = new FileNode();
|
||||
file.entry.content.mimeType = null;
|
||||
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
@@ -169,12 +170,12 @@ describe('ShareDataTableAdapter', () => {
|
||||
it('should generate fallback icon for a file with no content entry', () => {
|
||||
spyOn(documentListService, 'getDefaultMimeTypeIcon').and.returnValue(`assets/images/ft_ic_miscellaneous.svg`);
|
||||
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let file = new FileNode();
|
||||
file.entry.content = null;
|
||||
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
@@ -188,8 +189,8 @@ describe('ShareDataTableAdapter', () => {
|
||||
let file = new FileNode();
|
||||
file.entry['icon'] = imageUrl;
|
||||
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
let col = <DataColumn> { type: 'image', key: 'icon' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
@@ -199,9 +200,9 @@ describe('ShareDataTableAdapter', () => {
|
||||
it('should resolve folder icon', () => {
|
||||
spyOn(documentListService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_folder.svg`);
|
||||
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let row = new ShareDataRow(new FolderNode(), documentListService, null);
|
||||
let row = new ShareDataRow(new FolderNode(), contentService, null);
|
||||
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
@@ -212,9 +213,9 @@ describe('ShareDataTableAdapter', () => {
|
||||
it('should resolve smart folder icon', () => {
|
||||
spyOn(documentListService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_smart_folder.svg`);
|
||||
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let row = new ShareDataRow(new SmartFolderNode(), documentListService, null);
|
||||
let row = new ShareDataRow(new SmartFolderNode(), contentService, null);
|
||||
let col = <DataColumn> { type: 'folder', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
@@ -225,9 +226,9 @@ describe('ShareDataTableAdapter', () => {
|
||||
it('should resolve link folder icon', () => {
|
||||
spyOn(documentListService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_folder_shortcut_link.svg`);
|
||||
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let row = new ShareDataRow(new LinkFolderNode(), documentListService, null);
|
||||
let row = new ShareDataRow(new LinkFolderNode(), contentService, null);
|
||||
let col = <DataColumn> { type: 'folder', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
@@ -238,9 +239,9 @@ describe('ShareDataTableAdapter', () => {
|
||||
it('should resolve rule folder icon', () => {
|
||||
spyOn(documentListService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_folder_rule.svg`);
|
||||
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let row = new ShareDataRow(new RuleFolderNode(), documentListService, null);
|
||||
let row = new ShareDataRow(new RuleFolderNode(), contentService, null);
|
||||
let col = <DataColumn> { type: 'folder', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
@@ -250,11 +251,11 @@ describe('ShareDataTableAdapter', () => {
|
||||
|
||||
it('should resolve file thumbnail', () => {
|
||||
let imageUrl = 'http://<addresss>';
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
adapter.thumbnails = true;
|
||||
|
||||
let file = new FileNode();
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
@@ -265,14 +266,14 @@ describe('ShareDataTableAdapter', () => {
|
||||
it('should resolve fallback file icon for unknown node', () => {
|
||||
spyOn(documentListService, 'getDefaultMimeTypeIcon').and.returnValue(`assets/images/ft_ic_miscellaneous.svg`);
|
||||
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let file = new FileNode();
|
||||
file.entry.isFile = false;
|
||||
file.entry.isFolder = false;
|
||||
file.entry.content = null;
|
||||
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
@@ -282,14 +283,14 @@ describe('ShareDataTableAdapter', () => {
|
||||
|
||||
it('should resolve file icon for content type', () => {
|
||||
spyOn(documentListService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_raster_image.svg`);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
||||
|
||||
let file = new FileNode();
|
||||
file.entry.isFile = false;
|
||||
file.entry.isFolder = false;
|
||||
file.entry.content.mimeType = 'image/png';
|
||||
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
@@ -303,13 +304,13 @@ describe('ShareDataTableAdapter', () => {
|
||||
let folder = new FolderNode();
|
||||
|
||||
let col = <DataColumn> { key: 'name' };
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, [col]);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, [col]);
|
||||
adapter.setSorting(new DataSorting('name', 'asc'));
|
||||
|
||||
adapter.setRows([
|
||||
new ShareDataRow(file2, documentListService, null),
|
||||
new ShareDataRow(file1, documentListService, null),
|
||||
new ShareDataRow(folder, documentListService, null)
|
||||
new ShareDataRow(file2, contentService, null),
|
||||
new ShareDataRow(file1, contentService, null),
|
||||
new ShareDataRow(folder, contentService, null)
|
||||
]);
|
||||
|
||||
let sorted = adapter.getRows();
|
||||
@@ -326,11 +327,11 @@ describe('ShareDataTableAdapter', () => {
|
||||
file2.entry['dateProp'] = new Date(2016, 6, 30, 13, 14, 2);
|
||||
|
||||
let col = <DataColumn> { key: 'dateProp' };
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, [col]);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, [col]);
|
||||
|
||||
adapter.setRows([
|
||||
new ShareDataRow(file2, documentListService, null),
|
||||
new ShareDataRow(file1, documentListService, null)
|
||||
new ShareDataRow(file2, contentService, null),
|
||||
new ShareDataRow(file1, contentService, null)
|
||||
]);
|
||||
|
||||
adapter.sort('dateProp', 'asc');
|
||||
@@ -356,13 +357,13 @@ describe('ShareDataTableAdapter', () => {
|
||||
file4.entry.content.sizeInBytes = 2852791665; // 2.66 GB
|
||||
|
||||
let col = <DataColumn> { key: 'content.sizeInBytes' };
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, [col]);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, [col]);
|
||||
|
||||
adapter.setRows([
|
||||
new ShareDataRow(file3, documentListService, null),
|
||||
new ShareDataRow(file4, documentListService, null),
|
||||
new ShareDataRow(file1, documentListService, null),
|
||||
new ShareDataRow(file2, documentListService, null)
|
||||
new ShareDataRow(file3, contentService, null),
|
||||
new ShareDataRow(file4, contentService, null),
|
||||
new ShareDataRow(file1, contentService, null),
|
||||
new ShareDataRow(file2, contentService, null)
|
||||
]);
|
||||
|
||||
adapter.sort('content.sizeInBytes', 'asc');
|
||||
@@ -389,15 +390,15 @@ describe('ShareDataTableAdapter', () => {
|
||||
let file6 = new FileNode('b');
|
||||
|
||||
let col = <DataColumn> { key: 'name' };
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, [col]);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null, contentService, [col]);
|
||||
|
||||
adapter.setRows([
|
||||
new ShareDataRow(file4, documentListService, null),
|
||||
new ShareDataRow(file6, documentListService, null),
|
||||
new ShareDataRow(file3, documentListService, null),
|
||||
new ShareDataRow(file1, documentListService, null),
|
||||
new ShareDataRow(file2, documentListService, null),
|
||||
new ShareDataRow(file5, documentListService, null)
|
||||
new ShareDataRow(file4, contentService, null),
|
||||
new ShareDataRow(file6, contentService, null),
|
||||
new ShareDataRow(file3, contentService, null),
|
||||
new ShareDataRow(file1, contentService, null),
|
||||
new ShareDataRow(file2, contentService, null),
|
||||
new ShareDataRow(file5, contentService, null)
|
||||
]);
|
||||
|
||||
adapter.sort('name', 'asc');
|
||||
@@ -423,25 +424,25 @@ describe('ShareDataTableAdapter', () => {
|
||||
|
||||
it('should wrap node', () => {
|
||||
let file = new FileNode();
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
expect(row.node).toBe(file);
|
||||
});
|
||||
|
||||
it('should require object source', () => {
|
||||
expect(() => {
|
||||
return new ShareDataRow(null, documentListService, null);
|
||||
return new ShareDataRow(null, contentService, null);
|
||||
}).toThrowError(ShareDataRow.ERR_OBJECT_NOT_FOUND);
|
||||
});
|
||||
|
||||
it('should resolve value from node entry', () => {
|
||||
let file = new FileNode('test');
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
expect(row.getValue('name')).toBe('test');
|
||||
});
|
||||
|
||||
it('should check value', () => {
|
||||
let file = new FileNode('test');
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
|
||||
expect(row.hasValue('name')).toBeTruthy();
|
||||
expect(row.hasValue('missing')).toBeFalsy();
|
||||
@@ -450,21 +451,21 @@ describe('ShareDataTableAdapter', () => {
|
||||
it('should be set as drop target when user has permission for that node', () => {
|
||||
let file = new FolderNode('test');
|
||||
file.entry['allowableOperations'] = ['create'];
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
|
||||
expect(row.isDropTarget).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should not be set as drop target when user has permission for that node', () => {
|
||||
let file = new FolderNode('test');
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
|
||||
expect(row.isDropTarget).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should not be set as drop target when element is not a Folder', () => {
|
||||
let file = new FileNode('test');
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let row = new ShareDataRow(file, contentService, null);
|
||||
|
||||
expect(row.isDropTarget).toBeFalsy();
|
||||
});
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { DataColumn, DataRow, DataSorting, DataTableAdapter, ThumbnailService } from '@alfresco/adf-core';
|
||||
import { DataColumn, DataRow, DataSorting, DataTableAdapter, ThumbnailService, ContentService } from '@alfresco/adf-core';
|
||||
import { NodePaging } from '@alfresco/js-api';
|
||||
import { PermissionStyleModel } from './../models/permissions-style.model';
|
||||
import { DocumentListService } from './../services/document-list.service';
|
||||
@@ -52,6 +52,7 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
|
||||
constructor(private documentListService: DocumentListService,
|
||||
private thumbnailService: ThumbnailService,
|
||||
private contentService: ContentService,
|
||||
schema: DataColumn[] = [],
|
||||
sorting?: DataSorting,
|
||||
sortingMode: string = 'client') {
|
||||
@@ -241,7 +242,7 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
if (page && page.list) {
|
||||
let data = page.list.entries;
|
||||
if (data && data.length > 0) {
|
||||
rows = data.map((item) => new ShareDataRow(item, this.documentListService, this.permissionsStyle, this.thumbnailService));
|
||||
rows = data.map((item) => new ShareDataRow(item, this.contentService, this.permissionsStyle, this.thumbnailService));
|
||||
|
||||
if (this.filter) {
|
||||
rows = rows.filter(this.filter);
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
AlfrescoApiService, AuthenticationService, ContentService, LogService,
|
||||
PermissionsEnum, ThumbnailService
|
||||
AlfrescoApiService, AuthenticationService, ContentService, LogService, ThumbnailService
|
||||
} from '@alfresco/adf-core';
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
@@ -179,17 +178,6 @@ export class DocumentListService {
|
||||
return this.thumbnailService.getDefaultMimeTypeIcon();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a node has the specified permission.
|
||||
* @deprecated 2.3.0 - use the equivalent in the content service
|
||||
* @param node Target node
|
||||
* @param permission Permission level to query
|
||||
* @returns True if the node has the permission, false otherwise
|
||||
*/
|
||||
hasPermission(node: any, permission: PermissionsEnum | string): boolean {
|
||||
return this.contentService.hasPermission(node, permission);
|
||||
}
|
||||
|
||||
private handleError(error: any) {
|
||||
this.logService.error(error);
|
||||
return throwError(error || 'Server error');
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
AlfrescoApiService, AuthenticationService, ContentService,
|
||||
SettingsService, LogService, ThumbnailService
|
||||
} from '@alfresco/adf-core';
|
||||
import { Observable, throwError } from 'rxjs';
|
||||
import { NodePaging, DocumentListService } from '../document-list';
|
||||
import { PageNode } from './document-library.model.mock';
|
||||
|
||||
export class DocumentListServiceMock extends DocumentListService {
|
||||
|
||||
getFolderResult: NodePaging = new PageNode();
|
||||
getFolderReject: boolean = false;
|
||||
getFolderRejectError: string = 'Error';
|
||||
|
||||
constructor(settings?: SettingsService,
|
||||
authService?: AuthenticationService,
|
||||
contentService?: ContentService,
|
||||
apiService?: AlfrescoApiService,
|
||||
logService?: LogService,
|
||||
thumbnailService?: ThumbnailService) {
|
||||
super(authService, contentService, apiService, logService, thumbnailService);
|
||||
}
|
||||
|
||||
getFolder(folder: string) {
|
||||
if (this.getFolderReject) {
|
||||
return throwError(this.getFolderRejectError);
|
||||
}
|
||||
return new Observable((observer) => {
|
||||
observer.next(this.getFolderResult);
|
||||
observer.complete();
|
||||
});
|
||||
}
|
||||
|
||||
deleteNode(nodeId: string) {
|
||||
return new Observable((observer) => {
|
||||
observer.next();
|
||||
observer.complete();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,5 @@
|
||||
|
||||
export * from './document-library.model.mock';
|
||||
export * from './document-list.component.mock';
|
||||
export * from './document-list.service.mock';
|
||||
export * from './search.component.mock';
|
||||
export * from './search.service.mock';
|
||||
|
||||
@@ -118,7 +118,7 @@ export let errorJson = {
|
||||
|
||||
@Component({
|
||||
template: `
|
||||
<adf-search [searchTerm]="searchedWord" [queryBody]="searchNode" [maxResults]="maxResults"
|
||||
<adf-search [searchTerm]="searchedWord" [maxResults]="maxResults"
|
||||
(error)="showSearchResult('ERROR')"
|
||||
(success)="showSearchResult('success')" #search>
|
||||
<ng-template let-data>
|
||||
|
||||
@@ -32,8 +32,7 @@
|
||||
<adf-search #search
|
||||
#auto="searchAutocomplete"
|
||||
class="adf-search-result-autocomplete"
|
||||
[maxResults]="liveSearchMaxResults"
|
||||
[queryBody]="customQueryBody">
|
||||
[maxResults]="liveSearchMaxResults">
|
||||
<ng-template let-data>
|
||||
<mat-list *ngIf="isSearchBarActive()" id="autocomplete-search-result-list">
|
||||
<mat-list-item
|
||||
|
||||
@@ -19,7 +19,7 @@ import { AuthenticationService, ThumbnailService } from '@alfresco/adf-core';
|
||||
import { animate, state, style, transition, trigger } from '@angular/animations';
|
||||
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output,
|
||||
QueryList, ViewEncapsulation, ViewChild, ViewChildren, ElementRef, TemplateRef, ContentChild } from '@angular/core';
|
||||
import { NodeEntry, QueryBody } from '@alfresco/js-api';
|
||||
import { NodeEntry } from '@alfresco/js-api';
|
||||
import { Observable, Subject } from 'rxjs';
|
||||
import { SearchComponent } from './search.component';
|
||||
import { MatListItem } from '@angular/material';
|
||||
@@ -72,10 +72,6 @@ export class SearchControlComponent implements OnInit, OnDestroy {
|
||||
@Input()
|
||||
liveSearchMaxResults: number = 5;
|
||||
|
||||
/** @deprecated in 2.1.0 */
|
||||
@Input()
|
||||
customQueryBody: QueryBody;
|
||||
|
||||
/** Emitted when the search is submitted by pressing the ENTER key.
|
||||
* The search term is provided as the value of the event.
|
||||
*/
|
||||
|
||||
@@ -17,22 +17,10 @@
|
||||
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { SearchService, setupTestBed, CoreModule } from '@alfresco/adf-core';
|
||||
import { QueryBody } from '@alfresco/js-api';
|
||||
import { differentResult, folderResult, result, SimpleSearchTestComponent } from '../../mock';
|
||||
import { Observable, of, throwError } from 'rxjs';
|
||||
import { differentResult, result, SimpleSearchTestComponent } from '../../mock';
|
||||
import { of, throwError } from 'rxjs';
|
||||
import { SearchModule } from '../search.module';
|
||||
|
||||
function fakeNodeResultSearch(searchNode: QueryBody): Observable<any> {
|
||||
if (searchNode && searchNode.query.query === 'FAKE_SEARCH_EXMPL') {
|
||||
return of(differentResult);
|
||||
}
|
||||
if (searchNode && searchNode.filterQueries.length === 1 &&
|
||||
searchNode.filterQueries[0].query === "TYPE:'cm:folder'") {
|
||||
return of(folderResult);
|
||||
}
|
||||
return of(result);
|
||||
}
|
||||
|
||||
describe('SearchComponent', () => {
|
||||
|
||||
let fixture: ComponentFixture<SimpleSearchTestComponent>, element: HTMLElement;
|
||||
@@ -131,30 +119,6 @@ describe('SearchComponent', () => {
|
||||
|
||||
describe('search node', () => {
|
||||
|
||||
it('should perform a search based on the query node given', (done) => {
|
||||
spyOn(searchService, 'searchByQueryBody')
|
||||
.and.callFake((searchObj) => fakeNodeResultSearch(searchObj));
|
||||
let fakeSearchNode: QueryBody = {
|
||||
query: {
|
||||
query: 'TEST-FAKE-NODE'
|
||||
},
|
||||
filterQueries: [
|
||||
{ 'query': "TYPE:'cm:folder'" }
|
||||
]
|
||||
};
|
||||
component.setSearchWordTo('searchTerm');
|
||||
component.setSearchNodeTo(fakeSearchNode);
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let optionShowed = element.querySelectorAll('#autocomplete-search-result-list > li').length;
|
||||
expect(optionShowed).toBe(1);
|
||||
let folderOption: HTMLElement = <HTMLElement> element.querySelector('#result_option_0');
|
||||
expect(folderOption.textContent.trim()).toBe('MyFolder');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should perform a search with a defaultNode if no search node is given', (done) => {
|
||||
spyOn(searchService, 'search').and.returnValue(of(result));
|
||||
component.setSearchWordTo('searchTerm');
|
||||
@@ -168,29 +132,5 @@ describe('SearchComponent', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should perform a search with the searchNode given', (done) => {
|
||||
spyOn(searchService, 'searchByQueryBody')
|
||||
.and.callFake((searchObj) => fakeNodeResultSearch(searchObj));
|
||||
let fakeSearchNode: QueryBody = {
|
||||
query: {
|
||||
query: 'FAKE_SEARCH_EXMPL'
|
||||
},
|
||||
filterQueries: [
|
||||
{ 'query': "TYPE:'cm:folder'" }
|
||||
]
|
||||
};
|
||||
component.setSearchWordTo('searchTerm');
|
||||
component.setSearchNodeTo(fakeSearchNode);
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let optionShowed = element.querySelectorAll('#autocomplete-search-result-list > li').length;
|
||||
expect(optionShowed).toBe(1);
|
||||
let folderOption: HTMLElement = <HTMLElement> element.querySelector('#result_option_0');
|
||||
expect(folderOption.textContent.trim()).toBe('TEST_DOC');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -29,7 +29,7 @@ import {
|
||||
ViewChild,
|
||||
ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import { NodePaging, QueryBody } from '@alfresco/js-api';
|
||||
import { NodePaging } from '@alfresco/js-api';
|
||||
import { Subject } from 'rxjs';
|
||||
import { debounceTime } from 'rxjs/operators';
|
||||
|
||||
@@ -64,10 +64,6 @@ export class SearchComponent implements AfterContentInit, OnChanges {
|
||||
@Input()
|
||||
skipResults: number = 0;
|
||||
|
||||
/** @deprecated in 2.1.0 */
|
||||
@Input()
|
||||
queryBody: QueryBody;
|
||||
|
||||
/** Search term to use when executing the search. Updating this value will
|
||||
* run a new search and update the results.
|
||||
*/
|
||||
@@ -129,10 +125,6 @@ export class SearchComponent implements AfterContentInit, OnChanges {
|
||||
}
|
||||
|
||||
ngOnChanges(changes) {
|
||||
if (changes.queryBody &&
|
||||
this.hasDifferentQueryBody(changes.queryBody.previousValue, changes.queryBody.currentValue)) {
|
||||
this.loadSearchResults();
|
||||
}
|
||||
if (changes.searchTerm && changes.searchTerm.currentValue) {
|
||||
this.loadSearchResults(changes.searchTerm.currentValue);
|
||||
}
|
||||
@@ -147,10 +139,6 @@ export class SearchComponent implements AfterContentInit, OnChanges {
|
||||
this.loadSearchResults(this.searchTerm);
|
||||
}
|
||||
|
||||
private hasDifferentQueryBody(previousQueryBody: QueryBody, currentQueryBody: QueryBody) {
|
||||
return JSON.stringify(previousQueryBody) !== JSON.stringify(currentQueryBody);
|
||||
}
|
||||
|
||||
private cleanResults() {
|
||||
if (this.results) {
|
||||
this.results = {};
|
||||
@@ -160,17 +148,10 @@ export class SearchComponent implements AfterContentInit, OnChanges {
|
||||
private loadSearchResults(searchTerm?: string) {
|
||||
this.resetResults();
|
||||
if (searchTerm) {
|
||||
if (this.queryBody) {
|
||||
this.searchService.searchByQueryBody(this.queryBody).subscribe(
|
||||
(result) => this.onSearchDataLoaded(result),
|
||||
(err) => this.onSearchDataError(err)
|
||||
);
|
||||
} else {
|
||||
this.searchService.search(searchTerm, this.maxResults, this.skipResults).subscribe(
|
||||
(result) => this.onSearchDataLoaded(result),
|
||||
(err) => this.onSearchDataError(err)
|
||||
);
|
||||
}
|
||||
this.searchService.search(searchTerm, this.maxResults, this.skipResults).subscribe(
|
||||
(result) => this.onSearchDataLoaded(result),
|
||||
(err) => this.onSearchDataError(err)
|
||||
);
|
||||
} else {
|
||||
this.cleanResults();
|
||||
}
|
||||
|
||||
@@ -63,13 +63,6 @@ export abstract class UploadBase implements OnInit, OnDestroy {
|
||||
@Output()
|
||||
success = new EventEmitter();
|
||||
|
||||
/**
|
||||
* Emitted when a folder is created.
|
||||
* @deprecated 2.4.0 No longer used by the framework
|
||||
*/
|
||||
@Output()
|
||||
createFolder = new EventEmitter();
|
||||
|
||||
/** Emitted when an error occurs. */
|
||||
@Output()
|
||||
error = new EventEmitter();
|
||||
|
||||
@@ -23,9 +23,8 @@ import { ChangeDetectorRef, Component, Input, Output, EventEmitter, OnDestroy, O
|
||||
import { Subscription, merge } from 'rxjs';
|
||||
import { FileUploadingListComponent } from './file-uploading-list.component';
|
||||
|
||||
// @deprecated file-uploading-dialog TODO remove in 3.0.0
|
||||
@Component({
|
||||
selector: 'adf-file-uploading-dialog, file-uploading-dialog',
|
||||
selector: 'adf-file-uploading-dialog',
|
||||
templateUrl: './file-uploading-dialog.component.html',
|
||||
styleUrls: ['./file-uploading-dialog.component.scss']
|
||||
})
|
||||
|
||||
@@ -151,18 +151,7 @@ describe('UploadDragAreaComponent', () => {
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue');
|
||||
fixture.detectChanges();
|
||||
|
||||
let itemEntity = {
|
||||
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' });
|
||||
callbackFile(fileFake);
|
||||
}
|
||||
};
|
||||
component.onFilesEntityDropped(itemEntity);
|
||||
component.onFilesDropped([new File(['fakefake'], 'file-fake.png', { type: 'image/png' })]);
|
||||
|
||||
expect(uploadService.addToQueue).not.toHaveBeenCalled();
|
||||
expect(uploadService.uploadFilesInTheQueue).not.toHaveBeenCalled();
|
||||
@@ -270,19 +259,9 @@ describe('UploadDragAreaComponent', () => {
|
||||
component.success = null;
|
||||
component.acceptedFilesType = '.png';
|
||||
fixture.detectChanges();
|
||||
let itemEntity = {
|
||||
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' });
|
||||
callbackFile(fileFake);
|
||||
}
|
||||
};
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
component.onFilesEntityDropped(itemEntity);
|
||||
component.onFilesDropped([new File(['fakefake'], 'file-fake.png', { type: 'image/png' })]);
|
||||
expect(uploadService.uploadFilesInTheQueue).toHaveBeenCalledWith(null);
|
||||
});
|
||||
}));
|
||||
@@ -293,19 +272,8 @@ describe('UploadDragAreaComponent', () => {
|
||||
fixture.detectChanges();
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue');
|
||||
|
||||
let itemEntity = {
|
||||
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' });
|
||||
callbackFile(fileFake);
|
||||
}
|
||||
};
|
||||
fixture.whenStable().then(() => {
|
||||
component.onFilesEntityDropped(itemEntity);
|
||||
component.onFilesDropped([new File(['fakefake'], 'file-fake.png', { type: 'image/png' })]);
|
||||
expect(uploadService.uploadFilesInTheQueue).not.toHaveBeenCalledWith(null);
|
||||
});
|
||||
}));
|
||||
@@ -315,18 +283,7 @@ describe('UploadDragAreaComponent', () => {
|
||||
fixture.detectChanges();
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue');
|
||||
|
||||
let itemEntity = {
|
||||
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' });
|
||||
callbackFile(fileFake);
|
||||
}
|
||||
};
|
||||
component.onFilesEntityDropped(itemEntity);
|
||||
component.onFilesDropped([new File(['fakefake'], 'file-fake.png', { type: 'image/png' })]);
|
||||
expect(uploadService.uploadFilesInTheQueue).toHaveBeenCalledWith(null);
|
||||
}));
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
EXTENDIBLE_COMPONENT, FileInfo, FileModel, FileUtils, NodePermissionSubject,
|
||||
NotificationService, TranslationService, UploadService, ContentService, PermissionsEnum
|
||||
} from '@alfresco/adf-core';
|
||||
import { Component, forwardRef, Input, ViewEncapsulation, NgZone } from '@angular/core';
|
||||
import { Component, forwardRef, ViewEncapsulation, NgZone } from '@angular/core';
|
||||
import { UploadBase } from './base-upload/upload-base';
|
||||
|
||||
@Component({
|
||||
@@ -34,15 +34,6 @@ import { UploadBase } from './base-upload/upload-base';
|
||||
})
|
||||
export class UploadDragAreaComponent extends UploadBase implements NodePermissionSubject {
|
||||
|
||||
/**
|
||||
* ID of parent folder node
|
||||
* @deprecated 2.4.0 - use rootFolderId ID of parent folder node
|
||||
*/
|
||||
@Input()
|
||||
set parentId(nodeId: string) {
|
||||
this.rootFolderId = nodeId;
|
||||
}
|
||||
|
||||
constructor(protected uploadService: UploadService,
|
||||
protected translationService: TranslationService,
|
||||
private notificationService: NotificationService,
|
||||
@@ -62,21 +53,6 @@ export class UploadDragAreaComponent extends UploadBase implements NodePermissio
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the file are dropped in the drag area.
|
||||
* @deprecated in 2.4.0: use `onFilesDropped` instead
|
||||
* @param item - FileEntity
|
||||
*/
|
||||
onFilesEntityDropped(item: any): void {
|
||||
if (!this.disabled) {
|
||||
item.file((file: File) => {
|
||||
// const fileModel = this.createFileModel(file, this.rootFolderId, item.fullPath.replace(item.name, ''));
|
||||
|
||||
this.uploadFiles([file]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a folder are dropped in the drag area
|
||||
*
|
||||
|
||||
@@ -35,13 +35,6 @@ export class FileDraggableDirective implements OnInit, OnDestroy {
|
||||
@Output()
|
||||
filesDropped: EventEmitter<File[]> = new EventEmitter<File[]>();
|
||||
|
||||
/**
|
||||
* Emitted when one or more files are dragged and dropped onto the draggable element.
|
||||
* @deprecated in 2.4.0: use `filesDropped` instead
|
||||
*/
|
||||
@Output()
|
||||
filesEntityDropped: EventEmitter<any> = new EventEmitter();
|
||||
|
||||
/** Emitted when a directory is dragged and dropped onto the draggable element. */
|
||||
@Output()
|
||||
folderEntityDropped: EventEmitter<any> = new EventEmitter();
|
||||
|
||||
@@ -36,10 +36,6 @@ export class VersionListComponent implements OnChanges {
|
||||
versions: VersionEntry[] = [];
|
||||
isLoading = true;
|
||||
|
||||
/** @deprecated in 2.3.0 */
|
||||
@Input()
|
||||
id: string;
|
||||
|
||||
/** The target node. */
|
||||
@Input()
|
||||
node: Node;
|
||||
|
||||
Reference in New Issue
Block a user