Merge branch 'feat/ui-1.1.0' into sf-site-migration/ui

This commit is contained in:
haitaoo 2023-04-10 17:22:48 +08:00
commit 09e4ee10cb
2 changed files with 8 additions and 11 deletions

View File

@ -2,6 +2,7 @@ import {
ForwardRefRenderFunction,
forwardRef,
useImperativeHandle,
useEffect,
} from 'react';
import { Form, Button, Stack } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
@ -155,16 +156,10 @@ const SchemaForm: ForwardRefRenderFunction<IRef, IProps> = (
*/
const setDefaultValueAsDomBehaviour = () => {
keys.forEach((k) => {
const formVal = formData[k]?.value;
const fieldVal = formData[k]?.value;
const metaProp = properties[k];
const uiCtrl = uiSchema[k]?.['ui:widget'];
if (
!metaProp ||
!uiCtrl ||
formVal ||
formVal === 0 ||
formVal === false
) {
if (!metaProp || !uiCtrl || fieldVal !== undefined) {
return;
}
if (uiCtrl === 'select' && metaProp.enum?.[0] !== undefined) {
@ -176,7 +171,9 @@ const SchemaForm: ForwardRefRenderFunction<IRef, IProps> = (
}
});
};
useEffect(() => {
setDefaultValueAsDomBehaviour();
}, [formData]);
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const { name, value } = e.target;

View File

@ -33,7 +33,7 @@ const Smtp: FC = () => {
description: t('smtp_host.text'),
},
encryption: {
type: 'boolean',
type: 'string',
title: t('encryption.label'),
description: t('encryption.text'),
enum: ['SSL', ''],
@ -179,7 +179,7 @@ const Smtp: FC = () => {
}, [setting]);
useEffect(() => {
if (formData.smtp_authentication.value === '') {
if (!/true|false/.test(formData.smtp_authentication.value)) {
return;
}
if (formData.smtp_authentication.value) {