ADF 2.1.0 has been released. This is a minor release with some interesting new features are worth to detail. One of them is the new Metadata component, which is the subject of this article.
This post will be a practical guide for the ADF Metadata component, how to install it, use it and configure it.
The purpose of the component is to display the metadata belonging to given node. Until now, the component was capable of displaying and making the basic properties editable, but with the latest enhancements, all of the system wide and custom aspects related to a particular node can be displayed and edited.
The component is part of the content-services package, so for using it, we have to import either the ContentModule or the component's module (ContentMetadataModule) to our application. In most of the cases we already have the ContentModule imported, so we show an example following this scenario.
import { CoreModule } from '@alfresco/adf-core';
import { ContentModule } from '@alfresco/adf-content-services';
@NgModule({
imports: [
...
CoreModule,
ContentModule,
...
],
declarations: [ ... ],
providers: [ ... ],
bootstrap: [AppComponent]
})
export class AppModule {}
Using the component is quite straightforward. There are 3 input parameters:
<adf-content-metadata-card [node]="node"></adf-content-metadata-card>
<adf-content-metadata-card
[displayEmpty]="true"
[preset]="my-custom-preset"
[node]="node">
</adf-content-metadata-card>
The configuration happens through the application configuration file. By default, if there is no configuration for the component, the component will show every aspects and properties belonging to the node. Usually, this is not the expected behavior, since all the metadata will be shown this way, which would be hidden otherwise to decrease the unnecessary noise.
But for debugging purposes and to see the complete set of available metadata, this is the easiest way to list them.
Not having a configuration for the component is equivalent to have the following configuration:
"content-metadata": {
"presets": {
"default": "*"
}
}
As it can be seen in the example, presets can be defined for the content-metadata component. Each preset has a name, in the configuration above we have only one preset, which is called default. This name is the input parameter for the adf-content-metadata-card component.
A preset can be either the wildcard asterisk string ("*") as above or an object where the keys are the name of aspects.
The object's values are either the wildcard asterisk strings ("*") meaning all of the aspect's properties should be shown or string arrays, listing the name of aspect's properties to be shown.
In the configuration below, we define two presets:
"content-metadata": {
"presets": {
"default": "*",
"kitten-images": {
"kitten:vet-records": "*",
"exif:exif": [ "exif:xResolution", "exif:yResolution"]
}
}
}
For further details about the component and configuration, see the documentation of it.