feat: support tableoid filter (#1657)
* feat: support inherited collection filter * refactor: improve translation * chore: filter inherted collectiion * feat: data scope support inherited collection filter
This commit is contained in:
parent
0d0c5ff9e0
commit
1d6417f7f9
@ -5,6 +5,7 @@ import { useEffect } from 'react';
|
||||
import { useCollection, useCollectionManager } from '.';
|
||||
import { useRequest } from '../api-client';
|
||||
import { useRecord } from '../record-provider';
|
||||
import { useCompile } from '..';
|
||||
import { useActionContext } from '../schema-component';
|
||||
import { useFilterFieldOptions, useFilterFieldProps } from '../schema-component/antd/filter/useFilterActionProps';
|
||||
import { useResourceActionContext, useResourceContext } from './ResourceActionProvider';
|
||||
@ -155,7 +156,48 @@ export const useCollectionFilterOptions = (collectionName: string) => {
|
||||
});
|
||||
return options;
|
||||
};
|
||||
return getOptions(fields, 1);
|
||||
const options = getOptions(fields, 1);
|
||||
const compile = useCompile();
|
||||
const { getChildrenCollections } = useCollectionManager();
|
||||
const collection = useCollection();
|
||||
const childrenCollections = getChildrenCollections(collection.name);
|
||||
if (childrenCollections.length > 0 && !options.find((v) => v.name == 'tableoid')) {
|
||||
options.push({
|
||||
name: 'tableoid',
|
||||
type: 'string',
|
||||
title: '{{t("Table OID(Inheritance)")}}',
|
||||
schema: {
|
||||
'x-component': 'Select',
|
||||
enum: [{ value: collection.name, label: compile(collection.title) }].concat(
|
||||
childrenCollections.map((v) => {
|
||||
return {
|
||||
value: v.name,
|
||||
label: compile(v.title),
|
||||
};
|
||||
}),
|
||||
),
|
||||
},
|
||||
operators: [
|
||||
{
|
||||
label: '{{t("contains")}}',
|
||||
value: '$childIn',
|
||||
schema: {
|
||||
'x-component': 'Select',
|
||||
'x-component-props': { mode: 'tags' },
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '{{t("does not contain")}}',
|
||||
value: '$childNotIn',
|
||||
schema: {
|
||||
'x-component': 'Select',
|
||||
'x-component-props': { mode: 'tags' },
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
return options;
|
||||
};
|
||||
|
||||
export const useFilterDataSource = (options) => {
|
||||
|
@ -99,6 +99,7 @@ export default {
|
||||
"Data blocks": "Data blocks",
|
||||
"Filter blocks": "Filter blocks",
|
||||
"Table": "Table",
|
||||
"Table OID(Inheritance)":"Table OID(Inheritance)",
|
||||
"Form": "Form",
|
||||
"Collapse": "Collapse",
|
||||
"Select data source": "Select data source",
|
||||
|
@ -102,6 +102,7 @@ export default {
|
||||
"Set the data scope": "データ範囲の設定",
|
||||
"Data blocks": "データブロック",
|
||||
"Filter blocks": "フィルターブロック",
|
||||
"Table OID(Inheritance)":"データテーブルOID(継承)",
|
||||
"Table": "テーブル",
|
||||
"Form": "フォーム",
|
||||
"Collapse": "折りたたみ",
|
||||
|
@ -111,6 +111,7 @@ export default {
|
||||
"Filter blocks": "筛选区块",
|
||||
"Table": "表格",
|
||||
"Form": "表单",
|
||||
"Table OID(Inheritance)":"数据表 OID(继承)",
|
||||
"Collapse": "折叠面板",
|
||||
"Select data source": "选择数据源",
|
||||
"Calendar": "日历",
|
||||
|
@ -2,7 +2,7 @@ import { CloseCircleOutlined } from '@ant-design/icons';
|
||||
import { css } from '@emotion/css';
|
||||
import { observer } from '@formily/react';
|
||||
import { Cascader, Select, Space } from 'antd';
|
||||
import React, { useContext } from 'react';
|
||||
import React, { useContext, useEffect } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useCompile } from '../..';
|
||||
import { RemoveConditionContext } from './context';
|
||||
|
@ -2,6 +2,7 @@ import { Field } from '@formily/core';
|
||||
import { useField, useFieldSchema } from '@formily/react';
|
||||
import flat from 'flat';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useCompile } from '../..';
|
||||
import { useBlockRequestContext } from '../../../block-provider';
|
||||
import { mergeFilter } from '../../../block-provider/SharedFilterProvider';
|
||||
import { useCollection, useCollectionManager } from '../../../collection-manager';
|
||||
@ -9,7 +10,48 @@ import { useCollection, useCollectionManager } from '../../../collection-manager
|
||||
export const useFilterOptions = (collectionName: string) => {
|
||||
const { getCollectionFields } = useCollectionManager();
|
||||
const fields = getCollectionFields(collectionName);
|
||||
return useFilterFieldOptions(fields);
|
||||
const options=useFilterFieldOptions(fields)
|
||||
const compile = useCompile();
|
||||
const { getChildrenCollections } = useCollectionManager();
|
||||
const collection = useCollection();
|
||||
const childrenCollections = getChildrenCollections(collection.name);
|
||||
if (childrenCollections.length > 0 && !options.find((v) => v.name == 'tableoid')) {
|
||||
options.push({
|
||||
name: 'tableoid',
|
||||
type: 'string',
|
||||
title: '{{t("Table OID(Inheritance)")}}',
|
||||
schema: {
|
||||
'x-component': 'Select',
|
||||
enum: [{ value: collection.name, label: compile(collection.title) }].concat(
|
||||
childrenCollections.map((v) => {
|
||||
return {
|
||||
value: v.name,
|
||||
label: compile(v.title),
|
||||
};
|
||||
}),
|
||||
),
|
||||
},
|
||||
operators: [
|
||||
{
|
||||
label: '{{t("contains")}}',
|
||||
value: '$childIn',
|
||||
schema: {
|
||||
'x-component': 'Select',
|
||||
'x-component-props': { mode: 'tags' },
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '{{t("does not contain")}}',
|
||||
value: '$childNotIn',
|
||||
schema: {
|
||||
'x-component': 'Select',
|
||||
'x-component-props': { mode: 'tags' },
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
return options;
|
||||
};
|
||||
|
||||
export const useFilterFieldOptions = (fields) => {
|
||||
|
Loading…
Reference in New Issue
Block a user