|
@@ -15,7 +15,7 @@ import {PropertyDescription} from "../../PropertyDescription";
|
|
|
export default function () {
|
|
|
|
|
|
const cc = Ext.form.field.Checkbox.prototype.constructor
|
|
|
- const {initComponent, getValue} = Ext.form.field.Checkbox.prototype
|
|
|
+ const {initComponent, getValue, setValue} = Ext.form.field.Checkbox.prototype
|
|
|
Ext.form.field.Checkbox.override({
|
|
|
constructor(config) {
|
|
|
const newConfig = _.defaultsDeep({
|
|
@@ -27,10 +27,41 @@ export default function () {
|
|
|
},
|
|
|
|
|
|
getValue() {
|
|
|
+ const {inputValue, uncheckedValue} = this
|
|
|
const ov = getValue.call(this)
|
|
|
- const nv = ov ? 1 : 0
|
|
|
- // console.log('cc:', nv, ov)
|
|
|
- return nv
|
|
|
+ // const ov = this.getRawValue()
|
|
|
+ return (ov ? inputValue : uncheckedValue)
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ setValue(nv) {
|
|
|
+ const me = this
|
|
|
+ const {checkedValue, uncheckedValue} = this
|
|
|
+ let value
|
|
|
+ if (nv === checkedValue) {
|
|
|
+ value = true
|
|
|
+ } else if (nv === uncheckedValue) {
|
|
|
+ value = false
|
|
|
+ } else {
|
|
|
+ value = !!nv
|
|
|
+ }
|
|
|
+
|
|
|
+ // me.setRawValue(value)
|
|
|
+ // me.checked = value
|
|
|
+ // return me.mixins.field.setValue.call(me, value);
|
|
|
+ setValue.call(this, value)
|
|
|
+ },
|
|
|
+
|
|
|
+ updateCheckedCls: function (checked) {
|
|
|
+ const me = this;
|
|
|
+ const {uncheckedValue, checkedValue} = this
|
|
|
+ checked = checked != null ? checked : me.getValue();
|
|
|
+ if (checked === uncheckedValue) {
|
|
|
+ checked = false
|
|
|
+ } else if (checked === checkedValue) {
|
|
|
+ checked = true
|
|
|
+ }
|
|
|
+ me[checked ? 'addCls' : 'removeCls'](me.checkedCls);
|
|
|
},
|
|
|
|
|
|
initComponent() {
|