mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-02 12:18:15 +08:00
fix: deleting the last field from sub table, the entire table will be delete (#2077)
* fix: deleting the last field from sub table, the entire table will be deleted * refactor: association select support data scope in sub-table * refactor: locale improve * style: sub-table style improve
This commit is contained in:
parent
2bbba7b7fa
commit
7c5df477f3
@ -294,7 +294,7 @@ export default {
|
||||
"Quick upload": "Quick upload",
|
||||
"Select file": "Select file",
|
||||
"Subtable": "Sub-table",
|
||||
"Subform": "Sub-form",
|
||||
"Sub-form": "Sub-form",
|
||||
"Field mode":"Field mode",
|
||||
"Allow add new data":"Allow add new data",
|
||||
"Record picker": "Record picker",
|
||||
|
@ -280,7 +280,7 @@ export default {
|
||||
"Display field title": "Mostrar título de campo",
|
||||
"Field component": "Componente del campo",
|
||||
"Subtable": "Subtabla",
|
||||
"Subform": "Subformulario",
|
||||
"Sub-form": "Subformulario",
|
||||
"Record picker": "Selector de registros",
|
||||
"Toggles the subfield mode": "Alterna el modo de subcampo",
|
||||
"Selector mode": "Modo selector",
|
||||
|
@ -540,7 +540,7 @@ export default {
|
||||
"Quick upload": "クイックアップロード",
|
||||
"Select file": "ファイルを選択",
|
||||
"Subtable": "サブテーブル",
|
||||
"Subform": "サブフォーム",
|
||||
"Sub-form": "サブフォーム",
|
||||
"Sub-details":"サブリスト",
|
||||
"Field mode":"フィールドコンポーネント",
|
||||
"Allow add new data":"データの追加を許可",
|
||||
|
@ -244,7 +244,7 @@ export default {
|
||||
"Select file": "Selecionar arquivo",
|
||||
"Allow multiple": "Permitir múltiplos",
|
||||
"Subtable": "Subtabela",
|
||||
"Subform": "Subformulário",
|
||||
"Sub-form": "Subformulário",
|
||||
"Record picker": "Selecionador de registros",
|
||||
"Toggles the subfield mode": "Alterna o modo de subcampo",
|
||||
"Selector mode": "Modo de seleção",
|
||||
|
@ -478,7 +478,7 @@ export default {
|
||||
"Quick upload": "Быстрая загрузка",
|
||||
"Select file": "Выбрать файл",
|
||||
"Subtable": "Подтаблица",
|
||||
"Subform": "Подформа",
|
||||
"Sub-form": "Подформа",
|
||||
"Regular expression": "Образец",
|
||||
"Enabled languages": "Включенные языки",
|
||||
"View all plugins": "Посмотреть все плагины",
|
||||
|
@ -316,7 +316,7 @@ export default {
|
||||
"Quick upload": "快速上传",
|
||||
"Select file": "选择文件",
|
||||
"Subtable": "子表格",
|
||||
"Subform": "子表单",
|
||||
"Sub-form": "子表单",
|
||||
"Sub-details":"子详情",
|
||||
"Record picker": "数据选择器",
|
||||
"Toggles the subfield mode": "切换子字段模式",
|
||||
|
@ -75,7 +75,7 @@ export const SubTable: any = observer(
|
||||
.ant-table table {
|
||||
}
|
||||
td:not(.ant-table-selection-column) {
|
||||
padding: 0 !important;
|
||||
padding: 5px !important;
|
||||
}
|
||||
`}
|
||||
bordered
|
||||
|
@ -1,10 +1,13 @@
|
||||
import { ISchema, useField, useFieldSchema } from '@formily/react';
|
||||
import React from 'react';
|
||||
import { set } from 'lodash';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useCollectionManager } from '../../../collection-manager';
|
||||
import { useCollectionManager, useCollectionFilterOptions } from '../../../collection-manager';
|
||||
import { GeneralSchemaDesigner, SchemaSettings, isPatternDisabled } from '../../../schema-settings';
|
||||
import { useCompile, useDesignable } from '../../hooks';
|
||||
import { useAssociationFieldContext } from '../association-field/hooks';
|
||||
import { FilterDynamicComponent } from './FilterDynamicComponent';
|
||||
import { removeNullCondition } from '../filter';
|
||||
|
||||
const useLabelFields = (collectionName?: any) => {
|
||||
// 需要在组件顶层调用
|
||||
@ -39,6 +42,8 @@ export const TableColumnDesigner = (props) => {
|
||||
const isFileField = isFileCollection(targetCollection);
|
||||
const isSubTableColumn = ['QuickEdit', 'FormItem'].includes(fieldSchema['x-decorator']);
|
||||
const { currentMode, field: tableField } = useAssociationFieldContext();
|
||||
const defaultFilter = fieldSchema?.['x-component-props']?.service?.params?.filter || {};
|
||||
const dataSource = useCollectionFilterOptions(collectionField?.target);
|
||||
let readOnlyMode = 'editable';
|
||||
if (fieldSchema['x-disabled'] === true) {
|
||||
readOnlyMode = 'readonly';
|
||||
@ -80,6 +85,44 @@ export const TableColumnDesigner = (props) => {
|
||||
dn.refresh();
|
||||
}}
|
||||
/>
|
||||
{currentMode && !field.readPretty && (
|
||||
<SchemaSettings.ModalItem
|
||||
title={t('Set the data scope')}
|
||||
schema={
|
||||
{
|
||||
type: 'object',
|
||||
title: t('Set the data scope'),
|
||||
properties: {
|
||||
filter: {
|
||||
default: defaultFilter,
|
||||
enum: dataSource,
|
||||
'x-component': 'Filter',
|
||||
'x-component-props': {
|
||||
dynamicComponent: (props) => FilterDynamicComponent({ ...props }),
|
||||
},
|
||||
},
|
||||
},
|
||||
} as ISchema
|
||||
}
|
||||
onSubmit={({ filter }) => {
|
||||
filter = removeNullCondition(filter);
|
||||
set(field.componentProps, 'service.params.filter', filter);
|
||||
fieldSchema['x-component-props'] = field.componentProps;
|
||||
const path = field.path?.splice(field.path?.length - 1, 1);
|
||||
(tableField as any)?.value.map((_, index) => {
|
||||
field.form.query(`${path.concat(`${index}.` + fieldSchema.name)}`).take((f) => {
|
||||
set(f.componentProps, 'service.params.filter', filter);
|
||||
});
|
||||
});
|
||||
dn.emit('patch', {
|
||||
schema: {
|
||||
['x-uid']: fieldSchema['x-uid'],
|
||||
'x-component-props': field.componentProps,
|
||||
},
|
||||
});
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<SchemaSettings.ModalItem
|
||||
title={t('Column width')}
|
||||
schema={
|
||||
@ -282,7 +325,7 @@ export const TableColumnDesigner = (props) => {
|
||||
)}
|
||||
<SchemaSettings.Divider />
|
||||
<SchemaSettings.Remove
|
||||
removeParentsIfNoChildren
|
||||
removeParentsIfNoChildren={!isSubTableColumn}
|
||||
breakRemoveOn={{
|
||||
'x-component': 'Grid',
|
||||
}}
|
||||
|
@ -234,7 +234,7 @@
|
||||
"Quick upload": "Quick upload",
|
||||
"Select file": "Select file",
|
||||
"Subtable": "Subtable",
|
||||
"Subform": "Sub-form",
|
||||
"Sub-form": "Sub-form",
|
||||
"Record picker": "Record picker",
|
||||
"Toggles the subfield mode": "Toggles the subfield mode",
|
||||
"Selector mode": "Selector mode",
|
||||
|
@ -284,7 +284,7 @@
|
||||
"Display field title": "Mostrar título de campo",
|
||||
"Field component": "Componente del campo",
|
||||
"Subtable": "Subtabla",
|
||||
"Subform": "Subformulario",
|
||||
"Sub-form": "Subformulario",
|
||||
"Record picker": "Selector de registros",
|
||||
"Toggles the subfield mode": "Alterna el modo de subcampo",
|
||||
"Selector mode": "Modo selector",
|
||||
|
@ -218,7 +218,7 @@
|
||||
"Select file": "Selecionar arquivo",
|
||||
"Allow multiple": "Permitir múltiplos",
|
||||
"Subtable": "Subtabela",
|
||||
"Subform": "Subformulário",
|
||||
"Sub-form": "Subformulário",
|
||||
"Record picker": "Selecionador de registro",
|
||||
"Toggles the subfield mode": "Alterna o modo de subcampo",
|
||||
"Selector mode": "Modo de seleção",
|
||||
|
@ -234,7 +234,7 @@
|
||||
"Quick upload": "快速上传",
|
||||
"Select file": "选择文件",
|
||||
"Subtable": "子表格",
|
||||
"Subform": "子表单",
|
||||
"Sub-form": "子表单",
|
||||
"Record picker": "数据选择器",
|
||||
"Toggles the subfield mode": "切换子字段模式",
|
||||
"Selector mode": "选择器模式",
|
||||
|
Loading…
Reference in New Issue
Block a user