Browse Source

Add getOptionId

up-style-manager
Artur Arseniev 4 years ago
parent
commit
da5b5fda1d
  1. 11
      src/style_manager/model/PropertyRadio.js
  2. 2
      src/style_manager/view/PropertyRadioView.js

11
src/style_manager/model/PropertyRadio.js

@ -40,6 +40,15 @@ export default class PropertyRadio extends Property {
return this;
}
/**
* Get the option id from the option object.
* @param {Object} option Option object
* @returns {String} Option id
*/
getOptionId(option) {
return option.id || option.value;
}
/**
* Get option label.
* @param {String} id Option id
@ -50,7 +59,7 @@ export default class PropertyRadio extends Property {
getOptionLabel(id, opts = {}) {
const { locale = true } = opts;
const options = this.getOptions();
const option = options.filter(o => o.id === id || o.value === id)[0] || {};
const option = options.filter(o => this.getOptionId(o) === id)[0] || {};
const label = option.label || option.name || id;
const propId = this.getId();
return (

2
src/style_manager/view/PropertyRadioView.js

@ -25,7 +25,7 @@ export default PropertyView.extend({
const cls = opt.className
? `${opt.className} ${pfx}icon ${itemCls}`
: '';
const id = opt.id || opt.value;
const id = model.getOptionId(opt);
const elId = `${prop}-${id}-${cid}`;
const labelEl = cls ? '' : model.getOptionLabel(id);
const titleAttr = opt.title ? `title="${opt.title}"` : '';

Loading…
Cancel
Save