7 Star 54 Fork 8

tegojs/tego

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ImageSearch.configure.ts 1.49 KB
一键复制 编辑 原始数据 按行查看 历史
sealday 提交于 2024-12-15 02:00 +08:00 . refactor: module web (#1908)
import { SchemaInitializer, useCollection, useCollectionManager, useIsMobile } from '@tachybase/client';
import { canBeOptionalField, canBeRelatedField } from '../tab-search/utils';
import { createSchemaImageSearchItem } from './search-item/ImageSearchItem.schema';
export const ImageSearchConfigureFields = new SchemaInitializer({
name: 'ImageSearchView:configureFields',
title: '{{t("Configure fields")}}',
style: { marginTop: 16 },
icon: 'SettingOutlined',
items: [
{
name: 'choicesFields',
type: 'itemGroup',
title: '{{t("Choices fields")}}',
useChildren: useChildrenChoicesFieldSchemas,
},
],
});
function useChildrenChoicesFieldSchemas() {
const collection = useCollection();
const fields = collection?.fields;
const cm = useCollectionManager();
const isMobile = useIsMobile();
const choicesFieldsSchemas = fields
.map((field) => {
const { interface: _interface, target: collectionName } = field;
const label = cm.getCollection(collectionName)?.getPrimaryKey() ?? 'id';
const isCanBeOptional = canBeOptionalField(_interface);
const isCanBeRelated = canBeRelatedField(_interface);
if (isCanBeOptional || isCanBeRelated) {
const schema = createSchemaImageSearchItem({
collection,
field,
isMobile,
label,
isCanBeOptional,
isCanBeRelated,
});
return schema;
}
return null;
})
.filter(Boolean);
return choicesFieldsSchemas;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tegojs/tego.git
git@gitee.com:tegojs/tego.git
tegojs
tego
tego
ae41919bafbb911d2d9800902b8391a905392f6c

搜索帮助