mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
[ADF-4341] Customise the property title into the InfoDrawer from configuration (#5556)
* [ADF-4341] Customise the property title into the InfoDrawer from configuration * * docs added * * removed unnecessary logic and docs updated
This commit is contained in:
parent
772188c13d
commit
c684d5f50c
@ -818,7 +818,23 @@
|
|||||||
"presets": {
|
"presets": {
|
||||||
"default": {
|
"default": {
|
||||||
"exif:exif": "*"
|
"exif:exif": "*"
|
||||||
}
|
},
|
||||||
|
"custom-title": [{
|
||||||
|
"title": "Exif",
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"aspect": "exif:exif",
|
||||||
|
"editing": false,
|
||||||
|
"properties": [
|
||||||
|
"exif:pixelXDimension",
|
||||||
|
{
|
||||||
|
"title": "Custom YDimension Name",
|
||||||
|
"name": "exif:pixelYDimension"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}]
|
||||||
},
|
},
|
||||||
"multi-value-pipe-separator": ", ",
|
"multi-value-pipe-separator": ", ",
|
||||||
"multi-value-chips": true
|
"multi-value-chips": true
|
||||||
|
@ -212,6 +212,42 @@ A more complex config is shown in the example below:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Custom property title example
|
||||||
|
|
||||||
|
In layout oriented configuration, the metadata property title can be overridden from ADF as below.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"name": "exif:pixelYDimension", // your desired property name
|
||||||
|
"title": "Custom YDimension Name" // your desired property title
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```json
|
||||||
|
"content-metadata": {
|
||||||
|
"presets": {
|
||||||
|
"kittens": [
|
||||||
|
{
|
||||||
|
"title": "GROUP-TITLE1-TRANSLATION-KEY",
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"aspect": "exif:exif",
|
||||||
|
"properties": [
|
||||||
|
"exif:pixelXDimension",
|
||||||
|
{
|
||||||
|
"title": "Custom YDimension Name",
|
||||||
|
"name": "exif:pixelYDimension"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Note: The desired property title should be valid. otherwise it will take default value.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
The result of this config would be two accordion groups with the following properties:
|
The result of this config would be two accordion groups with the following properties:
|
||||||
|
|
||||||
| GROUP-TITLE1-TRANSLATION-KEY |
|
| GROUP-TITLE1-TRANSLATION-KEY |
|
||||||
|
Binary file not shown.
After Width: | Height: | Size: 8.9 KiB |
@ -15,10 +15,12 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Property } from './property.interface';
|
||||||
|
|
||||||
export interface LayoutOrientedConfigItem {
|
export interface LayoutOrientedConfigItem {
|
||||||
aspect?: string;
|
aspect?: string;
|
||||||
type?: string;
|
type?: string;
|
||||||
properties: string | string[];
|
properties: string | string[] | Property[];
|
||||||
includeAll?: boolean;
|
includeAll?: boolean;
|
||||||
exclude?: string | string[];
|
exclude?: string | string[];
|
||||||
editable?: boolean;
|
editable?: boolean;
|
||||||
|
@ -16,7 +16,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { LayoutOrientedConfigService } from './layout-oriented-config.service';
|
import { LayoutOrientedConfigService } from './layout-oriented-config.service';
|
||||||
import { LayoutOrientedConfig, Property, OrganisedPropertyGroup, PropertyGroupContainer } from '../../interfaces/content-metadata.interfaces';
|
import {
|
||||||
|
LayoutOrientedConfig,
|
||||||
|
Property,
|
||||||
|
OrganisedPropertyGroup,
|
||||||
|
PropertyGroupContainer
|
||||||
|
} from '../../interfaces/content-metadata.interfaces';
|
||||||
|
|
||||||
describe('LayoutOrientedConfigService', () => {
|
describe('LayoutOrientedConfigService', () => {
|
||||||
|
|
||||||
@ -269,7 +274,32 @@ describe('LayoutOrientedConfigService', () => {
|
|||||||
expectations: [
|
expectations: [
|
||||||
{ title: 'First group', properties: [property3, property4, property2] }
|
{ title: 'First group', properties: [property3, property4, property2] }
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Custom Title',
|
||||||
|
config: [
|
||||||
|
{
|
||||||
|
title: 'First group',
|
||||||
|
items: [
|
||||||
|
{ aspect: 'zestiria', properties: 'property3' },
|
||||||
|
{ type: 'berseria', properties: ['property2', <any> { title: 'Custom title', name: 'property1' }] },
|
||||||
|
{ type: 'otherTales', properties: [<any> { title: 'Custom title', name: 'property5' }] }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
expectations: [
|
||||||
|
{
|
||||||
|
title: 'First group',
|
||||||
|
properties: [
|
||||||
|
property3,
|
||||||
|
property2,
|
||||||
|
<Property> { name: 'property1', title: 'Custom title', editable: true },
|
||||||
|
<Property> { name: 'property5', title: 'Custom title', editable: true }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
testCases.forEach((testCase) => {
|
testCases.forEach((testCase) => {
|
||||||
@ -287,7 +317,7 @@ describe('LayoutOrientedConfigService', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
expectation.properties.forEach((property, j) => {
|
expectation.properties.forEach((property, j) => {
|
||||||
expect(organisedPropertyGroups[i].properties[j]).toBe(property, `Property should match ${property.name}`);
|
expect(organisedPropertyGroups[i].properties[j]).toEqual(property, `Property should match ${property.name}`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -41,7 +41,10 @@ export class LayoutOrientedConfigService implements ContentMetadataConfig {
|
|||||||
const organisedPropertyGroup = layoutBlocks.map((layoutBlock) => {
|
const organisedPropertyGroup = layoutBlocks.map((layoutBlock) => {
|
||||||
const flattenedItems = this.flattenItems(layoutBlock.items),
|
const flattenedItems = this.flattenItems(layoutBlock.items),
|
||||||
properties = flattenedItems.reduce((props, explodedItem) => {
|
properties = flattenedItems.reduce((props, explodedItem) => {
|
||||||
let property = getProperty(propertyGroups, explodedItem.groupName, explodedItem.propertyName) || [];
|
const isProperty = typeof explodedItem.property === 'object';
|
||||||
|
const propertyName = isProperty ? explodedItem.property.name : explodedItem.property;
|
||||||
|
let property = getProperty(propertyGroups, explodedItem.groupName, propertyName) || [];
|
||||||
|
if (isProperty) { property = this.setPropertyTitle(property, explodedItem.property); }
|
||||||
property = this.setEditableProperty(property, explodedItem);
|
property = this.setEditableProperty(property, explodedItem);
|
||||||
return props.concat(property);
|
return props.concat(property);
|
||||||
}, []);
|
}, []);
|
||||||
@ -101,13 +104,20 @@ export class LayoutOrientedConfigService implements ContentMetadataConfig {
|
|||||||
return propertyGroup;
|
return propertyGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private setPropertyTitle(item: Property | Property[], property: Property): Property | Property[] {
|
||||||
|
if (!Array.isArray(item)) {
|
||||||
|
return { ...item, ...(item.name === property.name && !!property.title) && { title: property.title } };
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
private flattenItems(items) {
|
private flattenItems(items) {
|
||||||
return items.reduce((accumulator, item) => {
|
return items.reduce((accumulator, item) => {
|
||||||
const properties = Array.isArray(item.properties) ? item.properties : [item.properties];
|
const properties = Array.isArray(item.properties) ? item.properties : [item.properties];
|
||||||
const flattenedProperties = properties.map((propertyName) => {
|
const flattenedProperties = properties.map((property) => {
|
||||||
return {
|
return {
|
||||||
groupName: item.aspect || item.type,
|
groupName: item.aspect || item.type,
|
||||||
propertyName,
|
property,
|
||||||
editable: item.editable
|
editable: item.editable
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -461,7 +461,31 @@
|
|||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
"description": "list of type properties",
|
"description": "list of type properties",
|
||||||
"type": "array"
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"title",
|
||||||
|
"name"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"title": {
|
||||||
|
"description": "Title of aspect properties",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"description": "Name of aspect properties",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user