Browse Source

Update getLabel with locale option

up-style-manager
Artur Arseniev 5 years ago
parent
commit
17faf095e9
  1. 9
      src/style_manager/model/Property.js
  2. 6
      src/style_manager/view/PropertyView.js

9
src/style_manager/model/Property.js

@ -67,10 +67,15 @@ export default class Property extends Model {
/** /**
* Get property label. * Get property label.
* @param {Object} [opts={}] Options
* @param {Boolean} [opts.locale=true] Use the locale string from i18n module
* @returns {String} * @returns {String}
*/ */
getLabel() { getLabel(opts = {}) {
return this.get('name'); const { locale = true } = opts;
const id = this.getId();
const name = this.get('name');
return (locale && this.em?.t(`styleManager.properties.${id}`)) || name;
} }
/** /**

6
src/style_manager/view/PropertyView.js

@ -16,10 +16,10 @@ export default Backbone.View.extend({
}, },
templateLabel(model) { templateLabel(model) {
const { pfx, em } = this; const { pfx } = this;
const { parent } = model; const { parent } = model;
const { icon = '', info = '', id, name } = model.attributes; const { icon = '', info = '' } = model.attributes;
const label = (em && em.t(`styleManager.properties.${id}`)) || name; const label = model.getLabel();
return ` return `
<span class="${pfx}icon ${icon}" title="${info}"> <span class="${pfx}icon ${icon}" title="${info}">

Loading…
Cancel
Save