Browse Source

Set id to traits

pull/3073/head
Artur Arseniev 5 years ago
parent
commit
fe8cefe711
  1. 1
      src/trait_manager/model/Trait.js
  2. 4
      src/trait_manager/view/TraitView.js

1
src/trait_manager/model/Trait.js

@ -22,6 +22,7 @@ export default Backbone.Model.extend({
const target = this.get('target'); const target = this.get('target');
const name = this.get('name'); const name = this.get('name');
const changeProp = this.get('changeProp'); const changeProp = this.get('changeProp');
!this.get('id') && this.set('id', name);
if (target) { if (target) {
this.target = target; this.target = target;

4
src/trait_manager/view/TraitView.js

@ -258,7 +258,7 @@ export default Backbone.View.extend({
render() { render() {
const { $el, pfx, ppfx, model } = this; const { $el, pfx, ppfx, model } = this;
const { type } = model.attributes; const { type, id } = model.attributes;
const hasLabel = this.hasLabel && this.hasLabel(); const hasLabel = this.hasLabel && this.hasLabel();
const cls = `${pfx}trait`; const cls = `${pfx}trait`;
this.$input = null; this.$input = null;
@ -277,7 +277,7 @@ export default Backbone.View.extend({
$el.empty().append(tmpl); $el.empty().append(tmpl);
hasLabel && this.renderLabel(); hasLabel && this.renderLabel();
this.renderField(); this.renderField();
this.el.className = `${cls}__wrp`; this.el.className = `${cls}__wrp ${cls}__wrp-${id}`;
this.postUpdate(); this.postUpdate();
this.onRender(this.getClbOpts()); this.onRender(this.getClbOpts());
return this; return this;

Loading…
Cancel
Save