lib.xp.examples.schema.createPart.js Maven / Gradle / Ivy
var schemaLib = require('/lib/xp/schema');
var assert = require('/lib/xp/testing');
/* global log*/
let resource = `
Virtual Part
My Part Description
false false
`;
// BEGIN
// Create virtual part.
var result = schemaLib.createComponent({
key: 'myapp:mypart',
type: 'PART',
resource
});
log.info('Created part: ' + result.key);
// END
assert.assertJsonEquals({
key: 'myapp:mypart',
displayName: 'Virtual Part',
displayNameI18nKey: 'key.display-name',
description: 'My Part Description',
descriptionI18nKey: 'key.description',
componentPath: 'myapp:/site/parts/mypart',
modifiedTime: '2021-09-25T10:00:00Z',
resource: '\n \n Virtual Part \n My Part Description \n \n \n false false \n \n \n ',
type: 'PART',
form: [
{
'formItemType': 'Input',
'name': 'width',
'label': 'Column width',
'helpText': 'key.help-text',
'maximize': true,
'inputType': 'Double',
'occurrences': {
'maximum': 1,
'minimum': 0
},
'config': {}
},
{
'formItemType': 'InlineMixin',
'name': 'myapplication:link-urls'
}
],
config: {
'input': [{
'value': '', '@name': 'width', '@type': 'Double'
}]
}
}, result);