fix listsetter bugs

This commit is contained in:
kangwei 2020-06-15 22:24:41 +08:00
parent 6a6dd2ee24
commit 703c9fa6d4
2 changed files with 23 additions and 6 deletions

View File

@ -91,8 +91,16 @@ export class SettingField extends SettingPropEntry implements SettingEntry {
} }
private hotValue: any; private hotValue: any;
// ======= compatibles for vision ====== // ======= compatibles for vision ======
setValue(val: any, isHotValue?: boolean, force?: boolean, extraOptions?: any) {
if (isHotValue) {
this.setHotValue(val, extraOptions);
return;
}
super.setValue(val, false, false, extraOptions);
}
getHotValue(): any { getHotValue(): any {
if (this.hotValue) { if (this.hotValue) {
return this.hotValue; return this.hotValue;
@ -105,7 +113,7 @@ export class SettingField extends SettingPropEntry implements SettingEntry {
return this.transducer.toHot(v); return this.transducer.toHot(v);
} }
setHotValue(data: any) { setHotValue(data: any, options?: any) {
this.hotValue = data; this.hotValue = data;
const v = this.transducer.toNative(data); const v = this.transducer.toNative(data);
if (this.isUseVariable()) { if (this.isUseVariable()) {
@ -114,10 +122,16 @@ export class SettingField extends SettingPropEntry implements SettingEntry {
type: 'JSExpression', type: 'JSExpression',
value: ov.value, value: ov.value,
mock: v, mock: v,
}); }, false, false, options);
} else { } else {
this.setValue(v); this.setValue(v, false, false, options);
} }
// dirty fix list setter
if (Array.isArray(data) && data[0] && data[0].__sid__) {
return;
}
this.valueChange(); this.valueChange();
} }

View File

@ -144,12 +144,15 @@ export class SettingPropEntry implements SettingEntry {
/** /**
* *
*/ */
setValue(val: any) { setValue(val: any, isHotValue?: boolean, force?: boolean, extraOptions?: any) {
if (this.type === 'field') { if (this.type === 'field') {
this.parent.setPropValue(this.name, val); this.parent.setPropValue(this.name, val);
} }
if (!extraOptions) {
extraOptions = {};
}
const { setValue } = this.extraProps; const { setValue } = this.extraProps;
if (setValue) { if (setValue && !extraOptions.disableMutator) {
setValue(this, val); setValue(this, val);
} }
} }