Merge branch 'preset-vision/0.9.0' of gitlab.alibaba-inc.com:ali-lowcode/ali-lowcode-engine into preset-vision/0.9.0

This commit is contained in:
kangwei 2020-05-09 17:34:15 +08:00
commit ea5a5d63e8
2 changed files with 23 additions and 2 deletions

View File

@ -142,8 +142,19 @@ export default class MixedSetter extends Component<{
// dirty fix vision variable setter logic
private hasVariableSetter = this.setters.some((item) => item.name === 'VariableSetter');
private getDefaultValueWhenUseSetter(oldUsed?: string): any {
if (this.used === 'I18nSetter') {
return {
type: 'i18n',
zh_CN: '',
en_US: '',
}
}
}
private useSetter = (name: string) => {
const { field, onChange } = this.props;
const oldUsed = this.used;
if (name === 'VariableSetter') {
const setterComponent = getSetter('VariableSetter')?.component as any;
if (setterComponent && setterComponent.isPopup) {
@ -156,7 +167,10 @@ export default class MixedSetter extends Component<{
}
const setter = this.setters.find((item) => item.name === name);
this.used = name;
if (setter) {
const newValue = this.getDefaultValueWhenUseSetter(oldUsed);
if (newValue !== undefined) {
onChange && onChange(newValue);
} else if (setter) {
this.handleInitial(setter);
}
};

View File

@ -369,7 +369,14 @@ export function upgradePropConfig(config: OldPropConfig, addInitial: AddIntial)
},
];
if (allowTextInput !== false) {
setters.unshift('I18nSetter');
setters.unshift({
componentName: 'I18nSetter',
title: {
'type': 'i18n',
'zh-CN': '国际化输入',
'en-US': 'Internationalized Input'
},
});
}
if (supportVariable) {
setters.push('VariableSetter');