-
Notifications
You must be signed in to change notification settings - Fork 5
Storing and Fetching MetaData in Zimlets
Saket Patel edited this page May 7, 2020
·
5 revisions
If you want to set custom meta data for an item so you can do it by using withSetCustomMetaData and withGetCustomMetaData decorators. These decorators are using SetCustomMetadata and GetCustomMetadata SOAP API and has client side GraphQL implementation.
Use withSetCustomMetaData
decorator which trigger SetCustomMetadataRequest to set custom meta to an item.
import { withSetCustomMetaData } from '../../graphql-decorators/custom-metadata';
@withSetCustomMetaData() // This will provide you setCustomMetadata method in props to set custom meta
class FancyZimlet extends Component {
handleClick = () => {
this.props.setCustomMetadata({
id: "1234", // Item id on which you want to set CustomMetaData,
section: "zwc:sectionName", // Section name under which you want to set CustomMetaData
attrs: [
{
key: "metaKey",
value:"metaValue"
},
...
]
})
}
render() {
return (
<button onClick={this.handleClick} />
)
}
}
Use withGetCustomMetaData
decorator which trigger SetCustomMetadataRequest to get defined custom meta with an item.
import { withGetCustomMetaData } from '../../graphql-decorators/custom-metadata';
@withGetCustomMetaData({
id: "1234" // Item id ,
section: "zwc:sectionName" // Section name under which your meta being defined.
}, ({ data: { getCustomMetadata } }) => {
const customMetaInfo = get(getCustomMetadata, 'meta.0._attrs');
return {
customMetaInfo
}
})
- Home
- Client Tool
- Getting Started
- Creating Your Zimlet
- Zimlet Design Patterns
- Advanced