feat(snapshot-field): improve transition (#1513)

This commit is contained in:
anuoua 2023-02-28 22:57:47 +08:00 committed by GitHub
parent 05efa41be3
commit 757d409131
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 19 deletions

View File

@ -29,15 +29,15 @@ const onTargetFieldChange = (field: Field) => {
function makeFieldsPathOptions(fields, appends = []) {
const { getCollection } = useCollectionManager();
const options = [];
fields.forEach(field => {
fields.forEach((field) => {
if (['belongsTo', 'hasOne', 'hasMany', 'belongsToMany'].includes(field.type)) {
const currentAppends = appends.filter(key => `${key}.`.startsWith(`${field.name}.`))
const currentAppends = appends.filter((key) => `${key}.`.startsWith(`${field.name}.`));
if (currentAppends.length) {
const nextCollection = getCollection(field.target);
const nextAppends = currentAppends
.filter(key => key !== field.name)
.map(key => key.replace(`${field.name}.`, ''))
.filter(key => key);
.filter((key) => key !== field.name)
.map((key) => key.replace(`${field.name}.`, ''))
.filter((key) => key);
options.push({
label: field.uiSchema?.title ?? field.name,
value: field.name,
@ -93,7 +93,7 @@ export const snapshot: IField = {
type: 'object',
group: 'advanced',
title: `{{t('Snapshot', {ns: '${NAMESPACE}'})}}`,
description: `{{t('Snapshot to description', {ns: '${NAMESPACE}'})}}`,
description: `{{t('When adding a new record, create a snapshot for its relational record and save in the current record. The snapshot is not updated when the record is subsequently updated.', {ns: '${NAMESPACE}'})}}`,
default: {
type: 'snapshot',
// name,
@ -127,14 +127,14 @@ export const snapshot: IField = {
label: `{{t('Snapshot data', { ns: '${NAMESPACE}' })}}`,
value: 'data',
children: result,
}
},
];
},
properties: {
...defaultProps,
[TARGET_FIELD]: {
type: 'string',
title: `{{t('Association field', {ns: '${NAMESPACE}'})}}`,
title: `{{t('The association field to snapshot', {ns: '${NAMESPACE}'})}}`,
required: true,
'x-decorator': 'FormItem',
'x-component': 'SnapshotOwnerCollectionFieldsSelect',
@ -158,8 +158,7 @@ export const snapshot: IField = {
},
[APPENDS]: {
type: 'string',
title: `{{t('Deep copy fields', {ns: '${NAMESPACE}'})}}`,
description: `{{t('When a record is created, relational data is backed up in a snapshot', {ns: '${NAMESPACE}'})}}`,
title: `{{t("Snapshot the snapshot's association fields", {ns: "${NAMESPACE}"})}}`,
'x-decorator': 'FormItem',
'x-component': 'AppendsTreeSelect',
'x-reactions': [

View File

@ -4,11 +4,9 @@ export default {
'View record': 'View record',
'Add block': 'Add block',
'Allow linking to multiple records': 'Allow linking to multiple records',
'Snapshot to description':
'It is used to create a snapshot of the table, save the current data of the pointed table, and save it only when the record to which it belongs is created, and will not be updated later.',
'Association field': 'Association field',
'Deep copy fields': 'Deep copy fields',
'When adding a new record, create a snapshot for its relational record and save in the current record. The snapshot is not updated when the record is subsequently updated.':
'When adding a new record, create a snapshot for its relational record and save in the current record. The snapshot is not updated when the record is subsequently updated.',
'The association field to snapshot': 'The association field to snapshot',
"Snapshot the snapshot's association fields": "Snapshot the snapshot's association fields",
'Please select': 'Please select',
'When a record is created, relational data is backed up in a snapshot':
'When a record is created, relational data is backed up in a snapshot',
};

View File

@ -2,11 +2,12 @@ export default {
Detail: '详情',
Snapshot: '快照',
'Add block': '创建区块',
'Snapshot to description': '用于创建表的快照,保存指向的表的当前数据,仅在其所属的记录创建时保存,后续不再更新。',
'When adding a new record, create a snapshot for its relational record and save in the current record. The snapshot is not updated when the record is subsequently updated.':
'在添加数据时,为它的关系数据创建快照,并保存在当前的数据中。后续更新数据时,快照不再更新。',
'View record': '查看数据',
'Allow linking to multiple records': '允许关联多条记录',
'Association field': '关系字段',
'Deep copy fields': '深复制的字段',
'The association field to snapshot': '快照目标关系字段',
"Snapshot the snapshot's association fields": '为快照的关系数据创建快照',
'Please select': '请选择',
'When a record is created, association data is backed up in a snapshot': '创建记录时,关系数据会备份到快照里',
'Snapshot data': '快照数据',