metadata.panel.view
MetadataPanelView : d2/sdk/widgets/metadata.panel/metadata.panel.view
Interface for all custom metadata views. This is an extension of Marionette Layout View
Extends: Marionette.LayoutView
Example (A new metadata view metadata.helloworld.view.js could be defined as)
define([
'd2/sdk/widgets/metadata.panel/metadata.panel.view'
], function (MetadataPanelView) {
'use strict';
var helloworldViewTemplate = '<script type="text/html">' +
'<h3 style="\n' +
' margin-top: 48px;\n' +
' padding: 16px;\n' +
' font-size: 24px;\n' +
' color: red;\n' +
'">Hello World !</h3>' +
'</script>';
var MetadataHelloworldView = MetadataPanelView.extend({
template: helloworldViewTemplate
}, {
enabled: function () {
// This metadata view will be shown or hidden based on whether
// the enabled function returns true or false
return true;
}
});
return MetadataHelloworldView;
});
Example (Suppose we do not want to show this metadata view for task, workflow step, repository, folders and cabinets, we can write a simple equality check for node type using constants utils from sdk)
enabled: function (options) {
var nodeType = options.node && options.node.get('type');
if (nodeType === constants.Types.TASK ||
nodeType === constants.Types.WORKFLOW_STEP ||
nodeType === constants.Types.REPOSITORY ||
nodeType === constants.Types.FOLDER ||
nodeType === constants.Types.CABINET) {
return false;
}
return true;
}
Example (To register this metadata view with metadata panel views array, add the entry in extension.json as)
{
"d2/sdk/widgets/metadata.panel/metadata.panel.views": {
"extensions": {
"mybundle": [
"mybundle/extensions/metadata.panel.views"
]
}
}
}
Example (The metadata.panel.views.js is defined as below. Optionally a sequence value(greater than 1000) can be passed to the metadata view entry to specify their order in the dropdown)
define([
'mybundle/widgets/metadata/panels/helloworld/metadata.helloworld.view'
], function(MetadataHelloworldView){
'use strict';
// Array of metadata views added to the plugin
return [
// Each metadata view entry should have a name, title to be shown for the dropdown option
// and content view to be shown on metadata panel when this view is selected
// Incase multiple metadata views(panels) are added in a plugin or multiple plugins with panels are
// deployed, then the order of these panels in dropdown are determined at runtime.
// If panels are to be placed in specific sequence in dropdown,
// then add a numeric value greater than 1000 for sequence attribute(values upto 1000 are used internally).
// The panels should appear in ascending order of their sequence in dropdown
{
name: 'helloworld', // The metadata view name, it has to be a unique string
title: 'Hello World',
contentView: MetadataHelloworldView,
sequence: 1010 // The sequence value determines the order in which these panels appear in the dropdown
}
// Additional metadata views can also be registered in this array
];
});
- MetadataPanelView :
d2/sdk/widgets/metadata.panel/metadata.panel.view
- instance
- static
- .enabled([options]) ⇒
boolean
- .enabled([options]) ⇒
metadataPanelView.options : Object
Holder of parameters passed during metadata view construction.
Kind: instance property of MetadataPanelView
metadataPanelView.model : NodeModel
Selected documentum object reference. It holds information like object id, name, type etc.
Kind: instance property of MetadataPanelView
See: NodeModel
MetadataPanelView.enabled([options]) ⇒ boolean
Decides whether to show or hide dropdown option for this metadata view based on the return value(true or false).
Kind: static method of MetadataPanelView
Param | Type | Description |
---|---|---|
[options] | Object | The options object will have the selected documentum object and context details. The options.node will have the selected documentum object reference and it contains the object information like object id, name, type etc. Conditions can be added based on these attributes to return true/false (show/hide the dropdown option for the selected documentum object). |