tachybase_todo/packages/plugins/audit-logs/src/client/collections.tsx
katherinehhh 55efa40cdd
refactor: association field (#1838)
* feat: association field

* fix: bug

* refactor: association field

* style: style improve

* style: style improve

* refactor: support subtable

* refactor: support file collection

* refactor: locale improve

* refactor: subtable improve

* refactor: association select  improve

* refactor: association select  improve

* refactor: association select  improve

* refactor: useAssociationNames

* refactor: enable link

* refactor: selector

* refactor: selector

* refactor: locale improve

* refactor: on demand loading of relational data

* refactor: locale improve

* refactor: select button

* refactor: association field

* refactor: formformBlock provider

* refactor: formformBlock provider

* refactor: internalSelect recordPicker

* refactor: formBlocklockProvider

* fix: addNewer schema

* fix: useServiceOptions

* fix: useCreateActionProps

* fix: useCreateActionProps

* refactor: nester delete

* refactor: nester delete in detail

* refactor: subTable suport select

* refactor: subTable suport select

* style: style improve

* style: style improve

* chore: fileManger

* fix: association readPrety

* fix: filemanger

* refactor: field mode

* refactor: enable link

* chore: error message

* refactor: association schemaInitialize

* refactor: association schemaInitialize

* refactor: currentMode

* refactor: field mode default value

* fix: file manage readPretty

* fix: appends

* chore: file manage readPretty

* fix: updateAssociationValues

* fix: updateAssociationValues

* fix: updateAssociationValues

* fix: nester appends

* fix: nester appends

* fix:  tree collection association fields

* fix:  tree collection association fields

* fix: nester appends

* fix: subtable to select field value missing

* fix: subtable to select field value missing

* fix: compatible with historical blocks

* fix: compatible with historical blocks

* fix: compatible with historical blocks

* feat: add migration

* fix: filter block allow add new

* fix: compatible with historical blocks

* fix: skip if not RecordPicker

* fix: compatible with historical blocks

* fix: detail block not support nester

* fix: association select support data scope and sort setting

* fix: appends on demand loading

* fix: asociationSelect support multiple

* fix: recordPicker -> AssociationField

* fix: add migration

* fix: audit logs not show assication data

* fix: flattenNestedList

* refactor: file manager field mode

* refactor: field mode refactor

* fix: subtable action

* fix: subtable appends

* refactor: code improve

* fix: nester add new

* feat: sub table

* fix: data scope not effect immediately

* fix: association add new

* fix: association field failed to  add new and mutual influence

* style: style improve

* style: style improve

* refactor: updateAssociationValues

* refactor: form init values

* refactor: select options

* fix: form initialValues

* fix: record picker values

* fix: field value change when field mode change

* fix: select data scope

* feat: add migration

* fix: table column enable link

* fix: table column enable link

* refactor: locale improve

* fix: migration

* fix: mutiple config

* fix: readPretty enable link

* fix: appends on demand

* fix: enable link style

* refactor: locale improve

* refactor: locale improve

* feat: sub-form migration

* fix: skip migration

* fix: translation

* fix: skip migration

* fix: getLabelFormatValue

* fix: error TS2339: Property 'find' does not exist on type 'string | SchemaEnum<any>'

* refactor: remove the logic code for converting old record picker

* refactor: locale

* refactor: locale

* fix: sub-table should not support add new

* refactor: code improve

* refactor: locale

* fix: compatibility history Subtable

* fix: improve

---------

Co-authored-by: chenos <chenlinxh@gmail.com>
Co-authored-by: Chareice <chareice@live.com>
2023-05-11 12:47:31 +08:00

167 lines
4.2 KiB
TypeScript

import { useAuditLogsTranslation } from './locale';
export const useAuditLogsCollection = () => {
return {
name: 'auditLogs',
title: '{{t("Audit logs")}}',
fields: [
{
name: 'createdAt',
type: 'date',
interface: 'createdAt',
uiSchema: {
type: 'datetime',
title: '{{t("Created at")}}',
'x-component': 'DatePicker',
'x-component-props': {
showTime: true,
ellipsis: true,
},
'x-read-pretty': true,
},
},
{
name: 'type',
type: 'string',
interface: 'select',
uiSchema: {
type: 'string',
title: '{{t("Action type")}}',
'x-component': 'Select',
'x-component-props': { ellipsis: true },
'x-read-pretty': true,
enum: [
{ label: '{{t("Create record")}}', value: 'create', color: 'lime' },
{ label: '{{t("Update record")}}', value: 'update', color: 'gold' },
{ label: '{{t("Delete record")}}', value: 'destroy', color: 'magenta' },
],
},
},
{
name: 'recordId',
type: 'string',
interface: 'input',
uiSchema: {
title: '{{t("Record ID")}}',
type: 'string',
'x-component': 'Input',
'x-component-props': { ellipsis: true },
},
},
{
collectionName: 'auditLogs',
name: 'collection',
type: 'belongsTo',
interface: 'm2o',
target: 'collections',
targetKey: 'name',
sourceKey: 'id',
foreignKey: 'collectionName',
uiSchema: {
type: 'object',
title: '{{t("Collection")}}',
'x-component': 'AssociationField',
'x-component-props': { fieldNames: { value: 'name', label: 'title' }, ellipsis: true },
'x-read-pretty': true,
},
},
{
name: 'user',
collectionName: 'auditLogs',
type: 'belongsTo',
interface: 'createdBy',
targetKey: 'id',
foreignKey: 'createdById',
target: 'users',
uiSchema: {
type: 'object',
title: '{{t("User")}}',
'x-component': 'AssociationField',
'x-component-props': { fieldNames: { value: 'id', label: 'nickname' }, ellipsis: true },
'x-read-pretty': true,
},
},
{
name: 'changes',
collectionName: 'auditLogs',
type: 'hasMany',
interface: 'subTable',
target: 'auditChanges',
foreignKey: 'auditLogId',
targetKey: 'id',
uiSchema: {
type: 'object',
title: '{{t("Details of changes", { ns: "audit-logs" })}}',
},
},
],
};
};
export const useAuditChangesCollection = () => {
return {
name: 'auditChanges',
title: '{{t("Audit Changes")}}',
fields: [
{
name: 'field',
type: 'json',
interface: 'input',
uiSchema: {
title: '{{t("Field")}}',
'x-component': 'AuditLogsField',
},
},
{
type: 'json',
name: 'before',
interface: 'input',
uiSchema: {
title: '{{t("Before change")}}',
'x-component': 'AuditLogsValue',
},
},
{
type: 'json',
name: 'after',
interface: 'input',
uiSchema: {
title: '{{t("After change")}}',
'x-component': 'AuditLogsValue',
},
},
],
};
};
export const useCollectionsCollection = () => {
return {
name: 'collections',
title: '{{t("Collections")}}',
fields: [
{
name: 'name',
type: 'string',
interface: 'input',
uiSchema: {
title: '{{t("Collection name")}}',
type: 'string',
'x-component': 'Input',
'x-component-props': { ellipsis: true },
},
},
{
name: 'title',
type: 'string',
interface: 'input',
uiSchema: {
title: '{{t("Collection display name")}}',
type: 'string',
'x-component': 'Input',
'x-component-props': { ellipsis: true },
},
},
],
};
};