Browse Source

Move TraitCheckboxView to TS

ts-style-manager
Artur Arseniev 4 years ago
parent
commit
3208fe44c6
  1. 2
      src/trait_manager/model/Trait.ts
  2. 12
      src/trait_manager/view/TraitCheckboxView.ts

2
src/trait_manager/model/Trait.ts

@ -35,6 +35,8 @@ export interface TraitProperties {
changeProp?: boolean; changeProp?: boolean;
attributes?: Record<string, any>; attributes?: Record<string, any>;
valueTrue?: string;
valueFalse?: string;
min?: number; min?: number;
max?: number; max?: number;
unit?: string; unit?: string;

12
src/trait_manager/view/TraitCheckboxView.js → src/trait_manager/view/TraitCheckboxView.ts

@ -20,8 +20,8 @@ export default class TraitCheckboxView extends TraitView {
this.model.set('value', this.getCheckedValue(value)); this.model.set('value', this.getCheckedValue(value));
} }
getCheckedValue(checked) { getCheckedValue(checked: boolean) {
let result = checked; let result: boolean | string = checked;
const { valueTrue, valueFalse } = this.model.attributes; const { valueTrue, valueFalse } = this.model.attributes;
if (result && !isUndefined(valueTrue)) { if (result && !isUndefined(valueTrue)) {
@ -40,15 +40,15 @@ export default class TraitCheckboxView extends TraitView {
* @return {HTMLElement} * @return {HTMLElement}
* @private * @private
*/ */
getInputEl(...args) { getInputEl(...args: any) {
const toInit = !this.$input; const toInit = !this.$input;
const el = TraitView.prototype.getInputEl.apply(this, args); const el = TraitView.prototype.getInputEl.apply(this, args);
if (toInit) { if (toInit) {
let checked, targetValue; let checked, targetValue;
const { model, target } = this; const { model, target } = this;
const { valueTrue, valueFalse } = model.attributes; const { valueFalse } = model.attributes;
const name = model.get('name'); const name = model.getName();
if (model.get('changeProp')) { if (model.get('changeProp')) {
checked = target.get(name); checked = target.get(name);
@ -62,7 +62,7 @@ export default class TraitCheckboxView extends TraitView {
checked = !1; checked = !1;
} }
el.checked = checked; el!.checked = checked;
} }
return el; return el;
Loading…
Cancel
Save