From 14f492f4140e908edd5d2a83811abcf9dd006438 Mon Sep 17 00:00:00 2001 From: semmywong <67748948+semmywong@users.noreply.github.com> Date: Sat, 30 Oct 2021 10:55:43 +0800 Subject: [PATCH] fix: add sort field to the users table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [Fixed] 1、初始化数据表时,没有配置sort 2、增加sort接口类型 * [Fixed] 1、重新提交PR * [Fixed] 1、重新提交PR * [Fixed] 1、重新提交PR * [Fixed] 1、重新提交PR * [Fixed] 1、重新提交PR --- packages/client/src/schemas/calendar/index.tsx | 4 ++-- packages/client/src/schemas/table/index.tsx | 6 +++--- packages/plugin-collections/src/server.ts | 6 ++++-- packages/plugin-users/src/collections/users.ts | 1 + 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/client/src/schemas/calendar/index.tsx b/packages/client/src/schemas/calendar/index.tsx index 42bd1210b..59d282c89 100644 --- a/packages/client/src/schemas/calendar/index.tsx +++ b/packages/client/src/schemas/calendar/index.tsx @@ -374,7 +374,7 @@ export const fieldsToFilterColumns = (fields: any[], options: any = {}) => { return; } const fieldOption = interfaces.get(field.interface); - if (!fieldOption.operations) { + if (!fieldOption?.operations) { return; } properties[`column${index}`] = { @@ -493,7 +493,7 @@ Calendar.Filter.DesignableBar = () => { {fields .filter((collectionField) => { const option = interfaces.get(collectionField.interface); - return option.operations?.length; + return option?.operations?.length; }) .map((collectionField) => ( { return; } const fieldOption = interfaces.get(field.interface); - if (!fieldOption.operations) { + if (!fieldOption?.operations) { return; } properties[`column${index}`] = { @@ -1436,7 +1436,7 @@ const fieldsToSortColumns = (fields: any[]) => { fields.forEach((field) => { const fieldOption = interfaces.get(field.interface); - if (!fieldOption.sortable) { + if (!fieldOption?.sortable) { return; } dataSource.push({ @@ -1546,7 +1546,7 @@ Table.Filter.DesignableBar = () => { {fields .filter((collectionField) => { const option = interfaces.get(collectionField.interface); - return option.operations?.length; + return option?.operations?.length; }) .map((collectionField) => ( field.type !== 'sort'); await collection.updateAssociations({ - generalFields: config.fields.filter((field) => field.state !== 0), - systemFields: config.fields.filter((field) => field.state === 0), + generalFields: fields.filter((field) => field.state !== 0), + systemFields: fields.filter((field) => field.state === 0), }); // await collection.migrate(); } diff --git a/packages/plugin-users/src/collections/users.ts b/packages/plugin-users/src/collections/users.ts index 757cbcf90..452a6e0dd 100644 --- a/packages/plugin-users/src/collections/users.ts +++ b/packages/plugin-users/src/collections/users.ts @@ -3,6 +3,7 @@ import { TableOptions } from '@nocobase/database'; export default { name: 'users', title: '用户', + sortable: 'sort', // developerMode: true, // internal: true, createdBy: false,