mirror of https://gitee.com/answerdev/answer.git
Merge branch 'feat/ui-v0.4' into 'test'
feat: form for swwitch add label See merge request opensource/answer!264
This commit is contained in:
commit
8e8cbf6621
|
@ -1167,6 +1167,7 @@ ui:
|
|||
label: Recommend Tags
|
||||
text: "Please input tag slug above, one tag per line."
|
||||
required_tag:
|
||||
title: Required Tag
|
||||
label: Set recommend tag as required
|
||||
text: "Every new question must have at least one recommend tag."
|
||||
reserved_tags:
|
||||
|
|
|
@ -14,6 +14,7 @@ export interface JSONSchema {
|
|||
[key: string]: {
|
||||
type: 'string' | 'boolean';
|
||||
title: string;
|
||||
label?: string;
|
||||
description?: string;
|
||||
enum?: Array<string | boolean>;
|
||||
enumNames?: string[];
|
||||
|
@ -228,7 +229,7 @@ const SchemaForm: FC<IProps> = ({
|
|||
return (
|
||||
<Form noValidate onSubmit={handleSubmit}>
|
||||
{keys.map((key) => {
|
||||
const { title, description } = properties[key];
|
||||
const { title, description, label } = properties[key];
|
||||
const { 'ui:widget': widget = 'input', 'ui:options': options = {} } =
|
||||
uiSchema[key] || {};
|
||||
if (widget === 'select') {
|
||||
|
@ -249,7 +250,7 @@ const SchemaForm: FC<IProps> = ({
|
|||
<Form.Control.Feedback type="invalid">
|
||||
{formData[key]?.errorMsg}
|
||||
</Form.Control.Feedback>
|
||||
<Form.Text className="text-muted">{description}</Form.Text>
|
||||
<Form.Text>{description}</Form.Text>
|
||||
</Form.Group>
|
||||
);
|
||||
}
|
||||
|
@ -279,13 +280,12 @@ const SchemaForm: FC<IProps> = ({
|
|||
<Form.Control.Feedback type="invalid">
|
||||
{formData[key]?.errorMsg}
|
||||
</Form.Control.Feedback>
|
||||
<Form.Text className="text-muted">{description}</Form.Text>
|
||||
<Form.Text>{description}</Form.Text>
|
||||
</Form.Group>
|
||||
);
|
||||
}
|
||||
|
||||
if (widget === 'switch') {
|
||||
console.log(formData[key]?.value, 'switch=====');
|
||||
return (
|
||||
<Form.Group key={title} className="mb-3" controlId={key}>
|
||||
<Form.Label>{title}</Form.Label>
|
||||
|
@ -294,7 +294,7 @@ const SchemaForm: FC<IProps> = ({
|
|||
id={title}
|
||||
name={key}
|
||||
type="switch"
|
||||
label={title}
|
||||
label={label}
|
||||
checked={formData[key]?.value}
|
||||
feedback={formData[key]?.errorMsg}
|
||||
feedbackType="invalid"
|
||||
|
@ -304,7 +304,7 @@ const SchemaForm: FC<IProps> = ({
|
|||
<Form.Control.Feedback type="invalid">
|
||||
{formData[key]?.errorMsg}
|
||||
</Form.Control.Feedback>
|
||||
<Form.Text className="text-muted">{description}</Form.Text>
|
||||
<Form.Text>{description}</Form.Text>
|
||||
</Form.Group>
|
||||
);
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ const SchemaForm: FC<IProps> = ({
|
|||
<Form.Control.Feedback type="invalid">
|
||||
{formData[key]?.errorMsg}
|
||||
</Form.Control.Feedback>
|
||||
<Form.Text className="text-muted">{description}</Form.Text>
|
||||
<Form.Text>{description}</Form.Text>
|
||||
</Form.Group>
|
||||
);
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ const SchemaForm: FC<IProps> = ({
|
|||
<Form.Control.Feedback type="invalid">
|
||||
{formData[key]?.errorMsg}
|
||||
</Form.Control.Feedback>
|
||||
<Form.Text className="text-muted">{description}</Form.Text>
|
||||
<Form.Text>{description}</Form.Text>
|
||||
</Form.Group>
|
||||
);
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ const SchemaForm: FC<IProps> = ({
|
|||
{formData[key]?.errorMsg}
|
||||
</Form.Control.Feedback>
|
||||
|
||||
<Form.Text className="text-muted">{description}</Form.Text>
|
||||
<Form.Text>{description}</Form.Text>
|
||||
</Form.Group>
|
||||
);
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ const SchemaForm: FC<IProps> = ({
|
|||
{formData[key]?.errorMsg}
|
||||
</Form.Control.Feedback>
|
||||
|
||||
<Form.Text className="text-muted">{description}</Form.Text>
|
||||
<Form.Text>{description}</Form.Text>
|
||||
</Form.Group>
|
||||
);
|
||||
})}
|
||||
|
|
|
@ -3,10 +3,10 @@ import { Card, Row, Col, Badge } from 'react-bootstrap';
|
|||
import { useTranslation } from 'react-i18next';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import { gt, gte } from 'semver';
|
||||
|
||||
import type * as Type from '@/common/interface';
|
||||
|
||||
const { gt, gte } = require('semver');
|
||||
|
||||
interface IProps {
|
||||
data: Type.AdminDashboard['info'];
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ const Legal: FC = () => {
|
|||
},
|
||||
required_tag: {
|
||||
type: 'boolean',
|
||||
title: t('required_tag.label'),
|
||||
title: t('required_tag.title'),
|
||||
label: t('required_tag.label'),
|
||||
description: t('required_tag.text'),
|
||||
},
|
||||
reserved_tags: {
|
||||
|
|
Loading…
Reference in New Issue