diff --git a/demo-shell-ng2/app/components/files/files.component.html b/demo-shell-ng2/app/components/files/files.component.html index 38c8a79e33..0197898389 100644 --- a/demo-shell-ng2/app/components/files/files.component.html +++ b/demo-shell-ng2/app/components/files/files.component.html @@ -17,7 +17,7 @@ --> - + + source="createdAt" + type="date" + format="medium"> diff --git a/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts b/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts index 68404f1a46..42584e1786 100644 --- a/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts @@ -50,7 +50,7 @@ import { - + + source="createdAt" + type="date" + format="medium"> diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/content-column.ts b/ng2-components/ng2-alfresco-documentlist/src/components/content-column.ts index 061b83feb1..568cf9f17a 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/content-column.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/components/content-column.ts @@ -40,6 +40,12 @@ export class ContentColumn implements OnInit, OnChanges { @Input('class') cssClass: string; + @Input() + type: string = 'text'; + + @Input() + format: string; + model: ContentColumnModel; constructor(private list: ContentColumnList) { @@ -51,7 +57,9 @@ export class ContentColumn implements OnInit, OnChanges { title: this.title, srTitle: this.srTitle, source: this.source, - cssClass: this.cssClass + cssClass: this.cssClass, + type: this.type, + format: this.format }); if (!this.model.srTitle && this.model.source === '$thumbnail') { diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.css b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.css index 510e9ef7fe..3a7c233881 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.css +++ b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.css @@ -23,6 +23,8 @@ cursor: pointer; } +:host .cell-value {} + :host .folder-row-cell.name-column, :host .document-row-cell.name-column { font-size: 15px; diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.html b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.html index 4723e07089..ee9f3fed75 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.html +++ b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.html @@ -36,15 +36,18 @@ - -
- +
+
- - {{getObjectValue(content.entry, col.source)}} + + {{ getCellValue(content, col) }} + + + {{ getCellValue(content, col) }} diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.spec.ts b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.spec.ts index a7d626f58e..405d5752bf 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.spec.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.spec.ts @@ -59,7 +59,9 @@ describe('DocumentList', () => { title: 'title', source: 'source', cssClass: 'css', - srTitle: '' + srTitle: '', + type: 'text', + format: '' }; documentList.columns.push(column); diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts index 020555c6a1..7f5990ca62 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts @@ -26,6 +26,7 @@ import { OnChanges, TemplateRef } from 'angular2/core'; +import { DatePipe } from 'angular2/common'; import { AlfrescoService } from './../services/alfresco.service'; import { MinimalNodeEntity, NodePaging } from './../models/document-library.model'; import { ContentActionModel } from './../models/content-action.model'; @@ -345,12 +346,36 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit, return target; } + getCellValue(row: MinimalNodeEntity, col: ContentColumnModel): any { + let value = this._getObjectValueRaw(row.entry, col.source); + + if (col.type === 'date') { + let datePipe = new DatePipe(); + if (datePipe.supports(value)) { + // TODO: to be changed to plan non-array value post angular2 beta.15 + let pattern = col.format ? [col.format] : []; + return datePipe.transform(value, pattern); + } + } + + if (col.type === 'image') { + + if (col.source === '$thumbnail') { + return this.getThumbnailUrl(row); + } + + } + + return value; + } + /** * Creates a set of predefined columns. */ setupDefaultColumns(): void { let thumbnailCol = new ContentColumnModel(); thumbnailCol.source = '$thumbnail'; + thumbnailCol.type = 'image'; let nameCol = new ContentColumnModel(); nameCol.title = 'Name'; diff --git a/ng2-components/ng2-alfresco-documentlist/src/models/content-column.model.ts b/ng2-components/ng2-alfresco-documentlist/src/models/content-column.model.ts index 24ff9fcf0b..3ea69b3b12 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/models/content-column.model.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/models/content-column.model.ts @@ -20,6 +20,8 @@ export class ContentColumnModel { srTitle: string; source: string; cssClass: string; + type: string = 'text'; // text|date|image|number + format: string = 'medium'; constructor(obj?: any) { if (obj) { @@ -27,6 +29,8 @@ export class ContentColumnModel { this.srTitle = obj.srTitle; this.source = obj.source; this.cssClass = obj.cssClass; + this.type = obj.type || 'text'; + this.format = obj.format; } } }