mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
#9 binding custom columns to nested properties
allow binding columns to bested properties and property paths, i.e. “item.location.path”
This commit is contained in:
@@ -7,6 +7,10 @@
|
|||||||
source="displayName"
|
source="displayName"
|
||||||
class="full-width name-column">
|
class="full-width name-column">
|
||||||
</content-column>
|
</content-column>
|
||||||
|
<content-column
|
||||||
|
title="{{'DOCUMENT_LIST.COLUMNS.SITE' | translate}}"
|
||||||
|
source="location.site">
|
||||||
|
</content-column>
|
||||||
<content-column
|
<content-column
|
||||||
title="{{'DOCUMENT_LIST.COLUMNS.CREATED_BY' | translate}}"
|
title="{{'DOCUMENT_LIST.COLUMNS.CREATED_BY' | translate}}"
|
||||||
source="createdBy">
|
source="createdBy">
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
"DOCUMENT_LIST": {
|
"DOCUMENT_LIST": {
|
||||||
"COLUMNS": {
|
"COLUMNS": {
|
||||||
"DISPLAY_NAME": "Display name",
|
"DISPLAY_NAME": "Display name",
|
||||||
|
"SITE": "Site",
|
||||||
"CREATED_BY": "Created by",
|
"CREATED_BY": "Created by",
|
||||||
"CREATED_ON": "Created on"
|
"CREATED_ON": "Created on"
|
||||||
},
|
},
|
||||||
|
@@ -89,6 +89,34 @@ A custom set of columns can look like the following:
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
|
Binding to nested properties is also supported. Assuming you have the node structure similar to following:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"nodeRef": "workspace://SpacesStore/8bb36efb-c26d-4d2b-9199-ab6922f53c28",
|
||||||
|
"nodeType": "cm:folder",
|
||||||
|
"type": "folder",
|
||||||
|
"location": {
|
||||||
|
"repositoryId": "552ca13e-458b-4566-9f3e-d0f9c92facff",
|
||||||
|
"site": "swsdp",
|
||||||
|
"siteTitle": "Sample: Web Site Design Project"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
the binding value for the Site column to display location site will be `location.site`:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<alfresco-document-list ...>
|
||||||
|
<content-columns>
|
||||||
|
<content-column source="$thumbnail"></content-column>
|
||||||
|
<content-column title="Name" source="displayName" class="full-width name-column"></content-column>
|
||||||
|
<content-column title="Site" source="location.site"></content-column>
|
||||||
|
</content-columns>
|
||||||
|
</alfresco-document-list>
|
||||||
|
```
|
||||||
|
|
||||||
### Custom folder icon
|
### Custom folder icon
|
||||||
|
|
||||||
Document list element exposes `folder-icon` property that accepts a CSS class list value with
|
Document list element exposes `folder-icon` property that accepts a CSS class list value with
|
||||||
|
@@ -49,5 +49,13 @@ export declare class DocumentList implements OnInit, AfterViewChecked, AfterCont
|
|||||||
executeContentAction(node: DocumentEntity, action: ContentActionModel): void;
|
executeContentAction(node: DocumentEntity, action: ContentActionModel): void;
|
||||||
displayFolderContent(path: any): void;
|
displayFolderContent(path: any): void;
|
||||||
getNodePath(node: DocumentEntity): string;
|
getNodePath(node: DocumentEntity): string;
|
||||||
|
/**
|
||||||
|
* Gets a value from an object by composed key
|
||||||
|
* documentList.getObjectValue({ item: { nodeType: 'cm:folder' }}, 'item.nodeType') ==> 'cm:folder'
|
||||||
|
* @param target
|
||||||
|
* @param key
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
getObjectValue(target: any, key: string): string;
|
||||||
setupDefaultColumns(): void;
|
setupDefaultColumns(): void;
|
||||||
}
|
}
|
||||||
|
@@ -42,7 +42,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span *ngSwitchDefault>
|
<span *ngSwitchDefault>
|
||||||
{{content[col.source]}}
|
{{getObjectValue(content, col.source)}}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
@@ -163,6 +163,32 @@ System.register(['angular2/core', './../services/alfresco.service', './../models
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* Gets a value from an object by composed key
|
||||||
|
* documentList.getObjectValue({ item: { nodeType: 'cm:folder' }}, 'item.nodeType') ==> 'cm:folder'
|
||||||
|
* @param target
|
||||||
|
* @param key
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
DocumentList.prototype.getObjectValue = function (target, key) {
|
||||||
|
var keys = key.split('.');
|
||||||
|
key = '';
|
||||||
|
do {
|
||||||
|
key += keys.shift();
|
||||||
|
var value = target[key];
|
||||||
|
if (value !== undefined && (typeof value === 'object' || !keys.length)) {
|
||||||
|
target = value;
|
||||||
|
key = '';
|
||||||
|
}
|
||||||
|
else if (!keys.length) {
|
||||||
|
target = undefined;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
key += '.';
|
||||||
|
}
|
||||||
|
} while (keys.length);
|
||||||
|
return target;
|
||||||
|
};
|
||||||
DocumentList.prototype.setupDefaultColumns = function () {
|
DocumentList.prototype.setupDefaultColumns = function () {
|
||||||
var thumbnailCol = new content_column_model_1.ContentColumnModel();
|
var thumbnailCol = new content_column_model_1.ContentColumnModel();
|
||||||
thumbnailCol.source = '$thumbnail';
|
thumbnailCol.source = '$thumbnail';
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -197,6 +197,33 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a value from an object by composed key
|
||||||
|
* documentList.getObjectValue({ item: { nodeType: 'cm:folder' }}, 'item.nodeType') ==> 'cm:folder'
|
||||||
|
* @param target
|
||||||
|
* @param key
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
getObjectValue(target: any, key: string): string {
|
||||||
|
let keys = key.split('.');
|
||||||
|
key = '';
|
||||||
|
|
||||||
|
do {
|
||||||
|
key += keys.shift();
|
||||||
|
let value = target[key];
|
||||||
|
if (value !== undefined && (typeof value === 'object' || !keys.length)) {
|
||||||
|
target = value;
|
||||||
|
key = '';
|
||||||
|
} else if (!keys.length) {
|
||||||
|
target = undefined;
|
||||||
|
} else {
|
||||||
|
key += '.';
|
||||||
|
}
|
||||||
|
} while (keys.length);
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
setupDefaultColumns(): void {
|
setupDefaultColumns(): void {
|
||||||
let thumbnailCol = new ContentColumnModel();
|
let thumbnailCol = new ContentColumnModel();
|
||||||
thumbnailCol.source = '$thumbnail';
|
thumbnailCol.source = '$thumbnail';
|
||||||
|
Reference in New Issue
Block a user