Some more options for mj-mosaico-property element in Mosaico Templates.

This commit is contained in:
Tomas Bures 2020-07-24 22:38:37 +02:00
parent ca615a86a5
commit 676f20bfa9

View file

@ -82,28 +82,30 @@ class MjMosaicoProperty extends HeadComponent {
static allowedAttributes = { static allowedAttributes = {
'property-id': 'string', 'property-id': 'string',
label: 'string', label: 'string',
type: 'enum(image,link,visible)' options: 'string',
values: 'string',
type: 'enum(image,link,visible,properties,select)'
}; };
handler() { handler() {
const { add } = this.context; const { add } = this.context;
let properties = null; let extra = '';
let extend = null;
const type = this.getAttribute('type'); const type = this.getAttribute('type');
if (type === 'image') { if (type === 'image') {
properties = 'src url alt'; extra = `${extra} properties: src url alt;`;
} else if (type === 'link') { } else if (type === 'link') {
properties = 'text url'; extra = `${extra} properties: text url;`;
} else if (type === 'visible') { } else if (type === 'visible') {
extend = 'visible'; extra = `${extra} extend: visible;`;
} else if (type === 'properties') {
extra = `${extra} properties: ${this.getAttribute('values')};`;
} else if (type === 'select') {
extra = `${extra} widget: select; options: ${this.getAttribute('options')};`;
} }
const propertiesStr = properties ? ` properties: ${properties}` : ''; add('style', ` @supports -ko-blockdefs { ${this.getAttribute('property-id')} { label: ${this.getAttribute('label')};${extra} } }`);
const extendStr = extend ? ` extend: ${extend}` : '';
add('style', ` @supports -ko-blockdefs { ${this.getAttribute('property-id')} { label: ${this.getAttribute('label')};${propertiesStr}${extendStr} } }`);
} }
} }