mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Merge branch 'development' of https://github.com/Alfresco/alfresco-ng2-components into development
This commit is contained in:
@@ -108,46 +108,6 @@ describe('ShareDataTableAdapter', () => {
|
||||
expect(check).toThrowError(adapter.ERR_COL_NOT_FOUND);
|
||||
});
|
||||
|
||||
it('should covert cell value to formatted date', () => {
|
||||
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 file = new FileNode();
|
||||
file.entry.createdAt = rawValue;
|
||||
|
||||
let col = <DataColumn> {
|
||||
key: 'createdAt',
|
||||
type: 'date',
|
||||
format: 'medium' // Jul 15, 2015, 9:43:11 PM
|
||||
};
|
||||
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null);
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
expect(value).toBe(dateValue);
|
||||
});
|
||||
|
||||
it('should use default date format as fallback', () => {
|
||||
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 file = new FileNode();
|
||||
file.entry.createdAt = rawValue;
|
||||
|
||||
let col = <DataColumn> {
|
||||
key: 'createdAt',
|
||||
type: 'date',
|
||||
format: null
|
||||
};
|
||||
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null);
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
expect(value).toBe(dateValue);
|
||||
});
|
||||
|
||||
it('should return date value as string', () => {
|
||||
let rawValue = new Date(2015, 6, 15, 21, 43, 11); // Wed Jul 15 2015 21:43:11 GMT+0100 (BST);
|
||||
|
||||
@@ -166,26 +126,6 @@ describe('ShareDataTableAdapter', () => {
|
||||
expect(value).toBe(rawValue);
|
||||
});
|
||||
|
||||
it('should log error when having date conversion issues', () => {
|
||||
let dateValue = <Date> {};
|
||||
let file = new FileNode();
|
||||
file.entry.createdAt = <any> dateValue;
|
||||
|
||||
let col = <DataColumn> {
|
||||
key: 'createdAt',
|
||||
type: 'date',
|
||||
format: 'medium'
|
||||
};
|
||||
|
||||
let row = new ShareDataRow(file, documentListService, null);
|
||||
let adapter = new ShareDataTableAdapter(documentListService, null);
|
||||
spyOn(console, 'error').and.stub();
|
||||
|
||||
let value = adapter.getValue(row, col);
|
||||
expect(value).toBe('Error');
|
||||
expect(console.error).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should generate fallback icon for a file thumbnail with missing mime type', () => {
|
||||
spyOn(documentListService, 'getDefaultMimeTypeIcon').and.returnValue(`assets/images/ft_ic_miscellaneouse.svg`);
|
||||
|
||||
|
@@ -16,8 +16,6 @@
|
||||
*/
|
||||
|
||||
import { DataColumn, DataRow, DataSorting, DataTableAdapter } from '@alfresco/adf-core';
|
||||
import { TimeAgoPipe } from '@alfresco/adf-core';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { NodePaging } from 'alfresco-js-api';
|
||||
import { PermissionStyleModel } from './../models/permissions-style.model';
|
||||
import { DocumentListService } from './../services/document-list.service';
|
||||
@@ -78,16 +76,6 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
return dataRow.cache[col.key];
|
||||
}
|
||||
|
||||
if (col.type === 'date') {
|
||||
try {
|
||||
const result = this.formatDate(col, value);
|
||||
return dataRow.cacheValue(col.key, result);
|
||||
} catch (err) {
|
||||
console.error(`Error parsing date ${value} to format ${col.format}`);
|
||||
return 'Error';
|
||||
}
|
||||
}
|
||||
|
||||
if (col.key === '$thumbnail') {
|
||||
|
||||
if (this.imageResolver) {
|
||||
@@ -132,21 +120,6 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
return dataRow.cacheValue(col.key, value);
|
||||
}
|
||||
|
||||
formatDate(col: DataColumn, value: any): string {
|
||||
if (col.type === 'date') {
|
||||
const format = col.format || 'medium';
|
||||
if (format === 'timeAgo') {
|
||||
const timeAgoPipe = new TimeAgoPipe();
|
||||
return timeAgoPipe.transform(value);
|
||||
} else {
|
||||
const datePipe = new DatePipe('en-US');
|
||||
return datePipe.transform(value, format);
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
getSorting(): DataSorting {
|
||||
return this.sorting;
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-upload-button-test',
|
||||
template: 'test componente';
|
||||
template: 'test componente'
|
||||
})
|
||||
|
||||
export class UploadTestComponent extends UploadBase {
|
||||
@@ -214,11 +214,12 @@ describe('UploadBase', () => {
|
||||
component.uploadFiles(files);
|
||||
|
||||
expect(addToQueueSpy).toHaveBeenCalledWith(new FileModel(files[0], {
|
||||
comment: 'example-comment'
|
||||
comment: 'example-comment',
|
||||
newVersion: false,
|
||||
majorVersion: false,
|
||||
parentId: '-root-',
|
||||
path: ''
|
||||
path: '',
|
||||
nodeType: 'cm:content'
|
||||
}));
|
||||
});
|
||||
});
|
||||
@@ -246,7 +247,8 @@ describe('UploadBase', () => {
|
||||
newVersion: true,
|
||||
majorVersion: true,
|
||||
parentId: '-root-',
|
||||
path: ''
|
||||
path: '',
|
||||
nodeType: 'cm:content'
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -261,7 +263,49 @@ describe('UploadBase', () => {
|
||||
newVersion: true,
|
||||
majorVersion: false,
|
||||
parentId: '-root-',
|
||||
path: ''
|
||||
path: '',
|
||||
nodeType: 'cm:content'
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Node Type', () => {
|
||||
|
||||
let addToQueueSpy;
|
||||
|
||||
const files: File[] = [
|
||||
<File> { name: 'process.pbmn' }
|
||||
];
|
||||
|
||||
beforeEach(() => {
|
||||
addToQueueSpy = spyOn(uploadService, 'addToQueue');
|
||||
});
|
||||
|
||||
it('should have custom nodeType if it is set', () => {
|
||||
component.nodeType = 'ama:process';
|
||||
|
||||
component.uploadFiles(files);
|
||||
|
||||
expect(addToQueueSpy).toHaveBeenCalledWith(new FileModel(files[0], {
|
||||
comment: undefined,
|
||||
newVersion: false,
|
||||
majorVersion: false,
|
||||
parentId: '-root-',
|
||||
path: '',
|
||||
nodeType: 'ama:process'
|
||||
}));
|
||||
});
|
||||
|
||||
it('should have default nodeType if it is not set', () => {
|
||||
component.uploadFiles(files);
|
||||
|
||||
expect(addToQueueSpy).toHaveBeenCalledWith(new FileModel(files[0], {
|
||||
comment: undefined,
|
||||
newVersion: false,
|
||||
majorVersion: false,
|
||||
parentId: '-root-',
|
||||
path: '',
|
||||
nodeType: 'cm:content'
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
@@ -53,6 +53,10 @@ export abstract class UploadBase {
|
||||
@Input()
|
||||
comment: string;
|
||||
|
||||
/** Custom node type for uploaded file */
|
||||
@Input()
|
||||
nodeType: string = 'cm:content';
|
||||
|
||||
/** Emitted when the file is uploaded successfully. */
|
||||
@Output()
|
||||
success = new EventEmitter();
|
||||
@@ -139,7 +143,8 @@ export abstract class UploadBase {
|
||||
majorVersion: this.majorVersion,
|
||||
newVersion: this.versioning,
|
||||
parentId: parentId,
|
||||
path: path
|
||||
path: path,
|
||||
nodeType: this.nodeType
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user