From bd6ffcef83fc365af7c69f9fa94e95b520a9d0c3 Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Sat, 6 Apr 2024 16:26:24 +0800 Subject: [PATCH] fix(collection manager): collection manager primarykey & nanoid & uuid suport index setting (#3943) * fix: formula field caluation error * fix: collection manager primarykey * fix: nanoid & uuid suport index --- .../src/collection-manager/interfaces/nanoid.ts | 17 ++++++++++++++++- .../interfaces/properties/index.ts | 2 +- .../src/collection-manager/interfaces/uuid.ts | 17 ++++++++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/packages/core/client/src/collection-manager/interfaces/nanoid.ts b/packages/core/client/src/collection-manager/interfaces/nanoid.ts index 773a75985a..13c89b9bd4 100644 --- a/packages/core/client/src/collection-manager/interfaces/nanoid.ts +++ b/packages/core/client/src/collection-manager/interfaces/nanoid.ts @@ -1,5 +1,5 @@ import { CollectionFieldInterface } from '../../data-source/collection-field-interface/CollectionFieldInterface'; -import { operators, autoFill } from './properties'; +import { operators, autoFill, primaryKey, unique } from './properties'; export class NanoidFieldInterface extends CollectionFieldInterface { name = 'nanoid'; type = 'object'; @@ -49,6 +49,21 @@ export class NanoidFieldInterface extends CollectionFieldInterface { 'x-component': 'InputNumber', }, autoFill, + layout: { + type: 'void', + title: '{{t("Index")}}', + 'x-component': 'Space', + 'x-decorator': 'FormItem', + 'x-decorator-props': { + style: { + marginBottom: '0px', + }, + }, + properties: { + primaryKey, + unique, + }, + }, }; filterable = { operators: operators.string, diff --git a/packages/core/client/src/collection-manager/interfaces/properties/index.ts b/packages/core/client/src/collection-manager/interfaces/properties/index.ts index f8d0880efa..c448927894 100644 --- a/packages/core/client/src/collection-manager/interfaces/properties/index.ts +++ b/packages/core/client/src/collection-manager/interfaces/properties/index.ts @@ -60,7 +60,7 @@ export const primaryKey = { 'x-reactions': [ { dependencies: ['unique'], - when: '{{$deps[0]}}', + when: '{{$deps[0]&&createMainOnly}}', fulfill: { state: { value: false, diff --git a/packages/core/client/src/collection-manager/interfaces/uuid.ts b/packages/core/client/src/collection-manager/interfaces/uuid.ts index 730b1c5a3a..2f1cb68d64 100644 --- a/packages/core/client/src/collection-manager/interfaces/uuid.ts +++ b/packages/core/client/src/collection-manager/interfaces/uuid.ts @@ -1,5 +1,5 @@ import { CollectionFieldInterface } from '../../data-source/collection-field-interface/CollectionFieldInterface'; -import { operators, autoFill } from './properties'; +import { operators, autoFill, primaryKey, unique } from './properties'; export class UUIDFieldInterface extends CollectionFieldInterface { name = 'uuid'; @@ -37,6 +37,21 @@ export class UUIDFieldInterface extends CollectionFieldInterface { "{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}", }, autoFill, + layout: { + type: 'void', + title: '{{t("Index")}}', + 'x-component': 'Space', + 'x-decorator': 'FormItem', + 'x-decorator-props': { + style: { + marginBottom: '0px', + }, + }, + properties: { + primaryKey, + unique, + }, + }, }; filterable = { operators: operators.string,