From 757d409131dfa785166fd180f7e943fd601f873f Mon Sep 17 00:00:00 2001 From: anuoua Date: Tue, 28 Feb 2023 22:57:47 +0800 Subject: [PATCH] feat(snapshot-field): improve transition (#1513) --- .../snapshot-field/src/client/interface.ts | 19 +++++++++---------- .../snapshot-field/src/client/locale/en-US.ts | 10 ++++------ .../snapshot-field/src/client/locale/zh-CN.ts | 7 ++++--- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/packages/plugins/snapshot-field/src/client/interface.ts b/packages/plugins/snapshot-field/src/client/interface.ts index 9c3201aaa..1a7b27799 100644 --- a/packages/plugins/snapshot-field/src/client/interface.ts +++ b/packages/plugins/snapshot-field/src/client/interface.ts @@ -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': [ diff --git a/packages/plugins/snapshot-field/src/client/locale/en-US.ts b/packages/plugins/snapshot-field/src/client/locale/en-US.ts index c9380f4f1..27e7437e6 100644 --- a/packages/plugins/snapshot-field/src/client/locale/en-US.ts +++ b/packages/plugins/snapshot-field/src/client/locale/en-US.ts @@ -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', }; diff --git a/packages/plugins/snapshot-field/src/client/locale/zh-CN.ts b/packages/plugins/snapshot-field/src/client/locale/zh-CN.ts index d50b4d0fa..6186ed459 100644 --- a/packages/plugins/snapshot-field/src/client/locale/zh-CN.ts +++ b/packages/plugins/snapshot-field/src/client/locale/zh-CN.ts @@ -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': '快照数据',