feat: deleted collection field give some tips (#1744)

* feat: deleted collection field give some tips

* chore: optimize traslation

---------

Co-authored-by: Rairn <958414905@qq.com>
This commit is contained in:
李小斐 2023-04-24 21:49:56 +08:00 committed by GitHub
parent cd596925ee
commit c03d271481
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 78 additions and 65 deletions

View File

@ -3,6 +3,7 @@ import { connect, useField, useFieldSchema } from '@formily/react';
import { merge } from '@formily/shared'; import { merge } from '@formily/shared';
import { concat } from 'lodash'; import { concat } from 'lodash';
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { useActionContext, useCompile, useComponent, useFormBlockContext, useRecord } from '..'; import { useActionContext, useCompile, useComponent, useFormBlockContext, useRecord } from '..';
import { CollectionFieldProvider } from './CollectionFieldProvider'; import { CollectionFieldProvider } from './CollectionFieldProvider';
import { useCollectionField } from './hooks'; import { useCollectionField } from './hooks';
@ -97,6 +98,12 @@ export const InternalFallbackField = () => {
return <div>{displayText}</div>; return <div>{displayText}</div>;
}; };
// 当字段被删除时,显示一个提示占位符
const DeletedField = () => {
const { t } = useTranslation()
return <div style={{ color: '#ccc' }}>{t('The field has bee deleted')}</div>;
}
export const CollectionField = connect((props) => { export const CollectionField = connect((props) => {
const fieldSchema = useFieldSchema(); const fieldSchema = useFieldSchema();
const field = fieldSchema?.['x-component-props']?.['field']; const field = fieldSchema?.['x-component-props']?.['field'];
@ -105,7 +112,7 @@ export const CollectionField = connect((props) => {
<CollectionFieldProvider <CollectionFieldProvider
name={fieldSchema.name} name={fieldSchema.name}
field={field} field={field}
fallback={snapshot ? <InternalFallbackField /> : null} fallback={snapshot ? <InternalFallbackField /> : <DeletedField />}
> >
<InternalField {...props} /> <InternalField {...props} />
</CollectionFieldProvider> </CollectionFieldProvider>

View File

@ -498,6 +498,7 @@ export default {
"Skip required validation": "Skip required validation", "Skip required validation": "Skip required validation",
"Form values": "Form values", "Form values": "Form values",
"Fields values": "Fields values", "Fields values": "Fields values",
'The field has bee deleted': 'The field has bee deleted',
"When submitting the following fields, the saved values are": "When submitting the following fields, the saved values are", "When submitting the following fields, the saved values are": "When submitting the following fields, the saved values are",
"After successful submission": "After successful submission", "After successful submission": "After successful submission",
"Then": "Then", "Then": "Then",

View File

@ -421,6 +421,7 @@ export default {
"Skip required validation": "必須のバリデーションをスキップ", "Skip required validation": "必須のバリデーションをスキップ",
"Form values": "フォームの値", "Form values": "フォームの値",
"Fields values": "フィールドの値", "Fields values": "フィールドの値",
'The field has bee deleted': 'フィールドが削除されました',
"When submitting the following fields, the saved values are": "次のフィールドを送信すると、保存された値は", "When submitting the following fields, the saved values are": "次のフィールドを送信すると、保存された値は",
"After successful submission": "送信が成功した後", "After successful submission": "送信が成功した後",
"Then": "その後", "Then": "その後",

View File

@ -457,7 +457,8 @@ export default {
"Delete table column": "Excluir coluna da tabela", "Delete table column": "Excluir coluna da tabela",
"Skip required validation": "Ignorar validação obrigatória", "Skip required validation": "Ignorar validação obrigatória",
"Form values": "Valores do formulário", "Form values": "Valores do formulário",
"Fields values": "Valores dos campos", "Fields values": "campo removido",
'The field has bee deleted': 'O campo foi excluído',
"When submitting the following fields, the saved values are": "Ao enviar os seguintes campos, os valores salvos são", "When submitting the following fields, the saved values are": "Ao enviar os seguintes campos, os valores salvos são",
"After successful submission": "Depois do envio bem-sucedido", "After successful submission": "Depois do envio bem-sucedido",
"Then": "Então", "Then": "Então",

View File

@ -363,6 +363,7 @@ export default {
"Skip required validation": "Пропустить обязатеьную проверку", "Skip required validation": "Пропустить обязатеьную проверку",
"Form values": "Значения формы", "Form values": "Значения формы",
"Fields values": "Значения полей", "Fields values": "Значения полей",
'The field has bee deleted': 'Поле было удалено',
"When submitting the following fields, the saved values are": "При отправке следующих полей, сохраненные значения такие", "When submitting the following fields, the saved values are": "При отправке следующих полей, сохраненные значения такие",
"After successful submission": "После удачной отправки", "After successful submission": "После удачной отправки",
"Then": "Затем", "Then": "Затем",

View File

@ -362,6 +362,7 @@ export default {
"Skip required validation": "Zorunlu alan kontrollerini atla", "Skip required validation": "Zorunlu alan kontrollerini atla",
"Form values": "Form değerleri", "Form values": "Form değerleri",
"Fields values": "Alanların değerleri", "Fields values": "Alanların değerleri",
'The field has bee deleted': 'Alan silindi',
"When submitting the following fields, the saved values are": "Aşağıdaki alanlar gönderilirken kaydedilen değerler", "When submitting the following fields, the saved values are": "Aşağıdaki alanlar gönderilirken kaydedilen değerler",
"After successful submission": "Başarılı gönderimden sonra", "After successful submission": "Başarılı gönderimden sonra",
"Then": "Then", "Then": "Then",

View File

@ -536,6 +536,7 @@ export default {
'Skip required validation': '跳过必填校验', 'Skip required validation': '跳过必填校验',
'Form values': '表单值', 'Form values': '表单值',
'Fields values': '字段值', 'Fields values': '字段值',
'The field has bee deleted': '字段已删除',
'When submitting the following fields, the saved values are': '提交以下字段时,保存的值为', 'When submitting the following fields, the saved values are': '提交以下字段时,保存的值为',
'After successful submission': '提交成功后', 'After successful submission': '提交成功后',
'Then': '然后', 'Then': '然后',