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