fix new ts javascript api

This commit is contained in:
Mario Romano 2016-09-26 23:32:18 +01:00
parent 16d8c55f62
commit 07f6bb2552
5 changed files with 24 additions and 24 deletions

View File

@ -17,25 +17,25 @@
import { import {
NodePaging, NodePaging,
MinimalNodeEntity, NodeMinimalEntry,
MinimalNodeEntryEntity, NodeMinimal,
PathInfoEntity, PathInfoEntity,
ContentInfo, ContentInfo,
NodePagingList NodePagingList
} from '../models/document-library.model'; } from '../models/document-library.model';
export class PageNode extends NodePaging { export class PageNode extends NodePaging {
constructor(entries?: MinimalNodeEntity[]) { constructor(entries?: NodeMinimalEntry[]) {
super(); super();
this.list = new NodePagingList(); this.list = new NodePagingList();
this.list.entries = entries || []; this.list.entries = entries || [];
} }
} }
export class FileNode extends MinimalNodeEntity { export class FileNode extends NodeMinimalEntry {
constructor(name?: string, mimeType?: string) { constructor(name?: string, mimeType?: string) {
super(); super();
this.entry = new MinimalNodeEntryEntity(); this.entry = new NodeMinimal();
this.entry.id = 'file-id'; this.entry.id = 'file-id';
this.entry.isFile = true; this.entry.isFile = true;
this.entry.isFolder = false; this.entry.isFolder = false;
@ -46,10 +46,10 @@ export class FileNode extends MinimalNodeEntity {
} }
} }
export class FolderNode extends MinimalNodeEntity { export class FolderNode extends NodeMinimalEntry {
constructor(name?: string) { constructor(name?: string) {
super(); super();
this.entry = new MinimalNodeEntryEntity(); this.entry = new NodeMinimal();
this.entry.id = 'folder-id'; this.entry.id = 'folder-id';
this.entry.isFile = false; this.entry.isFile = false;
this.entry.isFolder = true; this.entry.isFolder = true;

View File

@ -21,7 +21,7 @@ import { DocumentList } from './document-list';
import { DocumentListServiceMock } from './../assets/document-list.service.mock'; import { DocumentListServiceMock } from './../assets/document-list.service.mock';
import { ContentActionModel } from '../models/content-action.model'; import { ContentActionModel } from '../models/content-action.model';
import { FileNode, FolderNode } from '../assets/document-library.model.mock'; import { FileNode, FolderNode } from '../assets/document-library.model.mock';
import { MinimalNodeEntity } from '../models/document-library.model'; import { NodeMinimalEntry } from '../models/document-library.model';
describe('DocumentList', () => { describe('DocumentList', () => {
@ -131,7 +131,7 @@ describe('DocumentList', () => {
documentButton.target = 'document'; documentButton.target = 'document';
documentList.actions = [documentButton]; documentList.actions = [documentButton];
let node = new MinimalNodeEntity(); let node = new NodeMinimalEntry();
expect(documentList.getNodeActions(node)).toEqual([]); expect(documentList.getNodeActions(node)).toEqual([]);
node = new FileNode(); node = new FileNode();

View File

@ -130,7 +130,7 @@ describe('ShareDataTableAdapter', () => {
}); });
it('should covert cell value to formatted date', () => { it('should covert cell value to formatted date', () => {
let rawValue = new Date(2015, 6, 15, 21, 43, 11).toString(); // Wed Jul 15 2015 21:43:11 GMT+0100 (BST); let rawValue = new Date(2015, 6, 15, 21, 43, 11); // Wed Jul 15 2015 21:43:11 GMT+0100 (BST);
let dateValue = 'Jul 15, 2015, 9:43:11 PM'; let dateValue = 'Jul 15, 2015, 9:43:11 PM';
let file = new FileNode(); let file = new FileNode();
@ -150,7 +150,7 @@ describe('ShareDataTableAdapter', () => {
}); });
it('should use default date format as fallback', () => { it('should use default date format as fallback', () => {
let rawValue = new Date(2015, 6, 15, 21, 43, 11).toString(); // Wed Jul 15 2015 21:43:11 GMT+0100 (BST); let rawValue = new Date(2015, 6, 15, 21, 43, 11); // Wed Jul 15 2015 21:43:11 GMT+0100 (BST);
let dateValue = 'Jul 15, 2015, 9:43:11 PM'; let dateValue = 'Jul 15, 2015, 9:43:11 PM';
let file = new FileNode(); let file = new FileNode();
@ -170,7 +170,7 @@ describe('ShareDataTableAdapter', () => {
}); });
it('should return date value as string', () => { it('should return date value as string', () => {
let rawValue = new Date(2015, 6, 15, 21, 43, 11).toString(); // Wed Jul 15 2015 21:43:11 GMT+0100 (BST); let rawValue = new Date(2015, 6, 15, 21, 43, 11); // Wed Jul 15 2015 21:43:11 GMT+0100 (BST);
let file = new FileNode(); let file = new FileNode();
file.entry.createdAt = rawValue; file.entry.createdAt = rawValue;
@ -190,7 +190,7 @@ describe('ShareDataTableAdapter', () => {
it('should log error when having date conversion issues', () => { it('should log error when having date conversion issues', () => {
let dateValue = '[wrong-date]'; let dateValue = '[wrong-date]';
let file = new FileNode(); let file = new FileNode();
file.entry.createdAt = dateValue; file.entry.createdAt = <any> dateValue;
let col = <DataColumn> { let col = <DataColumn> {
key: 'createdAt', key: 'createdAt',

View File

@ -23,7 +23,7 @@ import {
DataRow, DataColumn, DataSorting DataRow, DataColumn, DataSorting
} from 'ng2-alfresco-datatable'; } from 'ng2-alfresco-datatable';
import { NodePaging, MinimalNodeEntity } from './../models/document-library.model'; import { NodePaging, NodeMinimalEntry } from './../models/document-library.model';
import { DocumentListService } from './../services/document-list.service'; import { DocumentListService } from './../services/document-list.service';
export class ShareDataTableAdapter implements DataTableAdapter, PaginationProvider { export class ShareDataTableAdapter implements DataTableAdapter, PaginationProvider {
@ -305,11 +305,11 @@ export class ShareDataRow implements DataRow {
isSelected: boolean = false; isSelected: boolean = false;
get node(): MinimalNodeEntity { get node(): NodeMinimalEntry {
return this.obj; return this.obj;
} }
constructor(private obj: MinimalNodeEntity) { constructor(private obj: NodeMinimalEntry) {
if (!obj) { if (!obj) {
throw new Error(ShareDataRow.ERR_OBJECT_NOT_FOUND); throw new Error(ShareDataRow.ERR_OBJECT_NOT_FOUND);
} }

View File

@ -17,18 +17,19 @@
// note: contains only limited subset of available fields // note: contains only limited subset of available fields
import { MinimalNodeEntity, MinimalNodeEntryEntity } from 'alfresco-js-api';
export class NodePaging { export class NodePaging {
list: NodePagingList; list: NodePagingList;
} }
export class NodePagingList { export class NodePagingList {
pagination: Pagination; pagination: Pagination;
entries: MinimalNodeEntity[]; entries: NodeMinimalEntry[];
} }
// TODO: rename to NodeMinimalEntry export class NodeMinimalEntry implements MinimalNodeEntity {
export class MinimalNodeEntity { entry: NodeMinimal;
entry: MinimalNodeEntryEntity;
} }
export class Pagination { export class Pagination {
@ -39,17 +40,16 @@ export class Pagination {
maxItems: number; maxItems: number;
} }
// TODO: rename to NodeMinimal export class NodeMinimal implements MinimalNodeEntryEntity {
export class MinimalNodeEntryEntity {
id: string; id: string;
parentId: string; parentId: string;
name: string; name: string;
nodeType: string; nodeType: string;
isFolder: boolean; isFolder: boolean;
isFile: boolean; isFile: boolean;
modifiedAt: string; modifiedAt: Date;
modifiedByUser: UserInfo; modifiedByUser: UserInfo;
createdAt: string; createdAt: Date;
createdByUser: UserInfo; createdByUser: UserInfo;
content: ContentInfo; content: ContentInfo;
path: PathInfoEntity; path: PathInfoEntity;