mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-06-30 18:15:11 +00:00
[ADF-3912] Improved folder retrieving for DL (#4423)
* [ADF-3912] added abstract class for document-list component to be provided * [ADF-3912] - created abstract class for document-list service * [ADF-3912] - fixing and removing the custom resource from document-list * [ADF-3912] added interface for document list service * [ADF-3912] added interface for loadFolderById for DL component * [ADF-3912] fixed missing return type * [ADF-3912] removed comment * [ADF-3912] fixed PR comments * [ADF-3912] fixed wrong import * [ADF-3912] fixed unit test failing * [ADF-3912] removed unused method * [ADF-3912] fixed lint problems
This commit is contained in:
parent
3b1c4923b2
commit
a2823eeb99
@ -20,25 +20,29 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|||||||
import { PathElementEntity } from '@alfresco/js-api';
|
import { PathElementEntity } from '@alfresco/js-api';
|
||||||
import { setupTestBed } from '@alfresco/adf-core';
|
import { setupTestBed } from '@alfresco/adf-core';
|
||||||
import { fakeNodeWithCreatePermission } from '../mock';
|
import { fakeNodeWithCreatePermission } from '../mock';
|
||||||
import { DocumentListComponent } from '../document-list';
|
import { DocumentListComponent, DocumentListService } from '../document-list';
|
||||||
import { BreadcrumbComponent } from './breadcrumb.component';
|
import { BreadcrumbComponent } from './breadcrumb.component';
|
||||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||||
|
import { of } from 'rxjs';
|
||||||
|
|
||||||
describe('Breadcrumb', () => {
|
describe('Breadcrumb', () => {
|
||||||
|
|
||||||
let component: BreadcrumbComponent;
|
let component: BreadcrumbComponent;
|
||||||
let fixture: ComponentFixture<BreadcrumbComponent>;
|
let fixture: ComponentFixture<BreadcrumbComponent>;
|
||||||
let documentList: DocumentListComponent;
|
let documentListService: DocumentListService = jasmine.createSpyObj({'loadFolderByNodeId' : of(''), 'isCustomSourceService': false});
|
||||||
|
let documentListComponent: DocumentListComponent;
|
||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [ContentTestingModule],
|
imports: [ContentTestingModule],
|
||||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||||
|
providers : [{ provide: DocumentListService, useValue: documentListService }]
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(BreadcrumbComponent);
|
fixture = TestBed.createComponent(BreadcrumbComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
documentList = TestBed.createComponent<DocumentListComponent>(DocumentListComponent).componentInstance;
|
documentListComponent = TestBed.createComponent<DocumentListComponent>(DocumentListComponent).componentInstance;
|
||||||
|
documentListService = TestBed.get(DocumentListService);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -69,17 +73,17 @@ describe('Breadcrumb', () => {
|
|||||||
component.onRoutePathClick(node, null);
|
component.onRoutePathClick(node, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update document list on click', (done) => {
|
it('should update document list on click', () => {
|
||||||
spyOn(documentList, 'loadFolderByNodeId').and.stub();
|
|
||||||
|
|
||||||
const node = <PathElementEntity> { id: '-id-', name: 'name' };
|
const node = <PathElementEntity> { id: '-id-', name: 'name' };
|
||||||
component.target = documentList;
|
component.target = documentListComponent;
|
||||||
|
|
||||||
component.onRoutePathClick(node, null);
|
component.onRoutePathClick(node, null);
|
||||||
setTimeout(() => {
|
|
||||||
expect(documentList.loadFolderByNodeId).toHaveBeenCalledWith(node.id);
|
expect(documentListService.loadFolderByNodeId).toHaveBeenCalledWith(node.id,
|
||||||
done();
|
documentListComponent.DEFAULT_PAGINATION,
|
||||||
}, 0);
|
documentListComponent.includeFields,
|
||||||
|
documentListComponent.where);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not parse the route when node not provided', () => {
|
it('should not parse the route when node not provided', () => {
|
||||||
|
@ -20,25 +20,29 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { setupTestBed } from '@alfresco/adf-core';
|
import { setupTestBed } from '@alfresco/adf-core';
|
||||||
import { fakeNodeWithCreatePermission } from '../mock';
|
import { fakeNodeWithCreatePermission } from '../mock';
|
||||||
import { DocumentListComponent } from '../document-list';
|
import { DocumentListComponent, DocumentListService } from '../document-list';
|
||||||
import { DropdownBreadcrumbComponent } from './dropdown-breadcrumb.component';
|
import { DropdownBreadcrumbComponent } from './dropdown-breadcrumb.component';
|
||||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||||
|
import { of } from 'rxjs';
|
||||||
|
|
||||||
describe('DropdownBreadcrumb', () => {
|
describe('DropdownBreadcrumb', () => {
|
||||||
|
|
||||||
let component: DropdownBreadcrumbComponent;
|
let component: DropdownBreadcrumbComponent;
|
||||||
let fixture: ComponentFixture<DropdownBreadcrumbComponent>;
|
let fixture: ComponentFixture<DropdownBreadcrumbComponent>;
|
||||||
let documentList: DocumentListComponent;
|
let documentList: DocumentListComponent;
|
||||||
|
let documentListService: DocumentListService = jasmine.createSpyObj({'loadFolderByNodeId' : of(''), 'isCustomSourceService': false});
|
||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [ContentTestingModule],
|
imports: [ContentTestingModule],
|
||||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||||
|
providers : [{ provide: DocumentListService, useValue: documentListService }]
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
fixture = TestBed.createComponent(DropdownBreadcrumbComponent);
|
fixture = TestBed.createComponent(DropdownBreadcrumbComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
documentList = TestBed.createComponent<DocumentListComponent>(DocumentListComponent).componentInstance;
|
documentList = TestBed.createComponent<DocumentListComponent>(DocumentListComponent).componentInstance;
|
||||||
|
documentListService = TestBed.get(DocumentListService);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
afterEach(async(() => {
|
afterEach(async(() => {
|
||||||
@ -151,7 +155,6 @@ describe('DropdownBreadcrumb', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should update document list when clicking on an option', (done) => {
|
it('should update document list when clicking on an option', (done) => {
|
||||||
spyOn(documentList, 'loadFolderByNodeId').and.stub();
|
|
||||||
component.target = documentList;
|
component.target = documentList;
|
||||||
const fakeNodeWithCreatePermissionInstance = JSON.parse(JSON.stringify(fakeNodeWithCreatePermission));
|
const fakeNodeWithCreatePermissionInstance = JSON.parse(JSON.stringify(fakeNodeWithCreatePermission));
|
||||||
fakeNodeWithCreatePermissionInstance.path.elements = [{ id: '1', name: 'Stark Industries' }];
|
fakeNodeWithCreatePermissionInstance.path.elements = [{ id: '1', name: 'Stark Industries' }];
|
||||||
@ -160,10 +163,9 @@ describe('DropdownBreadcrumb', () => {
|
|||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
openSelect();
|
openSelect();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
|
|
||||||
clickOnTheFirstOption();
|
clickOnTheFirstOption();
|
||||||
|
|
||||||
expect(documentList.loadFolderByNodeId).toHaveBeenCalledWith('1');
|
expect(documentListService.loadFolderByNodeId).toHaveBeenCalledWith('1', documentList.DEFAULT_PAGINATION, undefined, undefined);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import { MatDialog } from '@angular/material';
|
import { MatDialog } from '@angular/material';
|
||||||
import { EventEmitter, Injectable, Output } from '@angular/core';
|
import { EventEmitter, Injectable, Output } from '@angular/core';
|
||||||
import { ContentService } from '@alfresco/adf-core';
|
import { ContentService, ThumbnailService } from '@alfresco/adf-core';
|
||||||
import { Subject, Observable, throwError } from 'rxjs';
|
import { Subject, Observable, throwError } from 'rxjs';
|
||||||
import { ShareDataRow } from '../document-list/data/share-data-row.model';
|
import { ShareDataRow } from '../document-list/data/share-data-row.model';
|
||||||
import { Node, NodeEntry, SitePaging } from '@alfresco/js-api';
|
import { Node, NodeEntry, SitePaging } from '@alfresco/js-api';
|
||||||
@ -49,7 +49,8 @@ export class ContentNodeDialogService {
|
|||||||
private contentService: ContentService,
|
private contentService: ContentService,
|
||||||
private documentListService: DocumentListService,
|
private documentListService: DocumentListService,
|
||||||
private siteService: SitesService,
|
private siteService: SitesService,
|
||||||
private translation: TranslationService) {
|
private translation: TranslationService,
|
||||||
|
private thumbnailService: ThumbnailService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -224,7 +225,7 @@ export class ContentNodeDialogService {
|
|||||||
private imageResolver(row: ShareDataRow, col: DataColumn): string | null {
|
private imageResolver(row: ShareDataRow, col: DataColumn): string | null {
|
||||||
const entry: Node = row.node.entry;
|
const entry: Node = row.node.entry;
|
||||||
if (!this.contentService.hasAllowableOperations(entry, 'create')) {
|
if (!this.contentService.hasAllowableOperations(entry, 'create')) {
|
||||||
return this.documentListService.getMimeTypeIcon('disable/folder');
|
return this.thumbnailService.getMimeTypeIcon('disable/folder');
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -866,9 +866,9 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
it('should display folder content from loadFolderByNodeId on reload if currentFolderId defined', () => {
|
it('should display folder content from loadFolderByNodeId on reload if currentFolderId defined', () => {
|
||||||
documentList.currentFolderId = 'id-folder';
|
documentList.currentFolderId = 'id-folder';
|
||||||
spyOn(documentList, 'loadFolderByNodeId').and.stub();
|
spyOn(documentList, 'loadFolder').and.stub();
|
||||||
documentList.reload();
|
documentList.reload();
|
||||||
expect(documentList.loadFolderByNodeId).toHaveBeenCalled();
|
expect(documentList.loadFolder).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should require node to resolve context menu actions', () => {
|
it('should require node to resolve context menu actions', () => {
|
||||||
@ -1050,8 +1050,8 @@ describe('DocumentList', () => {
|
|||||||
disposableError.unsubscribe();
|
disposableError.unsubscribe();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
documentList.currentFolderId = '123';
|
||||||
documentList.loadFolderByNodeId('123');
|
documentList.loadFolder();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should emit folderChange event when a folder node is clicked', (done) => {
|
it('should emit folderChange event when a folder node is clicked', (done) => {
|
||||||
@ -1075,7 +1075,8 @@ describe('DocumentList', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
documentList.loadFolderByNodeId('123');
|
documentList.currentFolderId = '123';
|
||||||
|
documentList.loadFolder();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reset noPermission upon reload', () => {
|
it('should reset noPermission upon reload', () => {
|
||||||
@ -1135,7 +1136,8 @@ describe('DocumentList', () => {
|
|||||||
it('should fetch trashcan', () => {
|
it('should fetch trashcan', () => {
|
||||||
spyOn(apiService.nodesApi, 'getDeletedNodes').and.returnValue(Promise.resolve(null));
|
spyOn(apiService.nodesApi, 'getDeletedNodes').and.returnValue(Promise.resolve(null));
|
||||||
|
|
||||||
documentList.loadFolderByNodeId('-trashcan-');
|
documentList.currentFolderId = '-trashcan-';
|
||||||
|
documentList.loadFolder();
|
||||||
expect(apiService.nodesApi.getDeletedNodes).toHaveBeenCalled();
|
expect(apiService.nodesApi.getDeletedNodes).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1148,14 +1150,16 @@ describe('DocumentList', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
documentList.loadFolderByNodeId('-trashcan-');
|
documentList.currentFolderId = '-trashcan-';
|
||||||
|
documentList.loadFolder();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fetch shared links', () => {
|
it('should fetch shared links', () => {
|
||||||
const sharedlinksApi = apiService.getInstance().core.sharedlinksApi;
|
const sharedlinksApi = apiService.getInstance().core.sharedlinksApi;
|
||||||
spyOn(sharedlinksApi, 'findSharedLinks').and.returnValue(Promise.resolve(null));
|
spyOn(sharedlinksApi, 'findSharedLinks').and.returnValue(Promise.resolve(null));
|
||||||
|
|
||||||
documentList.loadFolderByNodeId('-sharedlinks-');
|
documentList.currentFolderId = '-sharedlinks-';
|
||||||
|
documentList.loadFolder();
|
||||||
expect(sharedlinksApi.findSharedLinks).toHaveBeenCalled();
|
expect(sharedlinksApi.findSharedLinks).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1169,13 +1173,15 @@ describe('DocumentList', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
documentList.loadFolderByNodeId('-sharedlinks-');
|
documentList.currentFolderId = '-sharedlinks-';
|
||||||
|
documentList.loadFolder();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fetch sites', () => {
|
it('should fetch sites', () => {
|
||||||
const sitesApi = apiService.getInstance().core.sitesApi;
|
const sitesApi = apiService.getInstance().core.sitesApi;
|
||||||
|
|
||||||
documentList.loadFolderByNodeId('-sites-');
|
documentList.currentFolderId = '-sites-';
|
||||||
|
documentList.loadFolder();
|
||||||
expect(sitesApi.getSites).toHaveBeenCalled();
|
expect(sitesApi.getSites).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1188,7 +1194,8 @@ describe('DocumentList', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
documentList.loadFolderByNodeId('-sites-');
|
documentList.currentFolderId = '-sites-';
|
||||||
|
documentList.loadFolder();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should assure that sites have name property set', (done) => {
|
it('should assure that sites have name property set', (done) => {
|
||||||
@ -1201,7 +1208,8 @@ describe('DocumentList', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
documentList.loadFolderByNodeId('-sites-');
|
documentList.currentFolderId = '-sites-';
|
||||||
|
documentList.loadFolder();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should assure that sites have name property set correctly', (done) => {
|
it('should assure that sites have name property set correctly', (done) => {
|
||||||
@ -1214,14 +1222,16 @@ describe('DocumentList', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
documentList.loadFolderByNodeId('-sites-');
|
documentList.currentFolderId = '-sites-';
|
||||||
|
documentList.loadFolder();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fetch user membership sites', () => {
|
it('should fetch user membership sites', () => {
|
||||||
const peopleApi = apiService.getInstance().core.peopleApi;
|
const peopleApi = apiService.getInstance().core.peopleApi;
|
||||||
spyOn(peopleApi, 'listSiteMembershipsForPerson').and.returnValue(Promise.resolve(fakeGetSiteMembership));
|
spyOn(peopleApi, 'listSiteMembershipsForPerson').and.returnValue(Promise.resolve(fakeGetSiteMembership));
|
||||||
|
|
||||||
documentList.loadFolderByNodeId('-mysites-');
|
documentList.currentFolderId = '-mysites-';
|
||||||
|
documentList.loadFolder();
|
||||||
expect(peopleApi.listSiteMembershipsForPerson).toHaveBeenCalled();
|
expect(peopleApi.listSiteMembershipsForPerson).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1235,7 +1245,8 @@ describe('DocumentList', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
documentList.loadFolderByNodeId('-mysites-');
|
documentList.currentFolderId = '-mysites-';
|
||||||
|
documentList.loadFolder();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should assure that user membership sites have name property set', (done) => {
|
it('should assure that user membership sites have name property set', (done) => {
|
||||||
@ -1243,7 +1254,8 @@ describe('DocumentList', () => {
|
|||||||
const peopleApi = apiService.getInstance().core.peopleApi;
|
const peopleApi = apiService.getInstance().core.peopleApi;
|
||||||
spyOn(peopleApi, 'listSiteMembershipsForPerson').and.returnValue(Promise.resolve(fakeGetSiteMembership));
|
spyOn(peopleApi, 'listSiteMembershipsForPerson').and.returnValue(Promise.resolve(fakeGetSiteMembership));
|
||||||
|
|
||||||
documentList.loadFolderByNodeId('-mysites-');
|
documentList.currentFolderId = '-mysites-';
|
||||||
|
documentList.loadFolder();
|
||||||
expect(peopleApi.listSiteMembershipsForPerson).toHaveBeenCalled();
|
expect(peopleApi.listSiteMembershipsForPerson).toHaveBeenCalled();
|
||||||
|
|
||||||
const disposableReady = documentList.ready.subscribe((page) => {
|
const disposableReady = documentList.ready.subscribe((page) => {
|
||||||
@ -1259,7 +1271,8 @@ describe('DocumentList', () => {
|
|||||||
const peopleApi = apiService.getInstance().core.peopleApi;
|
const peopleApi = apiService.getInstance().core.peopleApi;
|
||||||
spyOn(peopleApi, 'listSiteMembershipsForPerson').and.returnValue(Promise.resolve(fakeGetSiteMembership));
|
spyOn(peopleApi, 'listSiteMembershipsForPerson').and.returnValue(Promise.resolve(fakeGetSiteMembership));
|
||||||
|
|
||||||
documentList.loadFolderByNodeId('-mysites-');
|
documentList.currentFolderId = '-mysites-';
|
||||||
|
documentList.loadFolder();
|
||||||
expect(peopleApi.listSiteMembershipsForPerson).toHaveBeenCalled();
|
expect(peopleApi.listSiteMembershipsForPerson).toHaveBeenCalled();
|
||||||
|
|
||||||
const disposableReady = documentList.ready.subscribe((page) => {
|
const disposableReady = documentList.ready.subscribe((page) => {
|
||||||
@ -1274,7 +1287,8 @@ describe('DocumentList', () => {
|
|||||||
const favoritesApi = apiService.getInstance().core.favoritesApi;
|
const favoritesApi = apiService.getInstance().core.favoritesApi;
|
||||||
spyFavorite.and.returnValue(Promise.resolve(null));
|
spyFavorite.and.returnValue(Promise.resolve(null));
|
||||||
|
|
||||||
documentList.loadFolderByNodeId('-favorites-');
|
documentList.currentFolderId = '-favorites-';
|
||||||
|
documentList.loadFolder();
|
||||||
expect(favoritesApi.getFavorites).toHaveBeenCalled();
|
expect(favoritesApi.getFavorites).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1287,7 +1301,8 @@ describe('DocumentList', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
documentList.loadFolderByNodeId('-favorites-');
|
documentList.currentFolderId = '-favorites-';
|
||||||
|
documentList.loadFolder();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fetch recent', () => {
|
it('should fetch recent', () => {
|
||||||
@ -1295,7 +1310,8 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
const getPersonSpy = spyOn(apiService.peopleApi, 'getPerson').and.returnValue(Promise.resolve(person));
|
const getPersonSpy = spyOn(apiService.peopleApi, 'getPerson').and.returnValue(Promise.resolve(person));
|
||||||
|
|
||||||
documentList.loadFolderByNodeId('-recent-');
|
documentList.currentFolderId = '-recent-';
|
||||||
|
documentList.loadFolder();
|
||||||
|
|
||||||
expect(getPersonSpy).toHaveBeenCalledWith('-me-');
|
expect(getPersonSpy).toHaveBeenCalledWith('-me-');
|
||||||
});
|
});
|
||||||
@ -1309,7 +1325,8 @@ describe('DocumentList', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
documentList.loadFolderByNodeId('-recent-');
|
documentList.currentFolderId = '-recent-';
|
||||||
|
documentList.loadFolder();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should emit error when fetch recent fails on search call', (done) => {
|
it('should emit error when fetch recent fails on search call', (done) => {
|
||||||
@ -1321,7 +1338,8 @@ describe('DocumentList', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
documentList.loadFolderByNodeId('-recent-');
|
documentList.currentFolderId = '-recent-';
|
||||||
|
documentList.loadFolder();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have correct currentFolderId on loading folder by node id', () => {
|
it('should have correct currentFolderId on loading folder by node id', () => {
|
||||||
@ -1330,7 +1348,8 @@ describe('DocumentList', () => {
|
|||||||
const peopleApi = apiService.getInstance().core.peopleApi;
|
const peopleApi = apiService.getInstance().core.peopleApi;
|
||||||
spyOn(peopleApi, 'listSiteMembershipsForPerson').and.returnValue(Promise.resolve(fakeGetSiteMembership));
|
spyOn(peopleApi, 'listSiteMembershipsForPerson').and.returnValue(Promise.resolve(fakeGetSiteMembership));
|
||||||
|
|
||||||
documentList.loadFolderByNodeId('-mysites-');
|
documentList.currentFolderId = '-mysites-';
|
||||||
|
documentList.loadFolder();
|
||||||
expect(documentList.currentFolderId).toBe('-mysites-');
|
expect(documentList.currentFolderId).toBe('-mysites-');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -53,12 +53,11 @@ import { ShareDataTableAdapter } from './../data/share-datatable-adapter';
|
|||||||
import { presetsDefaultModel } from '../models/preset.model';
|
import { presetsDefaultModel } from '../models/preset.model';
|
||||||
import { ContentActionModel } from './../models/content-action.model';
|
import { ContentActionModel } from './../models/content-action.model';
|
||||||
import { PermissionStyleModel } from './../models/permissions-style.model';
|
import { PermissionStyleModel } from './../models/permissions-style.model';
|
||||||
import { DocumentListService } from './../services/document-list.service';
|
|
||||||
import { NodeEntityEvent, NodeEntryEvent } from './node.event';
|
import { NodeEntityEvent, NodeEntryEvent } from './node.event';
|
||||||
import { CustomResourcesService } from './../services/custom-resources.service';
|
|
||||||
import { NavigableComponentInterface } from '../../breadcrumb/navigable-component.interface';
|
import { NavigableComponentInterface } from '../../breadcrumb/navigable-component.interface';
|
||||||
import { RowFilter } from '../data/row-filter.model';
|
import { RowFilter } from '../data/row-filter.model';
|
||||||
import { Observable } from 'rxjs/index';
|
import { DocumentListService } from '../services/document-list.service';
|
||||||
|
import { DocumentLoaderNode } from '../models/document-folder.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-document-list',
|
selector: 'adf-document-list',
|
||||||
@ -323,7 +322,6 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
private elementRef: ElementRef,
|
private elementRef: ElementRef,
|
||||||
private appConfig: AppConfigService,
|
private appConfig: AppConfigService,
|
||||||
private userPreferencesService: UserPreferencesService,
|
private userPreferencesService: UserPreferencesService,
|
||||||
private customResourcesService: CustomResourcesService,
|
|
||||||
private contentService: ContentService,
|
private contentService: ContentService,
|
||||||
private thumbnailService: ThumbnailService,
|
private thumbnailService: ThumbnailService,
|
||||||
private alfrescoApiService: AlfrescoApiService,
|
private alfrescoApiService: AlfrescoApiService,
|
||||||
@ -378,7 +376,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.rowMenuCache = {};
|
this.rowMenuCache = {};
|
||||||
this.loadLayoutPresets();
|
this.loadLayoutPresets();
|
||||||
this.data = new ShareDataTableAdapter(this.documentListService, this.thumbnailService, this.contentService, null, this.getDefaultSorting(), this.sortingMode);
|
this.data = new ShareDataTableAdapter(this.thumbnailService, this.contentService, null, this.getDefaultSorting(), this.sortingMode);
|
||||||
this.data.thumbnails = this.thumbnails;
|
this.data.thumbnails = this.thumbnails;
|
||||||
this.data.permissionsStyle = this.permissionsStyle;
|
this.data.permissionsStyle = this.permissionsStyle;
|
||||||
|
|
||||||
@ -416,7 +414,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this.data) {
|
if (!this.data) {
|
||||||
this.data = new ShareDataTableAdapter(this.documentListService, this.thumbnailService, this.contentService, schema, this.getDefaultSorting(), this.sortingMode);
|
this.data = new ShareDataTableAdapter(this.thumbnailService, this.contentService, schema, this.getDefaultSorting(), this.sortingMode);
|
||||||
} else if (schema && schema.length > 0) {
|
} else if (schema && schema.length > 0) {
|
||||||
this.data.setColumns(schema);
|
this.data.setColumns(schema);
|
||||||
}
|
}
|
||||||
@ -627,45 +625,20 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
this.setupDefaultColumns(this._currentFolderId);
|
this.setupDefaultColumns(this._currentFolderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loadFolderByNodeId(this._currentFolderId);
|
if (this.documentListService.isCustomSourceService(this._currentFolderId)) {
|
||||||
}
|
this.updateCustomSourceData(this._currentFolderId);
|
||||||
|
|
||||||
loadFolderByNodeId(nodeId: string) {
|
|
||||||
if (this.customResourcesService.isCustomSource(nodeId)) {
|
|
||||||
this.updateCustomSourceData(nodeId);
|
|
||||||
this.customResourcesService.loadFolderByNodeId(nodeId, this._pagination, this.includeFields)
|
|
||||||
.subscribe((nodePaging: NodePaging) => {
|
|
||||||
this.onPageLoaded(nodePaging);
|
|
||||||
}, (err) => {
|
|
||||||
this.error.emit(err);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
|
|
||||||
this.documentListService.getFolder(null, {
|
|
||||||
maxItems: this._pagination.maxItems,
|
|
||||||
skipCount: this._pagination.skipCount,
|
|
||||||
rootFolderId: nodeId,
|
|
||||||
where: this.where
|
|
||||||
}, this.includeFields)
|
|
||||||
.subscribe((nodePaging: NodePaging) => {
|
|
||||||
this.getSourceNodeWithPath(nodeId).subscribe((nodeEntry: NodeEntry) => {
|
|
||||||
this.onPageLoaded(nodePaging);
|
|
||||||
});
|
|
||||||
}, (err) => {
|
|
||||||
this.handleError(err);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
getSourceNodeWithPath(nodeId: string): Observable<NodeEntry> {
|
this.documentListService.loadFolderByNodeId(this._currentFolderId, this._pagination, this.includeFields, this.where)
|
||||||
const getSourceObservable = this.documentListService.getFolderNode(nodeId, this.includeFields);
|
.subscribe((documentNode: DocumentLoaderNode) => {
|
||||||
|
if (documentNode.currentNode) {
|
||||||
getSourceObservable.subscribe((nodeEntry: NodeEntry) => {
|
this.folderNode = documentNode.currentNode.entry;
|
||||||
this.folderNode = nodeEntry.entry;
|
this.$folderNode.next(documentNode.currentNode.entry);
|
||||||
this.$folderNode.next(this.folderNode);
|
}
|
||||||
});
|
this.onPageLoaded(documentNode.children);
|
||||||
|
}, (err) => {
|
||||||
return getSourceObservable;
|
this.handleError(err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
resetSelection() {
|
resetSelection() {
|
||||||
|
@ -15,31 +15,64 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { DataColumn, DataRow, DataSorting, ContentService } from '@alfresco/adf-core';
|
import { DataColumn, DataRow, DataSorting, ContentService, ThumbnailService } from '@alfresco/adf-core';
|
||||||
import { FileNode, FolderNode, SmartFolderNode, RuleFolderNode, LinkFolderNode } from './../../mock';
|
import { FileNode, FolderNode, SmartFolderNode, RuleFolderNode, LinkFolderNode } from './../../mock';
|
||||||
import { DocumentListService } from './../services/document-list.service';
|
|
||||||
import { ShareDataRow } from './share-data-row.model';
|
import { ShareDataRow } from './share-data-row.model';
|
||||||
import { ShareDataTableAdapter } from './share-datatable-adapter';
|
import { ShareDataTableAdapter } from './share-datatable-adapter';
|
||||||
|
import { DomSanitizer } from '@angular/platform-browser';
|
||||||
|
import { MatIconRegistry } from '@angular/material';
|
||||||
|
|
||||||
|
class FakeSanitizer extends DomSanitizer {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
sanitize(html) {
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
|
bypassSecurityTrustHtml(value: string): any {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
bypassSecurityTrustStyle(value: string): any {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
bypassSecurityTrustScript(value: string): any {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
bypassSecurityTrustUrl(value: string): any {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
bypassSecurityTrustResourceUrl(value: string): any {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
describe('ShareDataTableAdapter', () => {
|
describe('ShareDataTableAdapter', () => {
|
||||||
|
|
||||||
let documentListService: DocumentListService;
|
let thumbnailService: ThumbnailService;
|
||||||
let contentService: ContentService;
|
let contentService: ContentService;
|
||||||
|
const fakeMatIconRegistry: MatIconRegistry = jasmine.createSpyObj(['addSvgIcon', 'addSvgIconInNamespace']);
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const imageUrl: string = 'http://<addresss>';
|
const imageUrl: string = 'http://<addresss>';
|
||||||
contentService = new ContentService(null, null, null, null);
|
contentService = new ContentService(null, null, null, null);
|
||||||
documentListService = new DocumentListService(null, contentService, null, null, null);
|
thumbnailService = new ThumbnailService(contentService, fakeMatIconRegistry, new FakeSanitizer());
|
||||||
spyOn(documentListService, 'getDocumentThumbnailUrl').and.returnValue(imageUrl);
|
spyOn(thumbnailService, 'getDocumentThumbnailUrl').and.returnValue(imageUrl);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use client sorting by default', () => {
|
it('should use client sorting by default', () => {
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, []);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, []);
|
||||||
expect(adapter.sortingMode).toBe('client');
|
expect(adapter.sortingMode).toBe('client');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not be case sensitive for sorting mode value', () => {
|
it('should not be case sensitive for sorting mode value', () => {
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, []);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, []);
|
||||||
|
|
||||||
adapter.sortingMode = 'CLIENT';
|
adapter.sortingMode = 'CLIENT';
|
||||||
expect(adapter.sortingMode).toBe('client');
|
expect(adapter.sortingMode).toBe('client');
|
||||||
@ -49,7 +82,7 @@ describe('ShareDataTableAdapter', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should fallback to client sorting for unknown values', () => {
|
it('should fallback to client sorting for unknown values', () => {
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, []);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, []);
|
||||||
|
|
||||||
adapter.sortingMode = 'SeRvEr';
|
adapter.sortingMode = 'SeRvEr';
|
||||||
expect(adapter.sortingMode).toBe('server');
|
expect(adapter.sortingMode).toBe('server');
|
||||||
@ -60,27 +93,27 @@ describe('ShareDataTableAdapter', () => {
|
|||||||
|
|
||||||
it('should setup rows and columns with constructor', () => {
|
it('should setup rows and columns with constructor', () => {
|
||||||
const schema = [<DataColumn> {}];
|
const schema = [<DataColumn> {}];
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, schema);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, schema);
|
||||||
|
|
||||||
expect(adapter.getRows()).toEqual([]);
|
expect(adapter.getRows()).toEqual([]);
|
||||||
expect(adapter.getColumns()).toEqual(schema);
|
expect(adapter.getColumns()).toEqual(schema);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should setup columns when constructor is missing schema', () => {
|
it('should setup columns when constructor is missing schema', () => {
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null);
|
||||||
expect(adapter.getColumns()).toEqual([]);
|
expect(adapter.getColumns()).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set new columns', () => {
|
it('should set new columns', () => {
|
||||||
const columns = [<DataColumn> {}, <DataColumn> {}];
|
const columns = [<DataColumn> {}, <DataColumn> {}];
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null);
|
||||||
adapter.setColumns(columns);
|
adapter.setColumns(columns);
|
||||||
expect(adapter.getColumns()).toEqual(columns);
|
expect(adapter.getColumns()).toEqual(columns);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reset columns', () => {
|
it('should reset columns', () => {
|
||||||
const columns = [<DataColumn> {}, <DataColumn> {}];
|
const columns = [<DataColumn> {}, <DataColumn> {}];
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, columns);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, columns);
|
||||||
|
|
||||||
expect(adapter.getColumns()).toEqual(columns);
|
expect(adapter.getColumns()).toEqual(columns);
|
||||||
adapter.setColumns(null);
|
adapter.setColumns(null);
|
||||||
@ -89,7 +122,7 @@ describe('ShareDataTableAdapter', () => {
|
|||||||
|
|
||||||
it('should set new rows', () => {
|
it('should set new rows', () => {
|
||||||
const rows = [<DataRow> {}, <DataRow> {}];
|
const rows = [<DataRow> {}, <DataRow> {}];
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null);
|
||||||
|
|
||||||
expect(adapter.getRows()).toEqual([]);
|
expect(adapter.getRows()).toEqual([]);
|
||||||
adapter.setRows(rows);
|
adapter.setRows(rows);
|
||||||
@ -98,7 +131,7 @@ describe('ShareDataTableAdapter', () => {
|
|||||||
|
|
||||||
it('should reset rows', () => {
|
it('should reset rows', () => {
|
||||||
const rows = [<DataRow> {}, <DataRow> {}];
|
const rows = [<DataRow> {}, <DataRow> {}];
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null);
|
||||||
|
|
||||||
adapter.setRows(rows);
|
adapter.setRows(rows);
|
||||||
expect(adapter.getRows()).toEqual(rows);
|
expect(adapter.getRows()).toEqual(rows);
|
||||||
@ -108,7 +141,7 @@ describe('ShareDataTableAdapter', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should sort new rows', () => {
|
it('should sort new rows', () => {
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null);
|
||||||
spyOn(adapter, 'sort').and.callThrough();
|
spyOn(adapter, 'sort').and.callThrough();
|
||||||
|
|
||||||
const rows = [<DataRow> {}];
|
const rows = [<DataRow> {}];
|
||||||
@ -118,7 +151,7 @@ describe('ShareDataTableAdapter', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should fail when getting value for missing row', () => {
|
it('should fail when getting value for missing row', () => {
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null);
|
||||||
const check = () => {
|
const check = () => {
|
||||||
return adapter.getValue(null, <DataColumn> {});
|
return adapter.getValue(null, <DataColumn> {});
|
||||||
};
|
};
|
||||||
@ -126,7 +159,7 @@ describe('ShareDataTableAdapter', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should fail when getting value for missing column', () => {
|
it('should fail when getting value for missing column', () => {
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null);
|
||||||
const check = () => {
|
const check = () => {
|
||||||
return adapter.getValue(<DataRow> {}, null);
|
return adapter.getValue(<DataRow> {}, null);
|
||||||
};
|
};
|
||||||
@ -145,16 +178,16 @@ describe('ShareDataTableAdapter', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const row = new ShareDataRow(file, contentService, null);
|
const row = new ShareDataRow(file, contentService, null);
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null);
|
||||||
|
|
||||||
const value = adapter.getValue(row, col);
|
const value = adapter.getValue(row, col);
|
||||||
expect(value).toBe(rawValue);
|
expect(value).toBe(rawValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should generate fallback icon for a file thumbnail with missing mime type', () => {
|
it('should generate fallback icon for a file thumbnail with missing mime type', () => {
|
||||||
spyOn(documentListService, 'getDefaultMimeTypeIcon').and.returnValue(`assets/images/ft_ic_miscellaneous.svg`);
|
spyOn(thumbnailService, 'getDefaultMimeTypeIcon').and.returnValue(`assets/images/ft_ic_miscellaneous.svg`);
|
||||||
|
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null);
|
||||||
|
|
||||||
const file = new FileNode();
|
const file = new FileNode();
|
||||||
file.entry.content.mimeType = null;
|
file.entry.content.mimeType = null;
|
||||||
@ -168,9 +201,9 @@ describe('ShareDataTableAdapter', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should generate fallback icon for a file with no content entry', () => {
|
it('should generate fallback icon for a file with no content entry', () => {
|
||||||
spyOn(documentListService, 'getDefaultMimeTypeIcon').and.returnValue(`assets/images/ft_ic_miscellaneous.svg`);
|
spyOn(thumbnailService, 'getDefaultMimeTypeIcon').and.returnValue(`assets/images/ft_ic_miscellaneous.svg`);
|
||||||
|
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null);
|
||||||
|
|
||||||
const file = new FileNode();
|
const file = new FileNode();
|
||||||
file.entry.content = null;
|
file.entry.content = null;
|
||||||
@ -189,7 +222,7 @@ describe('ShareDataTableAdapter', () => {
|
|||||||
const file = new FileNode();
|
const file = new FileNode();
|
||||||
file.entry['icon'] = imageUrl;
|
file.entry['icon'] = imageUrl;
|
||||||
|
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null);
|
||||||
const row = new ShareDataRow(file, contentService, null);
|
const row = new ShareDataRow(file, contentService, null);
|
||||||
const col = <DataColumn> { type: 'image', key: 'icon' };
|
const col = <DataColumn> { type: 'image', key: 'icon' };
|
||||||
|
|
||||||
@ -198,9 +231,9 @@ describe('ShareDataTableAdapter', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should resolve folder icon', () => {
|
it('should resolve folder icon', () => {
|
||||||
spyOn(documentListService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_folder.svg`);
|
spyOn(thumbnailService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_folder.svg`);
|
||||||
|
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null);
|
||||||
|
|
||||||
const row = new ShareDataRow(new FolderNode(), contentService, null);
|
const row = new ShareDataRow(new FolderNode(), contentService, null);
|
||||||
const col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
const col = <DataColumn> { type: 'image', key: '$thumbnail' };
|
||||||
@ -211,9 +244,9 @@ describe('ShareDataTableAdapter', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should resolve smart folder icon', () => {
|
it('should resolve smart folder icon', () => {
|
||||||
spyOn(documentListService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_smart_folder.svg`);
|
spyOn(thumbnailService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_smart_folder.svg`);
|
||||||
|
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null);
|
||||||
|
|
||||||
const row = new ShareDataRow(new SmartFolderNode(), contentService, null);
|
const row = new ShareDataRow(new SmartFolderNode(), contentService, null);
|
||||||
const col = <DataColumn> { type: 'folder', key: '$thumbnail' };
|
const col = <DataColumn> { type: 'folder', key: '$thumbnail' };
|
||||||
@ -224,9 +257,9 @@ describe('ShareDataTableAdapter', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should resolve link folder icon', () => {
|
it('should resolve link folder icon', () => {
|
||||||
spyOn(documentListService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_folder_shortcut_link.svg`);
|
spyOn(thumbnailService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_folder_shortcut_link.svg`);
|
||||||
|
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null);
|
||||||
|
|
||||||
const row = new ShareDataRow(new LinkFolderNode(), contentService, null);
|
const row = new ShareDataRow(new LinkFolderNode(), contentService, null);
|
||||||
const col = <DataColumn> { type: 'folder', key: '$thumbnail' };
|
const col = <DataColumn> { type: 'folder', key: '$thumbnail' };
|
||||||
@ -237,9 +270,9 @@ describe('ShareDataTableAdapter', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should resolve rule folder icon', () => {
|
it('should resolve rule folder icon', () => {
|
||||||
spyOn(documentListService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_folder_rule.svg`);
|
spyOn(thumbnailService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_folder_rule.svg`);
|
||||||
|
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null);
|
||||||
|
|
||||||
const row = new ShareDataRow(new RuleFolderNode(), contentService, null);
|
const row = new ShareDataRow(new RuleFolderNode(), contentService, null);
|
||||||
const col = <DataColumn> { type: 'folder', key: '$thumbnail' };
|
const col = <DataColumn> { type: 'folder', key: '$thumbnail' };
|
||||||
@ -251,7 +284,7 @@ describe('ShareDataTableAdapter', () => {
|
|||||||
|
|
||||||
it('should resolve file thumbnail', () => {
|
it('should resolve file thumbnail', () => {
|
||||||
const imageUrl = 'http://<addresss>';
|
const imageUrl = 'http://<addresss>';
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null);
|
||||||
adapter.thumbnails = true;
|
adapter.thumbnails = true;
|
||||||
|
|
||||||
const file = new FileNode();
|
const file = new FileNode();
|
||||||
@ -260,13 +293,13 @@ describe('ShareDataTableAdapter', () => {
|
|||||||
|
|
||||||
const value = adapter.getValue(row, col);
|
const value = adapter.getValue(row, col);
|
||||||
expect(value).toBe(imageUrl);
|
expect(value).toBe(imageUrl);
|
||||||
expect(documentListService.getDocumentThumbnailUrl).toHaveBeenCalledWith(file);
|
expect(thumbnailService.getDocumentThumbnailUrl).toHaveBeenCalledWith(file);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should resolve fallback file icon for unknown node', () => {
|
it('should resolve fallback file icon for unknown node', () => {
|
||||||
spyOn(documentListService, 'getDefaultMimeTypeIcon').and.returnValue(`assets/images/ft_ic_miscellaneous.svg`);
|
spyOn(thumbnailService, 'getDefaultMimeTypeIcon').and.returnValue(`assets/images/ft_ic_miscellaneous.svg`);
|
||||||
|
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null);
|
||||||
|
|
||||||
const file = new FileNode();
|
const file = new FileNode();
|
||||||
file.entry.isFile = false;
|
file.entry.isFile = false;
|
||||||
@ -282,8 +315,8 @@ describe('ShareDataTableAdapter', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should resolve file icon for content type', () => {
|
it('should resolve file icon for content type', () => {
|
||||||
spyOn(documentListService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_raster_image.svg`);
|
spyOn(thumbnailService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_raster_image.svg`);
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, null);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null);
|
||||||
|
|
||||||
const file = new FileNode();
|
const file = new FileNode();
|
||||||
file.entry.isFile = false;
|
file.entry.isFile = false;
|
||||||
@ -304,7 +337,7 @@ describe('ShareDataTableAdapter', () => {
|
|||||||
const folder = new FolderNode();
|
const folder = new FolderNode();
|
||||||
|
|
||||||
const col = <DataColumn> { key: 'name' };
|
const col = <DataColumn> { key: 'name' };
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, [col]);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, [col]);
|
||||||
adapter.setSorting(new DataSorting('name', 'asc'));
|
adapter.setSorting(new DataSorting('name', 'asc'));
|
||||||
|
|
||||||
adapter.setRows([
|
adapter.setRows([
|
||||||
@ -327,7 +360,7 @@ describe('ShareDataTableAdapter', () => {
|
|||||||
file2.entry['dateProp'] = new Date(2016, 6, 30, 13, 14, 2);
|
file2.entry['dateProp'] = new Date(2016, 6, 30, 13, 14, 2);
|
||||||
|
|
||||||
const col = <DataColumn> { key: 'dateProp' };
|
const col = <DataColumn> { key: 'dateProp' };
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, [col]);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, [col]);
|
||||||
|
|
||||||
adapter.setRows([
|
adapter.setRows([
|
||||||
new ShareDataRow(file2, contentService, null),
|
new ShareDataRow(file2, contentService, null),
|
||||||
@ -357,7 +390,7 @@ describe('ShareDataTableAdapter', () => {
|
|||||||
file4.entry.content.sizeInBytes = 2852791665; // 2.66 GB
|
file4.entry.content.sizeInBytes = 2852791665; // 2.66 GB
|
||||||
|
|
||||||
const col = <DataColumn> { key: 'content.sizeInBytes' };
|
const col = <DataColumn> { key: 'content.sizeInBytes' };
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, [col]);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, [col]);
|
||||||
|
|
||||||
adapter.setRows([
|
adapter.setRows([
|
||||||
new ShareDataRow(file3, contentService, null),
|
new ShareDataRow(file3, contentService, null),
|
||||||
@ -390,7 +423,7 @@ describe('ShareDataTableAdapter', () => {
|
|||||||
const file6 = new FileNode('b');
|
const file6 = new FileNode('b');
|
||||||
|
|
||||||
const col = <DataColumn> { key: 'name' };
|
const col = <DataColumn> { key: 'name' };
|
||||||
const adapter = new ShareDataTableAdapter(documentListService, null, contentService, [col]);
|
const adapter = new ShareDataTableAdapter(thumbnailService, contentService, [col]);
|
||||||
|
|
||||||
adapter.setRows([
|
adapter.setRows([
|
||||||
new ShareDataRow(file4, contentService, null),
|
new ShareDataRow(file4, contentService, null),
|
||||||
|
@ -25,7 +25,6 @@ import {
|
|||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { NodePaging } from '@alfresco/js-api';
|
import { NodePaging } from '@alfresco/js-api';
|
||||||
import { PermissionStyleModel } from './../models/permissions-style.model';
|
import { PermissionStyleModel } from './../models/permissions-style.model';
|
||||||
import { DocumentListService } from './../services/document-list.service';
|
|
||||||
import { ShareDataRow } from './share-data-row.model';
|
import { ShareDataRow } from './share-data-row.model';
|
||||||
import { NodeEntry } from '@alfresco/js-api/src/api/content-rest-api/model/nodeEntry';
|
import { NodeEntry } from '@alfresco/js-api/src/api/content-rest-api/model/nodeEntry';
|
||||||
import { RowFilter } from './row-filter.model';
|
import { RowFilter } from './row-filter.model';
|
||||||
@ -59,8 +58,7 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
|||||||
return this._sortingMode;
|
return this._sortingMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(private documentListService: DocumentListService,
|
constructor(private thumbnailService: ThumbnailService,
|
||||||
private thumbnailService: ThumbnailService,
|
|
||||||
private contentService: ContentService,
|
private contentService: ContentService,
|
||||||
schema: DataColumn[] = [],
|
schema: DataColumn[] = [],
|
||||||
sorting?: DataSorting,
|
sorting?: DataSorting,
|
||||||
@ -119,18 +117,18 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
|||||||
|
|
||||||
if (node.entry.isFile) {
|
if (node.entry.isFile) {
|
||||||
if (this.thumbnails) {
|
if (this.thumbnails) {
|
||||||
return this.documentListService.getDocumentThumbnailUrl(node);
|
return this.thumbnailService.getDocumentThumbnailUrl(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.entry.content) {
|
if (node.entry.content) {
|
||||||
const mimeType = node.entry.content.mimeType;
|
const mimeType = node.entry.content.mimeType;
|
||||||
if (mimeType) {
|
if (mimeType) {
|
||||||
return this.documentListService.getMimeTypeIcon(mimeType);
|
return this.thumbnailService.getMimeTypeIcon(mimeType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.documentListService.getDefaultMimeTypeIcon();
|
return this.thumbnailService.getDefaultMimeTypeIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (col.type === 'image') {
|
if (col.type === 'image') {
|
||||||
@ -175,13 +173,13 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
|||||||
|
|
||||||
private getFolderIcon(node: any) {
|
private getFolderIcon(node: any) {
|
||||||
if (this.isSmartFolder(node)) {
|
if (this.isSmartFolder(node)) {
|
||||||
return this.documentListService.getMimeTypeIcon('smartFolder');
|
return this.thumbnailService.getMimeTypeIcon('smartFolder');
|
||||||
} else if (this.isRuleFolder(node)) {
|
} else if (this.isRuleFolder(node)) {
|
||||||
return this.documentListService.getMimeTypeIcon('ruleFolder');
|
return this.thumbnailService.getMimeTypeIcon('ruleFolder');
|
||||||
} else if (this.isALinkFolder(node)) {
|
} else if (this.isALinkFolder(node)) {
|
||||||
return this.documentListService.getMimeTypeIcon('linkFolder');
|
return this.thumbnailService.getMimeTypeIcon('linkFolder');
|
||||||
} else {
|
} else {
|
||||||
return this.documentListService.getMimeTypeIcon('folder');
|
return this.thumbnailService.getMimeTypeIcon('folder');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 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 { PaginationModel } from '@alfresco/adf-core';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { DocumentLoaderNode } from '../models/document-folder.model';
|
||||||
|
|
||||||
|
export interface DocumentListLoader {
|
||||||
|
|
||||||
|
loadFolderByNodeId(nodeId: string, pagination: PaginationModel, includeFields: string[], where?: string): Observable <DocumentLoaderNode>;
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 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 { NodeEntry, NodePaging } from '@alfresco/js-api';
|
||||||
|
|
||||||
|
export class DocumentLoaderNode {
|
||||||
|
currentNode: NodeEntry;
|
||||||
|
children: NodePaging;
|
||||||
|
|
||||||
|
constructor(currentNode: NodeEntry, children: NodePaging) {
|
||||||
|
this.currentNode = currentNode;
|
||||||
|
this.children = children;
|
||||||
|
}
|
||||||
|
}
|
@ -46,4 +46,6 @@ export * from './models/document-library.model';
|
|||||||
export * from './models/permissions.model';
|
export * from './models/permissions.model';
|
||||||
export * from './models/permissions-style.model';
|
export * from './models/permissions-style.model';
|
||||||
|
|
||||||
|
export * from './interfaces/document-list-loader.interface';
|
||||||
|
|
||||||
export * from './document-list.module';
|
export * from './document-list.module';
|
||||||
|
@ -39,7 +39,7 @@ describe('DocumentActionsService', () => {
|
|||||||
const contentService = new ContentService(null, null, null, null);
|
const contentService = new ContentService(null, null, null, null);
|
||||||
const alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
const alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
||||||
|
|
||||||
documentListService = new DocumentListService(null, contentService, alfrescoApiService, null, null);
|
documentListService = new DocumentListService(contentService, alfrescoApiService, null, null);
|
||||||
service = new DocumentActionsService(null, null, new TranslationMock(), documentListService, contentService);
|
service = new DocumentActionsService(null, null, new TranslationMock(), documentListService, contentService);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
import { AlfrescoApiServiceMock, AlfrescoApiService,
|
import { AlfrescoApiServiceMock, AlfrescoApiService,
|
||||||
AppConfigService, StorageService, ContentService, setupTestBed, CoreModule, LogService, AppConfigServiceMock } from '@alfresco/adf-core';
|
AppConfigService, StorageService, ContentService, setupTestBed, CoreModule, LogService, AppConfigServiceMock } from '@alfresco/adf-core';
|
||||||
import { DocumentListService } from './document-list.service';
|
import { DocumentListService } from './document-list.service';
|
||||||
|
import { CustomResourcesService } from './custom-resources.service';
|
||||||
|
|
||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
|
|
||||||
@ -70,7 +71,8 @@ describe('DocumentListService', () => {
|
|||||||
const logService = new LogService(new AppConfigServiceMock(null));
|
const logService = new LogService(new AppConfigServiceMock(null));
|
||||||
const contentService = new ContentService(null, null, null, null);
|
const contentService = new ContentService(null, null, null, null);
|
||||||
alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
||||||
service = new DocumentListService(null, contentService, alfrescoApiService, logService, null);
|
const customActionService = new CustomResourcesService(alfrescoApiService, logService);
|
||||||
|
service = new DocumentListService(contentService, alfrescoApiService, logService, customActionService);
|
||||||
jasmine.Ajax.install();
|
jasmine.Ajax.install();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -16,26 +16,28 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AlfrescoApiService, AuthenticationService, ContentService, LogService, ThumbnailService
|
AlfrescoApiService, ContentService, LogService, PaginationModel
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { NodeEntry, NodePaging } from '@alfresco/js-api';
|
import { NodeEntry, NodePaging } from '@alfresco/js-api';
|
||||||
import { Observable, from, throwError } from 'rxjs';
|
import { DocumentLoaderNode } from '../models/document-folder.model';
|
||||||
import { catchError } from 'rxjs/operators';
|
import { Observable, from, throwError, forkJoin } from 'rxjs';
|
||||||
|
import { catchError, map } from 'rxjs/operators';
|
||||||
|
import { DocumentListLoader } from '../interfaces/document-list-loader.interface';
|
||||||
|
import { CustomResourcesService } from './custom-resources.service';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class DocumentListService {
|
export class DocumentListService implements DocumentListLoader {
|
||||||
|
|
||||||
static ROOT_ID = '-root-';
|
static ROOT_ID = '-root-';
|
||||||
|
|
||||||
constructor(authService: AuthenticationService,
|
constructor(private contentService: ContentService,
|
||||||
private contentService: ContentService,
|
|
||||||
private apiService: AlfrescoApiService,
|
private apiService: AlfrescoApiService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private thumbnailService: ThumbnailService) {
|
private customResourcesService: CustomResourcesService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -155,30 +157,31 @@ export class DocumentListService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
isCustomSourceService(nodeId): boolean {
|
||||||
* Get thumbnail URL for the given document node.
|
return this.customResourcesService.isCustomSource(nodeId);
|
||||||
* @param node Node to get URL for.
|
|
||||||
* @returns Thumbnail URL string
|
|
||||||
*/
|
|
||||||
getDocumentThumbnailUrl(node: NodeEntry): string {
|
|
||||||
return this.thumbnailService.getDocumentThumbnailUrl(node);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
loadFolderByNodeId(nodeId: string, pagination: PaginationModel, includeFields: string[], where?: string): Observable<DocumentLoaderNode> {
|
||||||
* Gets the icon that represents a MIME type.
|
if (this.customResourcesService.isCustomSource(nodeId)) {
|
||||||
* @param mimeType MIME type to get the icon for
|
return this.customResourcesService.loadFolderByNodeId(nodeId, pagination, includeFields).pipe(
|
||||||
* @returns Path to the icon file
|
map((result: any) => new DocumentLoaderNode(null, result))
|
||||||
*/
|
);
|
||||||
getMimeTypeIcon(mimeType: string): string {
|
} else {
|
||||||
return this.thumbnailService.getMimeTypeIcon(mimeType);
|
return this.retrieveDocumentNode(nodeId, pagination, includeFields, where);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private retrieveDocumentNode(nodeId: string, pagination: PaginationModel, includeFields: string[], where?: string): Observable<DocumentLoaderNode> {
|
||||||
* Gets a default icon for MIME types with no specific icon.
|
return forkJoin(
|
||||||
* @returns Path to the icon file
|
this.getFolderNode(nodeId, includeFields),
|
||||||
*/
|
this.getFolder(null, {
|
||||||
getDefaultMimeTypeIcon(): string {
|
maxItems: pagination.maxItems,
|
||||||
return this.thumbnailService.getDefaultMimeTypeIcon();
|
skipCount: pagination.skipCount,
|
||||||
|
rootFolderId: nodeId,
|
||||||
|
where: where
|
||||||
|
}, includeFields)).pipe(
|
||||||
|
map((results) => new DocumentLoaderNode(results[0], results[1]))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleError(error: any) {
|
private handleError(error: any) {
|
||||||
|
@ -40,7 +40,7 @@ describe('FolderActionsService', () => {
|
|||||||
|
|
||||||
const contentService = new ContentService(null, null, null, null);
|
const contentService = new ContentService(null, null, null, null);
|
||||||
const alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
const alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
||||||
documentListService = new DocumentListService(null, contentService, alfrescoApiService, null, null);
|
documentListService = new DocumentListService(contentService, alfrescoApiService, null, null);
|
||||||
service = new FolderActionsService(null, documentListService, contentService, new TranslationMock());
|
service = new FolderActionsService(null, documentListService, contentService, new TranslationMock());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user