#340 Rename 'AlfrescoService' to 'DocumentListService'

This commit is contained in:
Denys Vuika
2016-07-05 20:30:11 +01:00
parent 0138b40cf7
commit 0f0c5352c7
11 changed files with 71 additions and 76 deletions

View File

@@ -25,7 +25,7 @@ import { DocumentListBreadcrumb } from './src/components/document-list-breadcrum
import { FolderActionsService } from './src/services/folder-actions.service';
import { DocumentActionsService } from './src/services/document-actions.service';
import { AlfrescoService } from './src/services/alfresco.service';
import { DocumentListService } from './src/services/document-list.service';
// components
export * from './src/components/document-list';
@@ -39,7 +39,7 @@ export * from './src/components/document-list-breadcrumb.component';
// services
export * from './src/services/folder-actions.service';
export * from './src/services/document-actions.service';
export * from './src/services/alfresco.service';
export * from './src/services/document-list.service';
export const DOCUMENT_LIST_DIRECTIVES: [any] = [
DocumentList,
@@ -52,7 +52,7 @@ export const DOCUMENT_LIST_DIRECTIVES: [any] = [
];
export const DOCUMENT_LIST_PROVIDERS: [any] = [
AlfrescoService,
DocumentListService,
FolderActionsService,
DocumentActionsService
];

View File

@@ -15,15 +15,15 @@
* limitations under the License.
*/
import {Observable} from 'rxjs/Observable';
import {AlfrescoService} from '../../src/services/alfresco.service';
import { Observable } from 'rxjs/Observable';
import { DocumentListService } from './../services/document-list.service';
import {
AlfrescoSettingsService,
AlfrescoAuthenticationService,
AlfrescoContentService
} from 'ng2-alfresco-core';
export class AlfrescoServiceMock extends AlfrescoService {
export class DocumentListServiceMock extends DocumentListService {
folderToReturn: any = {};
getFolderReject: boolean = false;

View File

@@ -23,7 +23,7 @@ import {
} from '@angular/core/testing';
import { DocumentList } from './document-list';
import { AlfrescoServiceMock } from '../assets/alfresco.service.mock';
import { DocumentListServiceMock } from '../assets/document-list.service.mock';
import { ContentActionModel } from './../models/content-action.model';
import { ContentActionList } from './content-action-list';
@@ -33,8 +33,8 @@ describe('ContentColumnList', () => {
let actionList: ContentActionList;
beforeEach(() => {
let alfrescoServiceMock = new AlfrescoServiceMock();
documentList = new DocumentList(alfrescoServiceMock, null);
let documentListService = new DocumentListServiceMock();
documentList = new DocumentList(documentListService, null);
actionList = new ContentActionList(documentList);
});

View File

@@ -40,7 +40,7 @@ import {
ObjectDataColumn
} from 'ng2-alfresco-datatable';
import { AlfrescoService } from './../services/alfresco.service';
import { DocumentListService } from './../services/document-list.service';
import { MinimalNodeEntity } from './../models/document-library.model';
import { ContentActionModel } from './../models/content-action.model';
import { ShareDataTableAdapter, ShareDataRow } from './../data/share-datatable-adapter';
@@ -53,7 +53,7 @@ declare let __moduleName: string;
selector: 'alfresco-document-list',
styleUrls: ['./document-list.css'],
templateUrl: './document-list.html',
providers: [AlfrescoService],
providers: [DocumentListService],
directives: [CONTEXT_MENU_DIRECTIVES, ALFRESCO_DATATABLE_DIRECTIVES],
host: {
'(contextmenu)': 'onShowContextMenu($event)'
@@ -125,7 +125,7 @@ export class DocumentList implements OnInit, AfterViewInit, AfterViewChecked, Af
data: ShareDataTableAdapter;
constructor(
private alfrescoService: AlfrescoService,
private documentListService: DocumentListService,
private ngZone: NgZone) {
this.setupData();
@@ -329,7 +329,7 @@ export class DocumentList implements OnInit, AfterViewInit, AfterViewChecked, Af
}
private setupData() {
this.data = new ShareDataTableAdapter(this.alfrescoService, this.baseComponentPath, []);
this.data = new ShareDataTableAdapter(this.documentListService, this.baseComponentPath, []);
this.data.setSorting(new DataSorting('id', 'asc'));
}

View File

@@ -23,7 +23,7 @@ import {
} from 'ng2-alfresco-datatable';
import { NodePaging, MinimalNodeEntity } from './../models/document-library.model';
import { AlfrescoService as DataService } from './../services/alfresco.service';
import { DocumentListService } from './../services/document-list.service';
export class ShareDataTableAdapter implements DataTableAdapter {
@@ -33,7 +33,7 @@ export class ShareDataTableAdapter implements DataTableAdapter {
thumbnails: boolean = false;
constructor(private dataService: DataService,
constructor(private documentListService: DocumentListService,
private basePath: string,
schema: DataColumn[]) {
this.rows = [];
@@ -94,8 +94,8 @@ export class ShareDataTableAdapter implements DataTableAdapter {
if (node.entry.isFile) {
if (this.thumbnails) {
if (this.dataService) {
return this.dataService.getDocumentThumbnailUrl(node);
if (this.documentListService) {
return this.documentListService.getDocumentThumbnailUrl(node);
}
return null;
}
@@ -103,7 +103,7 @@ export class ShareDataTableAdapter implements DataTableAdapter {
if (node.entry.content && node.entry.content.mimeType) {
let mimeType = node.entry.content.mimeType;
if (mimeType) {
let icon = this.dataService.getMimeTypeIcon(mimeType);
let icon = this.documentListService.getMimeTypeIcon(mimeType);
if (icon) {
return `${this.basePath}/img/${icon}`;
}
@@ -163,8 +163,8 @@ export class ShareDataTableAdapter implements DataTableAdapter {
}
loadPath(path: string) {
if (path && this.dataService) {
this.dataService
if (path && this.documentListService) {
this.documentListService
.getFolder(path)
.subscribe(val => {
let page = <NodePaging>val;

View File

@@ -24,8 +24,8 @@ import {
import { AlfrescoContentService } from 'ng2-alfresco-core';
import { ContentActionHandler } from '../models/content-action.model';
import { DocumentActionsService } from './document-actions.service';
import { AlfrescoServiceMock } from '../assets/alfresco.service.mock';
import { AlfrescoService } from './alfresco.service';
import { DocumentListServiceMock } from '../assets/document-list.service.mock';
import { DocumentListService } from './document-list.service';
import {
FileNode,
FolderNode
@@ -34,13 +34,13 @@ import {
describe('DocumentActionsService', () => {
let service: DocumentActionsService;
let alfrescoService: AlfrescoService;
let documentListService: DocumentListService;
let contentService: AlfrescoContentService;
beforeEach(() => {
alfrescoService = new AlfrescoServiceMock();
documentListService = new DocumentListServiceMock();
contentService = new AlfrescoContentService(null, null);
service = new DocumentActionsService(alfrescoService, contentService);
service = new DocumentActionsService(documentListService, contentService);
});
it('should register default download action', () => {
@@ -147,7 +147,7 @@ describe('DocumentActionsService', () => {
});
it('should require content service for download action', () => {
let actionService = new DocumentActionsService(alfrescoService, null);
let actionService = new DocumentActionsService(documentListService, null);
let file = new FileNode();
let result = actionService.getHandler('download')(file);
expect(result).toBeFalsy();
@@ -159,44 +159,44 @@ describe('DocumentActionsService', () => {
});
it('should delete file node', () => {
spyOn(alfrescoService, 'deleteNode').and.callThrough();
spyOn(documentListService, 'deleteNode').and.callThrough();
let file = new FileNode();
service.getHandler('delete')(file);
expect(alfrescoService.deleteNode).toHaveBeenCalledWith(file.entry.id);
expect(documentListService.deleteNode).toHaveBeenCalledWith(file.entry.id);
});
it('should support deletion only file node', () => {
spyOn(alfrescoService, 'deleteNode').and.callThrough();
spyOn(documentListService, 'deleteNode').and.callThrough();
let folder = new FolderNode();
service.getHandler('delete')(folder);
expect(alfrescoService.deleteNode).not.toHaveBeenCalled();
expect(documentListService.deleteNode).not.toHaveBeenCalled();
let file = new FileNode();
service.getHandler('delete')(file);
expect(alfrescoService.deleteNode).toHaveBeenCalled();
expect(documentListService.deleteNode).toHaveBeenCalled();
});
it('should require node id to delete', () => {
spyOn(alfrescoService, 'deleteNode').and.callThrough();
spyOn(documentListService, 'deleteNode').and.callThrough();
let file = new FileNode();
file.entry.id = null;
service.getHandler('delete')(file);
expect(alfrescoService.deleteNode).not.toHaveBeenCalled();
expect(documentListService.deleteNode).not.toHaveBeenCalled();
});
it('should reload target upon node deletion', () => {
spyOn(alfrescoService, 'deleteNode').and.callThrough();
spyOn(documentListService, 'deleteNode').and.callThrough();
let target = jasmine.createSpyObj('obj', ['reload']);
let file = new FileNode();
service.getHandler('delete')(file, target);
expect(alfrescoService.deleteNode).toHaveBeenCalled();
expect(documentListService.deleteNode).toHaveBeenCalled();
expect(target.reload).toHaveBeenCalled();
});
});

View File

@@ -15,9 +15,9 @@
* limitations under the License.
*/
import {Injectable} from '@angular/core';
import {ContentActionHandler} from '../models/content-action.model';
import {AlfrescoService} from './alfresco.service';
import { Injectable } from '@angular/core';
import { ContentActionHandler } from '../models/content-action.model';
import { DocumentListService } from './document-list.service';
import { AlfrescoContentService } from 'ng2-alfresco-core';
@Injectable()
@@ -25,7 +25,7 @@ export class DocumentActionsService {
private handlers: { [id: string]: ContentActionHandler; } = {};
constructor(
private alfrescoService?: AlfrescoService,
private documentListService?: DocumentListService,
private contentService?: AlfrescoContentService
) {
this.setupActionHandlers();
@@ -49,7 +49,7 @@ export class DocumentActionsService {
}
canExecuteAction(obj: any): boolean {
return this.alfrescoService && obj && obj.entry.isFile === true;
return this.documentListService && obj && obj.entry.isFile === true;
}
private setupActionHandlers() {
@@ -86,7 +86,7 @@ export class DocumentActionsService {
private deleteNode(obj: any, target?: any) {
if (this.canExecuteAction(obj) && obj.entry && obj.entry.id) {
this.alfrescoService.deleteNode(obj.entry.id).subscribe(() => {
this.documentListService.deleteNode(obj.entry.id).subscribe(() => {
if (target && typeof target.reload === 'function') {
target.reload();
}

View File

@@ -27,12 +27,11 @@ import {
AlfrescoContentService
} from 'ng2-alfresco-core';
import { FileNode } from '../assets/document-library.model.mock';
import { AlfrescoService } from './alfresco.service';
import { DocumentListService } from './document-list.service';
// TODO: rename to DocumentListService
describe('AlfrescoService', () => {
describe('DocumentListService', () => {
let service: AlfrescoService;
let service: DocumentListService;
let settingsService: AlfrescoSettingsService;
let authService: AlfrescoAuthenticationService;
let contentService: AlfrescoContentService;
@@ -42,7 +41,7 @@ describe('AlfrescoService', () => {
settingsService = new AlfrescoSettingsService();
authService = new AlfrescoAuthenticationService(settingsService);
contentService = new AlfrescoContentService(settingsService, authService);
service = new AlfrescoService(settingsService, authService, contentService);
service = new DocumentListService(settingsService, authService, contentService);
});
it('should require node to get thumbnail url', () => {
@@ -50,7 +49,7 @@ describe('AlfrescoService', () => {
});
it('should require content service to get thumbnail url', () => {
service = new AlfrescoService(settingsService, authService, null);
service = new DocumentListService(settingsService, authService, null);
let file = new FileNode();
expect(service.getDocumentThumbnailUrl(file)).toBeNull();
});
@@ -72,9 +71,9 @@ describe('AlfrescoService', () => {
});
it('should resolve default icon for mime type', () => {
expect(service.getMimeTypeIcon(null)).toBe(AlfrescoService.DEFAULT_MIME_TYPE_ICON);
expect(service.getMimeTypeIcon('')).toBe(AlfrescoService.DEFAULT_MIME_TYPE_ICON);
expect(service.getMimeTypeIcon('missing/type')).toBe(AlfrescoService.DEFAULT_MIME_TYPE_ICON);
expect(service.getMimeTypeIcon(null)).toBe(DocumentListService.DEFAULT_MIME_TYPE_ICON);
expect(service.getMimeTypeIcon('')).toBe(DocumentListService.DEFAULT_MIME_TYPE_ICON);
expect(service.getMimeTypeIcon('missing/type')).toBe(DocumentListService.DEFAULT_MIME_TYPE_ICON);
});
});

View File

@@ -27,12 +27,8 @@ import {
declare let AlfrescoApi: any;
// TODO: consider renaming to something like 'DocumentListService'
/**
* Internal service used by Document List component.
*/
@Injectable()
export class AlfrescoService {
export class DocumentListService {
static DEFAULT_MIME_TYPE_ICON: string = 'ft_ic_miscellaneous.svg';
@@ -120,7 +116,7 @@ export class AlfrescoService {
getMimeTypeIcon(mimeType: string): string {
let icon = this.mimeTypeIcons[mimeType];
return icon || AlfrescoService.DEFAULT_MIME_TYPE_ICON;
return icon || DocumentListService.DEFAULT_MIME_TYPE_ICON;
}
private handleError(error: Response) {

View File

@@ -27,17 +27,17 @@ import {
FileNode,
FolderNode
} from '../assets/document-library.model.mock';
import { AlfrescoService } from './alfresco.service';
import { AlfrescoServiceMock } from '../assets/alfresco.service.mock';
import { DocumentListService } from './document-list.service';
import { DocumentListServiceMock } from '../assets/document-list.service.mock';
describe('FolderActionsService', () => {
let service: FolderActionsService;
let alfrescoService: AlfrescoService;
let documentListService: DocumentListService;
beforeEach(() => {
alfrescoService = new AlfrescoServiceMock();
service = new FolderActionsService(alfrescoService);
documentListService = new DocumentListServiceMock();
service = new FolderActionsService(documentListService);
});
it('should register custom action handler', () => {
@@ -105,44 +105,44 @@ describe('FolderActionsService', () => {
});
it('should delete folder node', () => {
spyOn(alfrescoService, 'deleteNode').and.callThrough();
spyOn(documentListService, 'deleteNode').and.callThrough();
let folder = new FolderNode();
service.getHandler('delete')(folder);
expect(alfrescoService.deleteNode).toHaveBeenCalledWith(folder.entry.id);
expect(documentListService.deleteNode).toHaveBeenCalledWith(folder.entry.id);
});
it('should support deletion only folder node', () => {
spyOn(alfrescoService, 'deleteNode').and.callThrough();
spyOn(documentListService, 'deleteNode').and.callThrough();
let file = new FileNode();
service.getHandler('delete')(file);
expect(alfrescoService.deleteNode).not.toHaveBeenCalled();
expect(documentListService.deleteNode).not.toHaveBeenCalled();
let folder = new FolderNode();
service.getHandler('delete')(folder);
expect(alfrescoService.deleteNode).toHaveBeenCalled();
expect(documentListService.deleteNode).toHaveBeenCalled();
});
it('should require node id to delete', () => {
spyOn(alfrescoService, 'deleteNode').and.callThrough();
spyOn(documentListService, 'deleteNode').and.callThrough();
let folder = new FolderNode();
folder.entry.id = null;
service.getHandler('delete')(folder);
expect(alfrescoService.deleteNode).not.toHaveBeenCalled();
expect(documentListService.deleteNode).not.toHaveBeenCalled();
});
it('should reload target upon node deletion', () => {
spyOn(alfrescoService, 'deleteNode').and.callThrough();
spyOn(documentListService, 'deleteNode').and.callThrough();
let target = jasmine.createSpyObj('obj', ['reload']);
let folder = new FolderNode();
service.getHandler('delete')(folder, target);
expect(alfrescoService.deleteNode).toHaveBeenCalled();
expect(documentListService.deleteNode).toHaveBeenCalled();
expect(target.reload).toHaveBeenCalled();
});

View File

@@ -15,15 +15,15 @@
* limitations under the License.
*/
import {Injectable} from '@angular/core';
import {ContentActionHandler} from '../models/content-action.model';
import {AlfrescoService} from './alfresco.service';
import { Injectable } from '@angular/core';
import { ContentActionHandler } from '../models/content-action.model';
import { DocumentListService } from './document-list.service';
@Injectable()
export class FolderActionsService {
private handlers: { [id: string]: ContentActionHandler; } = {};
constructor(private _alfrescoService?: AlfrescoService) {
constructor(private documentListService?: DocumentListService) {
this.setupActionHandlers();
}
@@ -45,7 +45,7 @@ export class FolderActionsService {
}
canExecuteAction(obj: any): boolean {
return this._alfrescoService && obj && obj.entry.isFolder === true;
return this.documentListService && obj && obj.entry.isFolder === true;
}
private setupActionHandlers() {
@@ -68,7 +68,7 @@ export class FolderActionsService {
private deleteNode(obj: any, target?: any) {
if (this.canExecuteAction(obj) && obj.entry && obj.entry.id) {
this._alfrescoService.deleteNode(obj.entry.id).subscribe(() => {
this.documentListService.deleteNode(obj.entry.id).subscribe(() => {
if (target && typeof target.reload === 'function') {
target.reload();
}