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;
// ======= 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 {
if (this.hotValue) {
return this.hotValue;
@ -105,7 +113,7 @@ export class SettingField extends SettingPropEntry implements SettingEntry {
return this.transducer.toHot(v);
}
setHotValue(data: any) {
setHotValue(data: any, options?: any) {
this.hotValue = data;
const v = this.transducer.toNative(data);
if (this.isUseVariable()) {
@ -114,10 +122,16 @@ export class SettingField extends SettingPropEntry implements SettingEntry {
type: 'JSExpression',
value: ov.value,
mock: v,
});
}, false, false, options);
} 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();
}

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') {
this.parent.setPropValue(this.name, val);
}
if (!extraOptions) {
extraOptions = {};
}
const { setValue } = this.extraProps;
if (setValue) {
if (setValue && !extraOptions.disableMutator) {
setValue(this, val);
}
}