Browse Source

Update checkbox trait

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

2
dist/css/grapes.min.css

File diff suppressed because one or more lines are too long

5
src/styles/scss/_gjs_inputs.scss

@ -191,8 +191,10 @@
/* ??? */
.#{$app-prefix}field-checkbox {
padding: 0;
width: auto !important;
width: 17px;
height: 17px;
display: block;
cursor: pointer;
input {
display: none;
@ -348,7 +350,6 @@
height: 14px;
margin: 0 5px;
width: 6px;
cursor: pointer;
}
.#{$app-prefix}add-trasp {

6
src/trait_manager/view/TraitCheckboxView.js

@ -5,8 +5,8 @@ export default TraitView.extend({
appendInput: 0,
templateInput() {
const { ppfx } = this;
return `<label data-input>
const { ppfx, clsField } = this;
return `<label class="${clsField}" data-input>
<i class="${ppfx}chk-icon"></i>
</label>`;
},
@ -16,7 +16,7 @@ export default TraitView.extend({
* @private
*/
onChange() {
const value = this.getInputEl().checked;
const value = this.getInputElem().checked;
this.model.set('value', this.getCheckedValue(value));
},

20
src/trait_manager/view/TraitView.js

@ -50,7 +50,7 @@ export default Backbone.View.extend({
* @private
*/
onChange() {
this.model.set('value', this.getInputEl().value);
this.model.set('value', this.getInputElem().value);
},
getValueForTarget() {
@ -58,7 +58,8 @@ export default Backbone.View.extend({
},
setInputValue(value) {
this.getInputEl().value = value;
const el = this.getInputElem();
el && (el.value = value);
},
/**
@ -66,15 +67,11 @@ export default Backbone.View.extend({
* @private
*/
onValueChange(model, value, opts = {}) {
const mod = this.model;
const trg = this.target;
const name = mod.get('name');
if (opts.fromTarget) {
this.setInputValue(mod.get('value'));
this.setInputValue(model.get('value'));
} else {
const value = this.getValueForTarget();
mod.setTargetValue(value, opts);
const val = this.getValueForTarget();
model.setTargetValue(val, opts);
}
},
@ -149,6 +146,11 @@ export default Backbone.View.extend({
return this.$input.get(0);
},
getInputElem() {
const { input, $input } = this;
return input || ($input && $input.get(0));
},
getModelValue() {
let value;
const model = this.model;

Loading…
Cancel
Save