From 395ddb4a603da1caa61098391d50c69af8609523 Mon Sep 17 00:00:00 2001 From: yxh01132861 Date: Fri, 15 Sep 2023 14:30:10 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=E7=AD=9B=E9=80=89=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Component/FilterCard/index.tsx | 11 +++-- .../widgets/FilterWidget/Component/index.tsx | 43 +++++++++++-------- .../src/widgets/FilterWidget/index.tsx | 7 ++- .../src/widgets/FilterWidget/registerForm.ts | 32 ++++++++++++++ 4 files changed, 70 insertions(+), 23 deletions(-) create mode 100644 packages/li-analysis-assets/src/widgets/FilterWidget/registerForm.ts diff --git a/packages/li-analysis-assets/src/widgets/FilterWidget/Component/FilterCard/index.tsx b/packages/li-analysis-assets/src/widgets/FilterWidget/Component/FilterCard/index.tsx index 57a128cc..9824443f 100644 --- a/packages/li-analysis-assets/src/widgets/FilterWidget/Component/FilterCard/index.tsx +++ b/packages/li-analysis-assets/src/widgets/FilterWidget/Component/FilterCard/index.tsx @@ -17,12 +17,13 @@ const EMPTY_DATASET_FILTER: DatasetFilter = { relation: 'AND', children: [] }; type FilterCardProps = { id: string; + showDeleteFilter: boolean; datasetOptions: { id: string; name: string }[]; selectedDatasets: string[]; onDel: () => void; }; -const FilterCard = ({ id, datasetOptions, selectedDatasets, onDel }: FilterCardProps) => { +const FilterCard = ({ id, showDeleteFilter, datasetOptions, selectedDatasets, onDel }: FilterCardProps) => { const { token } = useToken(); const [datasetId, setDatasetId] = useState(id); // TODO: 筛选条件不进行筛选自己,获取全量数据 @@ -97,9 +98,11 @@ const FilterCard = ({ id, datasetOptions, selectedDatasets, onDel }: FilterCardP ]} onChange={(val: DatasetFilter['relation']) => onRelationChange(val)} /> - - - + + + )} ); -} +}; + +export default FilterWidget; diff --git a/packages/li-analysis-assets/src/widgets/FilterWidget/index.tsx b/packages/li-analysis-assets/src/widgets/FilterWidget/index.tsx index 80ea370f..b048e078 100644 --- a/packages/li-analysis-assets/src/widgets/FilterWidget/index.tsx +++ b/packages/li-analysis-assets/src/widgets/FilterWidget/index.tsx @@ -1,5 +1,6 @@ import { implementWidget } from '@antv/li-sdk'; import component from './Component/index'; +import registerForm from './registerForm'; export default implementWidget({ version: 'v0.1', @@ -10,6 +11,10 @@ export default implementWidget({ type: 'Atom', category: 'DataAnalysis', }, + defaultProperties: { + showAddFilter: false, + showDeleteFilter: false, + }, component, - registerForm: { schema: {} }, + registerForm, }); diff --git a/packages/li-analysis-assets/src/widgets/FilterWidget/registerForm.ts b/packages/li-analysis-assets/src/widgets/FilterWidget/registerForm.ts new file mode 100644 index 00000000..05518f14 --- /dev/null +++ b/packages/li-analysis-assets/src/widgets/FilterWidget/registerForm.ts @@ -0,0 +1,32 @@ +import type { WidgetRegisterForm, WidgetRegisterFormProps } from '@antv/li-sdk'; + +/** + * 属性面板生产的数据类型定义 + */ +export type Properties = { + /** 新增过滤器 */ + showAddFilter: boolean; + /** 删除过滤器 */ + showDeleteFilter: boolean; +}; + +export default (props: WidgetRegisterFormProps): WidgetRegisterForm => { + // 属性面板表单的 Schema 定义,来自表单库 formily 的 Schema + const schema = { + showAddFilter: { + title: '新增过滤器', + type: 'boolean', + 'x-decorator': 'FormItem', + 'x-component': 'Switch', + default: false, + }, + showDeleteFilter: { + title: '删除过滤器', + type: 'boolean', + 'x-decorator': 'FormItem', + 'x-component': 'Switch', + default: false, + }, + }; + return { schema }; +}; From bb90a35782cf3f0b6f44ea01b359e3d729933d0a Mon Sep 17 00:00:00 2001 From: yxh01132861 Date: Fri, 15 Sep 2023 14:51:04 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20list=20=E7=AD=9B=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FilterWidget/Component/FilterCard/index.tsx | 12 +++++++++++- .../src/widgets/FilterWidget/Component/index.tsx | 1 + .../src/components/Filter/FilterItem/index.tsx | 15 +++++++++------ .../src/components/Filter/FilterList/index.tsx | 13 ++++++++++--- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/packages/li-analysis-assets/src/widgets/FilterWidget/Component/FilterCard/index.tsx b/packages/li-analysis-assets/src/widgets/FilterWidget/Component/FilterCard/index.tsx index 9824443f..d761cc52 100644 --- a/packages/li-analysis-assets/src/widgets/FilterWidget/Component/FilterCard/index.tsx +++ b/packages/li-analysis-assets/src/widgets/FilterWidget/Component/FilterCard/index.tsx @@ -18,12 +18,20 @@ const EMPTY_DATASET_FILTER: DatasetFilter = { relation: 'AND', children: [] }; type FilterCardProps = { id: string; showDeleteFilter: boolean; + showAddFilter: boolean; datasetOptions: { id: string; name: string }[]; selectedDatasets: string[]; onDel: () => void; }; -const FilterCard = ({ id, showDeleteFilter, datasetOptions, selectedDatasets, onDel }: FilterCardProps) => { +const FilterCard = ({ + id, + showDeleteFilter, + showAddFilter, + datasetOptions, + selectedDatasets, + onDel, +}: FilterCardProps) => { const { token } = useToken(); const [datasetId, setDatasetId] = useState(id); // TODO: 筛选条件不进行筛选自己,获取全量数据 @@ -109,6 +117,8 @@ const FilterCard = ({ id, showDeleteFilter, datasetOptions, selectedDatasets, on {!isUnselectedDataset(datasetId) && ( { key={id} id={id} showDeleteFilter={showDeleteFilter} + showAddFilter={showAddFilter} selectedDatasets={selectedDatasets} datasetOptions={datasetOptions} onDel={() => { diff --git a/packages/li-p2/src/components/Filter/FilterItem/index.tsx b/packages/li-p2/src/components/Filter/FilterItem/index.tsx index 024dfb80..c49fd7b2 100644 --- a/packages/li-p2/src/components/Filter/FilterItem/index.tsx +++ b/packages/li-p2/src/components/Filter/FilterItem/index.tsx @@ -13,6 +13,7 @@ const { useToken } = theme; export const CLS_PREFIX = 'li-filter-item'; export type FilterItemProps = { + showDeleteFilter: boolean; defaultValue: FilterNode; data: Record[]; columns: ColumnType[]; @@ -22,7 +23,7 @@ export type FilterItemProps = { }; export const FilterItem = (props: FilterItemProps) => { - const { defaultValue, data, columns, selectedFields = [], onDelField } = props; + const { showDeleteFilter, defaultValue, data, columns, selectedFields = [], onDelField } = props; const [filterNode, setFilterNode] = useState(defaultValue); const field = isEmpty(filterNode.field) ? undefined : filterNode.field; const { token } = useToken(); @@ -96,11 +97,13 @@ export const FilterItem = (props: FilterItemProps) => {
过滤字段 -
- - - -
+ {showDeleteFilter && ( +
+ + + +
+ )}
diff --git a/packages/li-p2/src/components/Filter/FilterList/index.tsx b/packages/li-p2/src/components/Filter/FilterList/index.tsx index 60ce2c4c..a5cc161d 100644 --- a/packages/li-p2/src/components/Filter/FilterList/index.tsx +++ b/packages/li-p2/src/components/Filter/FilterList/index.tsx @@ -10,6 +10,8 @@ export const CLS_PREFIX = 'li-filter-list'; export type FilterListProps = { data: Record[]; + showDeleteFilter: boolean; + showAddFilter: boolean; columns: ColumnType[]; filterNodes: FilterNode[]; addFilterNode: (filterNode: FilterNode, filterLogicalOperator?: FilterLogicalOperators) => void; @@ -19,6 +21,8 @@ export type FilterListProps = { export const FilterList = ({ data, + showDeleteFilter, + showAddFilter, columns, filterNodes, addFilterNode, @@ -63,6 +67,7 @@ export const FilterList = ({ return ( - -
+ {showAddFilter && ( +
+ +
+ )} ); }; From 24df45036b3f636f10c7ec0b165809f6f2bc4eb0 Mon Sep 17 00:00:00 2001 From: yxh01132861 Date: Fri, 15 Sep 2023 15:52:47 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Component/FilterCard/index.tsx | 27 +++++++++++-------- .../widgets/FilterWidget/Component/index.tsx | 3 ++- .../src/widgets/FilterWidget/index.tsx | 1 + .../src/widgets/FilterWidget/registerForm.ts | 17 +++++++++--- .../components/Filter/FilterList/index.tsx | 4 +-- 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/packages/li-analysis-assets/src/widgets/FilterWidget/Component/FilterCard/index.tsx b/packages/li-analysis-assets/src/widgets/FilterWidget/Component/FilterCard/index.tsx index d761cc52..c89d8b7f 100644 --- a/packages/li-analysis-assets/src/widgets/FilterWidget/Component/FilterCard/index.tsx +++ b/packages/li-analysis-assets/src/widgets/FilterWidget/Component/FilterCard/index.tsx @@ -19,6 +19,7 @@ type FilterCardProps = { id: string; showDeleteFilter: boolean; showAddFilter: boolean; + showFilterRelation: boolean; datasetOptions: { id: string; name: string }[]; selectedDatasets: string[]; onDel: () => void; @@ -28,6 +29,7 @@ const FilterCard = ({ id, showDeleteFilter, showAddFilter, + showFilterRelation, datasetOptions, selectedDatasets, onDel, @@ -95,17 +97,20 @@ const FilterCard = ({ bodyStyle={{ padding: 0 }} extra={ <> - onRelationChange(val)} + /> + )} + {showDeleteFilter && (