Merge remote-tracking branch 'github/feat/ui-1.1.0' into feature-plugin

This commit is contained in:
LinkinStars
2023-03-17 17:21:45 +08:00
5 changed files with 23 additions and 13 deletions
+8 -8
View File
@@ -20,7 +20,6 @@ export interface JSONSchema {
[key: string]: {
type: 'string' | 'boolean' | 'number';
title: string;
label?: string;
description?: string;
enum?: Array<string | boolean | number>;
enumNames?: string[];
@@ -61,7 +60,9 @@ export interface UploadOptions extends BaseUIOptions {
imageType?: Type.UploadType;
}
export interface SwitchOptions extends BaseUIOptions {}
export interface SwitchOptions extends BaseUIOptions {
label?: string;
}
export interface TimezoneOptions extends BaseUIOptions {
placeholder?: string;
@@ -172,7 +173,6 @@ const SchemaForm: ForwardRefRenderFunction<IRef, IProps> = (
isInvalid: false,
value: metaProp.enum?.[0],
};
console.log('formData[k]: ', k, formData[k]);
}
});
};
@@ -348,13 +348,13 @@ const SchemaForm: ForwardRefRenderFunction<IRef, IProps> = (
useImperativeHandle(ref, () => ({
validator,
}));
console.log('uiSchema: ', uiSchema);
return (
<Form noValidate onSubmit={handleSubmit}>
{keys.map((key) => {
const { title, description, label } = properties[key];
const { 'ui:widget': widget = 'input' } = uiSchema[key] || {};
const { title, description } = properties[key];
const { 'ui:widget': widget = 'input', 'ui:options': uiOpt } =
uiSchema[key] || {};
if (widget === 'select') {
return (
<Form.Group
@@ -435,7 +435,7 @@ const SchemaForm: ForwardRefRenderFunction<IRef, IProps> = (
id={`switch-${title}`}
name={key}
type="switch"
label={label}
label={(uiOpt as SwitchOptions)?.label}
checked={formData[key]?.value || ''}
feedback={formData[key]?.errorMsg}
feedbackType="invalid"
+6 -2
View File
@@ -19,14 +19,12 @@ const Index: FC = () => {
allow_new_registrations: {
type: 'boolean',
title: t('membership.title'),
label: t('membership.label'),
description: t('membership.text'),
default: false,
},
login_required: {
type: 'boolean',
title: t('private.title'),
label: t('private.label'),
description: t('private.text'),
default: false,
},
@@ -35,9 +33,15 @@ const Index: FC = () => {
const uiSchema: UISchema = {
allow_new_registrations: {
'ui:widget': 'switch',
'ui:options': {
label: t('membership.label'),
},
},
login_required: {
'ui:widget': 'switch',
'ui:options': {
label: t('private.label'),
},
},
};
const [formData, setFormData] = useState(initFormData(schema));
+3 -1
View File
@@ -47,7 +47,6 @@ const Smtp: FC = () => {
smtp_authentication: {
type: 'boolean',
title: t('smtp_authentication.title'),
label: t('smtp_authentication.label'),
enum: [true, false],
enumNames: [t('smtp_authentication.yes'), t('smtp_authentication.no')],
},
@@ -102,6 +101,9 @@ const Smtp: FC = () => {
},
smtp_authentication: {
'ui:widget': 'switch',
'ui:options': {
label: t('smtp_authentication.label'),
},
},
smtp_port: {
'ui:options': {
+3 -1
View File
@@ -27,7 +27,6 @@ const Index: FC = () => {
required_tag: {
type: 'boolean',
title: t('required_tag.title'),
label: t('required_tag.label'),
description: t('required_tag.text'),
},
reserved_tags: {
@@ -46,6 +45,9 @@ const Index: FC = () => {
},
required_tag: {
'ui:widget': 'switch',
'ui:options': {
label: t('required_tag.label'),
},
},
reserved_tags: {
'ui:widget': 'textarea',
@@ -17,7 +17,6 @@ const Index = () => {
notice_switch: {
type: 'boolean',
title: t('email.label'),
label: t('email.radio'),
default: false,
},
},
@@ -25,6 +24,9 @@ const Index = () => {
const uiSchema: UISchema = {
notice_switch: {
'ui:widget': 'switch',
'ui:options': {
label: t('email.radio'),
},
},
};
const [formData, setFormData] = useState<FormDataType>(initFormData(schema));