mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-02 20:27:49 +08:00
fix: action error when field deleted (#1849)
* fix: action error when field deleted * fix: delete field cannot set dynamic value
This commit is contained in:
parent
1c757bd025
commit
975b7dfe93
@ -101,7 +101,7 @@ export const InternalFallbackField = () => {
|
||||
// 当字段被删除时,显示一个提示占位符
|
||||
const DeletedField = () => {
|
||||
const { t } = useTranslation();
|
||||
return <div style={{ color: '#ccc' }}>{t('The field has bee deleted')}</div>;
|
||||
return <div style={{ color: '#ccc' }}>{t('The field has been deleted')}</div>;
|
||||
};
|
||||
|
||||
export const CollectionField = connect((props) => {
|
||||
|
@ -9,7 +9,7 @@ export const CollectionFieldProvider: React.FC<{
|
||||
field?: CollectionFieldOptions;
|
||||
fallback?: React.ReactElement;
|
||||
}> = (props) => {
|
||||
const { name, field, children, fallback } = props;
|
||||
const { name, field, children, fallback = null } = props;
|
||||
const fieldSchema = useFieldSchema();
|
||||
const { getField } = useCollection();
|
||||
const { getCollectionJoinField } = useCollectionManager();
|
||||
|
@ -504,7 +504,7 @@ export default {
|
||||
"Skip required validation": "Skip required validation",
|
||||
"Form values": "Form values",
|
||||
"Fields values": "Fields values",
|
||||
'The field has bee deleted': 'The field has bee deleted',
|
||||
'The field has been deleted': 'The field has been 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",
|
||||
|
@ -421,7 +421,7 @@ export default {
|
||||
"Skip required validation": "必須のバリデーションをスキップ",
|
||||
"Form values": "フォームの値",
|
||||
"Fields values": "フィールドの値",
|
||||
'The field has bee deleted': 'フィールドが削除されました',
|
||||
'The field has been deleted': 'フィールドが削除されました',
|
||||
"When submitting the following fields, the saved values are": "次のフィールドを送信すると、保存された値は",
|
||||
"After successful submission": "送信が成功した後",
|
||||
"Then": "その後",
|
||||
|
@ -461,7 +461,7 @@ export default {
|
||||
"Skip required validation": "Ignorar validação obrigatória",
|
||||
"Form values": "Valores do formulário",
|
||||
"Fields values": "campo removido",
|
||||
'The field has bee deleted': 'O campo foi excluído',
|
||||
'The field has been 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",
|
||||
"After successful submission": "Depois do envio bem-sucedido",
|
||||
"Then": "Então",
|
||||
|
@ -363,7 +363,7 @@ export default {
|
||||
"Skip required validation": "Пропустить обязатеьную проверку",
|
||||
"Form values": "Значения формы",
|
||||
"Fields values": "Значения полей",
|
||||
'The field has bee deleted': 'Поле было удалено',
|
||||
'The field has been deleted': 'Поле было удалено',
|
||||
"When submitting the following fields, the saved values are": "При отправке следующих полей, сохраненные значения такие",
|
||||
"After successful submission": "После удачной отправки",
|
||||
"Then": "Затем",
|
||||
|
@ -362,7 +362,7 @@ export default {
|
||||
"Skip required validation": "Zorunlu alan kontrollerini atla",
|
||||
"Form values": "Form değerleri",
|
||||
"Fields values": "Alanların değerleri",
|
||||
'The field has bee deleted': 'Alan silindi',
|
||||
'The field has been deleted': 'Alan silindi',
|
||||
"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",
|
||||
"Then": "Then",
|
||||
|
@ -543,7 +543,7 @@ export default {
|
||||
'Skip required validation': '跳过必填校验',
|
||||
'Form values': '表单值',
|
||||
'Fields values': '字段值',
|
||||
'The field has bee deleted': '字段已删除',
|
||||
'The field has been deleted': '字段已删除',
|
||||
'When submitting the following fields, the saved values are': '提交以下字段时,保存的值为',
|
||||
'After successful submission': '提交成功后',
|
||||
'Then': '然后',
|
||||
|
@ -191,7 +191,7 @@ export const TableActionColumnInitializers = (props: any) => {
|
||||
title: '{{t("Update record")}}',
|
||||
component: 'CustomizeActionInitializer',
|
||||
schema: {
|
||||
title: '{{ t("Update record") }}',
|
||||
title: '{{t("Update record")}}',
|
||||
'x-component': 'Action.Link',
|
||||
'x-action': 'customize:update',
|
||||
'x-decorator': 'ACLActionProvider',
|
||||
|
@ -8,6 +8,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import { useFormBlockContext } from '../../block-provider';
|
||||
import { CollectionFieldProvider, useCollection, useCollectionField } from '../../collection-manager';
|
||||
import { useCompile, useComponent } from '../../schema-component';
|
||||
import { DeletedField } from './DeletedField';
|
||||
|
||||
const InternalField: React.FC = (props) => {
|
||||
const field = useField<Field>();
|
||||
@ -65,7 +66,7 @@ const InternalField: React.FC = (props) => {
|
||||
const CollectionField = connect((props) => {
|
||||
const fieldSchema = useFieldSchema();
|
||||
return (
|
||||
<CollectionFieldProvider name={fieldSchema.name}>
|
||||
<CollectionFieldProvider name={fieldSchema.name} fallback={<DeletedField />}>
|
||||
<InternalField {...props} />
|
||||
</CollectionFieldProvider>
|
||||
);
|
||||
@ -85,7 +86,7 @@ export const BulkEditField = (props: any) => {
|
||||
const [type, setType] = useState<number>(BulkEditFormItemValueType.RemainsTheSame);
|
||||
const [value, setValue] = useState(null);
|
||||
const { getField } = useCollection();
|
||||
const collectionField = getField(fieldSchema.name);
|
||||
const collectionField = getField(fieldSchema.name) || {};
|
||||
|
||||
useEffect(() => {
|
||||
field.value = { [type]: value };
|
||||
|
@ -0,0 +1,7 @@
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export const DeletedField = () => {
|
||||
const { t } = useTranslation();
|
||||
return <div style={{ color: '#ccc' }}>{t('The field has bee deleted')}</div>;
|
||||
};
|
@ -2,7 +2,7 @@ import { Field } from '@formily/core';
|
||||
import { connect, useField, useFieldSchema } from '@formily/react';
|
||||
import { merge } from '@formily/shared';
|
||||
import { Cascader, Select, Space } from 'antd';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useFormBlockContext } from '../../../block-provider';
|
||||
import {
|
||||
@ -12,6 +12,7 @@ import {
|
||||
useCollectionFilterOptions,
|
||||
} from '../../../collection-manager';
|
||||
import { useCompile, useComponent } from '../../../schema-component';
|
||||
import { DeletedField } from '../DeletedField';
|
||||
|
||||
const DYNAMIC_RECORD_REG = /\{\{\s*currentRecord\.(.*)\s*\}\}/;
|
||||
const DYNAMIC_USER_REG = /\{\{\s*currentUser\.(.*)\s*\}\}/;
|
||||
@ -134,7 +135,6 @@ export const AssignedField = (props: any) => {
|
||||
name: 'currentTime',
|
||||
title: t('Current time'),
|
||||
});
|
||||
} else {
|
||||
}
|
||||
setOptions(compile(opt));
|
||||
}, []);
|
||||
@ -178,16 +178,15 @@ export const AssignedField = (props: any) => {
|
||||
const userChangeHandler = (val) => {
|
||||
setUserValue(val);
|
||||
};
|
||||
return (
|
||||
<Space>
|
||||
<Select defaultValue={type} value={type} style={{ width: 150 }} onChange={typeChangeHandler}>
|
||||
<Select.Option value={AssignedFieldValueType.ConstantValue}>{t('Constant value')}</Select.Option>
|
||||
<Select.Option value={AssignedFieldValueType.DynamicValue}>{t('Dynamic value')}</Select.Option>
|
||||
</Select>
|
||||
|
||||
{type === AssignedFieldValueType.ConstantValue ? (
|
||||
<CollectionField {...props} value={value} onChange={valueChangeHandler} style={{ minWidth: 150 }} />
|
||||
) : (
|
||||
const useFieldMemo = useMemo(() => {
|
||||
if (!collectionField) {
|
||||
return <DeletedField />;
|
||||
}
|
||||
if (type === AssignedFieldValueType.ConstantValue) {
|
||||
return <CollectionField {...props} value={value} onChange={valueChangeHandler} style={{ minWidth: 150 }} />;
|
||||
} else {
|
||||
return (
|
||||
<Select defaultValue={fieldType} value={fieldType} style={{ minWidth: 150 }} onChange={fieldTypeChangeHandler}>
|
||||
{options?.map((opt) => {
|
||||
return (
|
||||
@ -197,7 +196,19 @@ export const AssignedField = (props: any) => {
|
||||
);
|
||||
})}
|
||||
</Select>
|
||||
)}
|
||||
);
|
||||
}
|
||||
}, [collectionField, type, value, fieldType]);
|
||||
|
||||
return (
|
||||
<Space>
|
||||
<Select defaultValue={type} value={type} style={{ width: 150 }} onChange={typeChangeHandler}>
|
||||
<Select.Option value={AssignedFieldValueType.ConstantValue}>{t('Constant value')}</Select.Option>
|
||||
<Select.Option value={AssignedFieldValueType.DynamicValue}>{t('Dynamic value')}</Select.Option>
|
||||
</Select>
|
||||
|
||||
{useFieldMemo}
|
||||
|
||||
{fieldType === 'currentRecord' && (
|
||||
<Cascader
|
||||
fieldNames={{
|
||||
|
Loading…
Reference in New Issue
Block a user