Browse Source

Update getLabel with locale option

up-style-manager
Artur Arseniev 4 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.
* @param {Object} [opts={}] Options
* @param {Boolean} [opts.locale=true] Use the locale string from i18n module
* @returns {String}
*/
getLabel() {
return this.get('name');
getLabel(opts = {}) {
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) {
const { pfx, em } = this;
const { pfx } = this;
const { parent } = model;
const { icon = '', info = '', id, name } = model.attributes;
const label = (em && em.t(`styleManager.properties.${id}`)) || name;
const { icon = '', info = '' } = model.attributes;
const label = model.getLabel();
return `
<span class="${pfx}icon ${icon}" title="${info}">

Loading…
Cancel
Save