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 { useCollection, useCollectionManager } from '.';
|
||||||
import { useRequest } from '../api-client';
|
import { useRequest } from '../api-client';
|
||||||
import { useRecord } from '../record-provider';
|
import { useRecord } from '../record-provider';
|
||||||
|
import { useCompile } from '..';
|
||||||
import { useActionContext } from '../schema-component';
|
import { useActionContext } from '../schema-component';
|
||||||
import { useFilterFieldOptions, useFilterFieldProps } from '../schema-component/antd/filter/useFilterActionProps';
|
import { useFilterFieldOptions, useFilterFieldProps } from '../schema-component/antd/filter/useFilterActionProps';
|
||||||
import { useResourceActionContext, useResourceContext } from './ResourceActionProvider';
|
import { useResourceActionContext, useResourceContext } from './ResourceActionProvider';
|
||||||
@ -155,7 +156,48 @@ export const useCollectionFilterOptions = (collectionName: string) => {
|
|||||||
});
|
});
|
||||||
return options;
|
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) => {
|
export const useFilterDataSource = (options) => {
|
||||||
|
@ -99,6 +99,7 @@ export default {
|
|||||||
"Data blocks": "Data blocks",
|
"Data blocks": "Data blocks",
|
||||||
"Filter blocks": "Filter blocks",
|
"Filter blocks": "Filter blocks",
|
||||||
"Table": "Table",
|
"Table": "Table",
|
||||||
|
"Table OID(Inheritance)":"Table OID(Inheritance)",
|
||||||
"Form": "Form",
|
"Form": "Form",
|
||||||
"Collapse": "Collapse",
|
"Collapse": "Collapse",
|
||||||
"Select data source": "Select data source",
|
"Select data source": "Select data source",
|
||||||
|
@ -102,6 +102,7 @@ export default {
|
|||||||
"Set the data scope": "データ範囲の設定",
|
"Set the data scope": "データ範囲の設定",
|
||||||
"Data blocks": "データブロック",
|
"Data blocks": "データブロック",
|
||||||
"Filter blocks": "フィルターブロック",
|
"Filter blocks": "フィルターブロック",
|
||||||
|
"Table OID(Inheritance)":"データテーブルOID(継承)",
|
||||||
"Table": "テーブル",
|
"Table": "テーブル",
|
||||||
"Form": "フォーム",
|
"Form": "フォーム",
|
||||||
"Collapse": "折りたたみ",
|
"Collapse": "折りたたみ",
|
||||||
|
@ -111,6 +111,7 @@ export default {
|
|||||||
"Filter blocks": "筛选区块",
|
"Filter blocks": "筛选区块",
|
||||||
"Table": "表格",
|
"Table": "表格",
|
||||||
"Form": "表单",
|
"Form": "表单",
|
||||||
|
"Table OID(Inheritance)":"数据表 OID(继承)",
|
||||||
"Collapse": "折叠面板",
|
"Collapse": "折叠面板",
|
||||||
"Select data source": "选择数据源",
|
"Select data source": "选择数据源",
|
||||||
"Calendar": "日历",
|
"Calendar": "日历",
|
||||||
|
@ -2,7 +2,7 @@ import { CloseCircleOutlined } from '@ant-design/icons';
|
|||||||
import { css } from '@emotion/css';
|
import { css } from '@emotion/css';
|
||||||
import { observer } from '@formily/react';
|
import { observer } from '@formily/react';
|
||||||
import { Cascader, Select, Space } from 'antd';
|
import { Cascader, Select, Space } from 'antd';
|
||||||
import React, { useContext } from 'react';
|
import React, { useContext, useEffect } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useCompile } from '../..';
|
import { useCompile } from '../..';
|
||||||
import { RemoveConditionContext } from './context';
|
import { RemoveConditionContext } from './context';
|
||||||
|
@ -2,6 +2,7 @@ import { Field } from '@formily/core';
|
|||||||
import { useField, useFieldSchema } from '@formily/react';
|
import { useField, useFieldSchema } from '@formily/react';
|
||||||
import flat from 'flat';
|
import flat from 'flat';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { useCompile } from '../..';
|
||||||
import { useBlockRequestContext } from '../../../block-provider';
|
import { useBlockRequestContext } from '../../../block-provider';
|
||||||
import { mergeFilter } from '../../../block-provider/SharedFilterProvider';
|
import { mergeFilter } from '../../../block-provider/SharedFilterProvider';
|
||||||
import { useCollection, useCollectionManager } from '../../../collection-manager';
|
import { useCollection, useCollectionManager } from '../../../collection-manager';
|
||||||
@ -9,7 +10,48 @@ import { useCollection, useCollectionManager } from '../../../collection-manager
|
|||||||
export const useFilterOptions = (collectionName: string) => {
|
export const useFilterOptions = (collectionName: string) => {
|
||||||
const { getCollectionFields } = useCollectionManager();
|
const { getCollectionFields } = useCollectionManager();
|
||||||
const fields = getCollectionFields(collectionName);
|
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) => {
|
export const useFilterFieldOptions = (fields) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user