refactor(client): change isTitleField check to interface property titleUsable (#2250)
This commit is contained in:
parent
9b5e923e91
commit
b63012d85a
@ -57,14 +57,11 @@ const tableContainer = css`
|
||||
`;
|
||||
|
||||
const titlePrompt = 'Default title for each record';
|
||||
// 只有下面类型的字段才可以设置为标题字段
|
||||
const expectTypes = ['string', 'integer', 'bigInt', 'float', 'double', 'decimal', 'date', 'dateonly', 'time'];
|
||||
const excludeInterfaces = ['icon'];
|
||||
|
||||
// 是否可以作为标题字段
|
||||
export const isTitleField = (field) => {
|
||||
if (!field) return false;
|
||||
return !field.isForeignKey && expectTypes.includes(field.type) && !excludeInterfaces.includes(field.interface);
|
||||
const { getInterface } = useCollectionManager();
|
||||
return !field.isForeignKey && getInterface(field.interface)?.titleUsable;
|
||||
};
|
||||
|
||||
const CurrentFields = (props) => {
|
||||
|
@ -28,4 +28,5 @@ export const createdAt: IField = {
|
||||
filterable: {
|
||||
operators: operators.datetime,
|
||||
},
|
||||
titleUsable: true,
|
||||
};
|
||||
|
@ -37,4 +37,5 @@ export const datetime: IField = {
|
||||
filterable: {
|
||||
operators: operators.datetime,
|
||||
},
|
||||
titleUsable: true,
|
||||
};
|
||||
|
@ -28,6 +28,7 @@ export const email: IField = {
|
||||
filterable: {
|
||||
operators: operators.string,
|
||||
},
|
||||
titleUsable: true,
|
||||
schemaInitialize(schema: ISchema, { block }) {
|
||||
if (['Table', 'Kanban'].includes(block)) {
|
||||
schema['x-component-props'] = schema['x-component-props'] || {};
|
||||
|
@ -45,4 +45,5 @@ export const id: IField = {
|
||||
filterable: {
|
||||
operators: operators.id,
|
||||
},
|
||||
titleUsable: true,
|
||||
};
|
||||
|
@ -27,6 +27,7 @@ export const input: IField = {
|
||||
filterable: {
|
||||
operators: operators.string,
|
||||
},
|
||||
titleUsable: true,
|
||||
schemaInitialize(schema: ISchema, { block }) {
|
||||
if (['Table', 'Kanban'].includes(block)) {
|
||||
schema['x-component-props'] = schema['x-component-props'] || {};
|
||||
|
@ -38,6 +38,7 @@ export const integer: IField = {
|
||||
filterable: {
|
||||
operators: operators.number,
|
||||
},
|
||||
titleUsable: true,
|
||||
validateSchema(fieldSchema) {
|
||||
return {
|
||||
maximum: {
|
||||
|
@ -46,6 +46,7 @@ export const number: IField = {
|
||||
filterable: {
|
||||
operators: operators.number,
|
||||
},
|
||||
titleUsable: true,
|
||||
validateSchema(fieldSchema) {
|
||||
return {
|
||||
maximum: {
|
||||
|
@ -99,6 +99,7 @@ export const percent: IField = {
|
||||
filterable: {
|
||||
operators: operators.number,
|
||||
},
|
||||
titleUsable: true,
|
||||
validateSchema(fieldSchema) {
|
||||
return {
|
||||
maxValue: {
|
||||
|
@ -30,4 +30,5 @@ export const phone: IField = {
|
||||
filterable: {
|
||||
operators: operators.string,
|
||||
},
|
||||
titleUsable: true,
|
||||
};
|
||||
|
@ -26,4 +26,5 @@ export const radioGroup: IField = {
|
||||
filterable: {
|
||||
operators: operators.enumType,
|
||||
},
|
||||
titleUsable: true,
|
||||
};
|
||||
|
@ -28,6 +28,7 @@ export const select: IField = {
|
||||
filterable: {
|
||||
operators: operators.enumType,
|
||||
},
|
||||
titleUsable: true,
|
||||
schemaInitialize(schema: ISchema, { block }) {
|
||||
const props = (schema['x-component-props'] = schema['x-component-props'] || {});
|
||||
props.style = {
|
||||
|
@ -41,4 +41,5 @@ export const time: IField = {
|
||||
filterable: {
|
||||
operators: operators.time,
|
||||
},
|
||||
titleUsable: true,
|
||||
};
|
||||
|
@ -12,5 +12,7 @@ export interface IField extends ISchema {
|
||||
filterable?: any;
|
||||
/** 不支持使用变量的值进行设置 */
|
||||
invariable?: boolean;
|
||||
// NOTE: set to `true` means field could be used as a title field
|
||||
titleUsable?: boolean;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
@ -28,4 +28,5 @@ export const updatedAt: IField = {
|
||||
filterable: {
|
||||
operators: operators.datetime,
|
||||
},
|
||||
titleUsable: true,
|
||||
};
|
||||
|
@ -19,4 +19,5 @@ export const url: IField = {
|
||||
properties: {
|
||||
...defaultProps,
|
||||
},
|
||||
titleUsable: true,
|
||||
};
|
||||
|
@ -197,4 +197,5 @@ export default {
|
||||
filterable: {
|
||||
operators: operators.number,
|
||||
},
|
||||
titleUsable: true,
|
||||
} as IField;
|
||||
|
@ -280,6 +280,10 @@ export const sequence: IField = {
|
||||
},
|
||||
},
|
||||
hasDefaultValue: false,
|
||||
filterable: {
|
||||
operators: interfacesProperties.operators.string,
|
||||
},
|
||||
titleUsable: true,
|
||||
schemaInitialize(schema: ISchema, { block, field }) {
|
||||
if (block === 'Form') {
|
||||
Object.assign(schema['x-component-props'], {
|
||||
@ -405,7 +409,4 @@ export const sequence: IField = {
|
||||
},
|
||||
},
|
||||
},
|
||||
filterable: {
|
||||
operators: interfacesProperties.operators.string,
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user