From 511ba90d993e5e77aee77d4c7e7fd19bced929ea Mon Sep 17 00:00:00 2001 From: chenos Date: Wed, 3 Feb 2021 16:53:31 +0800 Subject: [PATCH] feat: add defaultFilter property to table view --- .../app/src/components/form.fields/drawer-select/index.tsx | 3 ++- packages/app/src/components/views/Table.tsx | 4 +++- packages/plugin-pages/src/actions/getView.ts | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/app/src/components/form.fields/drawer-select/index.tsx b/packages/app/src/components/form.fields/drawer-select/index.tsx index fca0d642f..65fe37477 100644 --- a/packages/app/src/components/form.fields/drawer-select/index.tsx +++ b/packages/app/src/components/form.fields/drawer-select/index.tsx @@ -28,7 +28,7 @@ function transform({value, multiple, labelField, valueField = 'id'}) { } function DrawerSelectComponent(props) { - const { disabled, target, multiple, associatedName, labelField, valueField = 'id', value, onChange } = props; + const { disabled, target, multiple, filter, associatedName, labelField, valueField = 'id', value, onChange } = props; const [selectedKeys, selectedValue] = transform({value, multiple, labelField, valueField }); const [visible, setVisible] = useState(false); const [selectedRowKeys, setSelectedRowKeys] = useState(multiple ? selectedKeys : [selectedKeys]); @@ -96,6 +96,7 @@ function DrawerSelectComponent(props) { ]} > api.resource(name).list({ // associatedKey, // })); - const { filter: defaultFilter = {} } = actionDefaultParams; + const { filter: defaultActionFilter = {} } = actionDefaultParams; const [filterCount, setFilterCount] = useState(0); const name = associatedName ? `${associatedName}.${resourceName}` : resourceName; @@ -65,6 +66,7 @@ export function Table(props: TableProps) { filter: { and: [ defaultFilter, + defaultActionFilter, filter, ].filter(obj => obj && Object.keys(obj).length) } diff --git a/packages/plugin-pages/src/actions/getView.ts b/packages/plugin-pages/src/actions/getView.ts index 2193e63a4..b2ee97722 100644 --- a/packages/plugin-pages/src/actions/getView.ts +++ b/packages/plugin-pages/src/actions/getView.ts @@ -25,6 +25,9 @@ const transforms = { const mode = get(ctx.action.params, ['values', 'mode'], ctx.action.params.mode); const schema = {}; for (const field of fields) { + if (field.get('component.type') === 'hidden') { + continue; + } if (!field.get('component.showInForm')) { continue; }