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

View File

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