Browse Source

Update color trait

refactor-traits
Artur Arseniev 7 years ago
parent
commit
cdb15719ec
  1. 2
      dist/css/grapes.min.css
  2. 2
      src/styles/scss/_gjs_traits.scss
  3. 20
      src/trait_manager/view/TraitColorView.js
  4. 6
      src/trait_manager/view/TraitView.js

2
dist/css/grapes.min.css

File diff suppressed because one or more lines are too long

2
src/styles/scss/_gjs_traits.scss

@ -10,7 +10,7 @@
&label { &label {
&-wrp { &-wrp {
width: 30%; min-width: 30%;
} }
} }

20
src/trait_manager/view/TraitColorView.js

@ -2,13 +2,15 @@ import TraitView from './TraitView';
import InputColor from 'domain_abstract/ui/InputColor'; import InputColor from 'domain_abstract/ui/InputColor';
export default TraitView.extend({ export default TraitView.extend({
templateInput: '',
/** /**
* Returns input element * Returns input element
* @return {HTMLElement} * @return {HTMLElement}
* @private * @private
*/ */
getInputEl() { getInputEl() {
if (!this.$input) { if (!this.input) {
const model = this.model; const model = this.model;
const value = this.getModelValue(); const value = this.getModelValue();
const inputColor = new InputColor({ const inputColor = new InputColor({
@ -18,22 +20,10 @@ export default TraitView.extend({
ppfx: this.ppfx ppfx: this.ppfx
}); });
const input = inputColor.render(); const input = inputColor.render();
this.$input = input.colorEl;
input.setValue(value, { fromTarget: 1 }); input.setValue(value, { fromTarget: 1 });
this.input = input; this.input = input.el;
} }
return this.$input.get(0); return this.input;
},
/**
* Renders input
* @private
* */
renderField() {
if (!this.$input) {
this.getInputEl();
this.$el.append(this.input.el);
}
} }
}); });

6
src/trait_manager/view/TraitView.js

@ -191,14 +191,12 @@ export default Backbone.View.extend({
render() { render() {
const { $el, pfx, ppfx, model } = this; const { $el, pfx, ppfx, model } = this;
const { noLabel } = model.attributes; const { noLabel, type } = model.attributes;
const cls = `${pfx}trait`; const cls = `${pfx}trait`;
this.$input = null; this.$input = null;
let tmpl = `<div class="${cls}"> let tmpl = `<div class="${cls}">
${!noLabel ? `<div class="${ppfx}label-wrp" data-label></div>` : ''} ${!noLabel ? `<div class="${ppfx}label-wrp" data-label></div>` : ''}
<div class="${ppfx}field-wrp ${ppfx}field-wrp--${model.get( <div class="${ppfx}field-wrp ${ppfx}field-wrp--${type}" data-input>
'type'
)}" data-input>
${this.templateInput && this.templateInput()} ${this.templateInput && this.templateInput()}
</div> </div>
</div>`; </div>`;

Loading…
Cancel
Save