| Conditions | 13 |
| Paths | 432 |
| Total Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
Complex classes like AbstracCheckbox.js ➔ ... ➔ ??? often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
| 1 | |||
| 12 | constructor(params = {}) { |
||
| 13 | |||
| 14 | super(); |
||
| 15 | |||
| 16 | this.value = params.value; |
||
| 17 | if (isUnd(this.value) || !this.value.subscribe) |
||
| 18 | { |
||
| 19 | this.value = ko.observable(isUnd(this.value) ? false : !!this.value); |
||
| 20 | } |
||
| 21 | |||
| 22 | this.enable = params.enable; |
||
| 23 | if (isUnd(this.enable) || !this.enable.subscribe) |
||
| 24 | { |
||
| 25 | this.enable = ko.observable(isUnd(this.enable) ? true : !!this.enable); |
||
| 26 | } |
||
| 27 | |||
| 28 | this.disable = params.disable; |
||
| 29 | if (isUnd(this.disable) || !this.disable.subscribe) |
||
| 30 | { |
||
| 31 | this.disable = ko.observable(isUnd(this.disable) ? false : !!this.disable); |
||
| 32 | } |
||
| 33 | |||
| 34 | this.label = params.label || ''; |
||
| 35 | this.inline = isUnd(params.inline) ? false : params.inline; |
||
| 36 | |||
| 37 | this.readOnly = isUnd(params.readOnly) ? false : !!params.readOnly; |
||
| 38 | this.inverted = isUnd(params.inverted) ? false : !!params.inverted; |
||
| 39 | |||
| 40 | this.labeled = !isUnd(params.label); |
||
| 41 | this.labelAnimated = !!params.labelAnimated; |
||
| 42 | } |
||
| 43 | |||
| 53 |