feat: add defaultFilter property to table view
This commit is contained in:
parent
365513909a
commit
511ba90d99
@ -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) {
|
||||
]}
|
||||
>
|
||||
<ViewFactory
|
||||
defaultFilter={filter}
|
||||
multiple={multiple}
|
||||
resourceName={target}
|
||||
isFieldComponent={true}
|
||||
|
@ -30,6 +30,7 @@ export function Table(props: TableProps) {
|
||||
onSelected,
|
||||
multiple = true,
|
||||
selectedRowKeys: srk,
|
||||
defaultFilter = {},
|
||||
} = props;
|
||||
const {
|
||||
name: viewName,
|
||||
@ -47,7 +48,7 @@ export function Table(props: TableProps) {
|
||||
// const { data, mutate } = useRequest(() => 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)
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user