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) {
|
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 [selectedKeys, selectedValue] = transform({value, multiple, labelField, valueField });
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const [selectedRowKeys, setSelectedRowKeys] = useState(multiple ? selectedKeys : [selectedKeys]);
|
const [selectedRowKeys, setSelectedRowKeys] = useState(multiple ? selectedKeys : [selectedKeys]);
|
||||||
@ -96,6 +96,7 @@ function DrawerSelectComponent(props) {
|
|||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<ViewFactory
|
<ViewFactory
|
||||||
|
defaultFilter={filter}
|
||||||
multiple={multiple}
|
multiple={multiple}
|
||||||
resourceName={target}
|
resourceName={target}
|
||||||
isFieldComponent={true}
|
isFieldComponent={true}
|
||||||
|
@ -30,6 +30,7 @@ export function Table(props: TableProps) {
|
|||||||
onSelected,
|
onSelected,
|
||||||
multiple = true,
|
multiple = true,
|
||||||
selectedRowKeys: srk,
|
selectedRowKeys: srk,
|
||||||
|
defaultFilter = {},
|
||||||
} = props;
|
} = props;
|
||||||
const {
|
const {
|
||||||
name: viewName,
|
name: viewName,
|
||||||
@ -47,7 +48,7 @@ export function Table(props: TableProps) {
|
|||||||
// const { data, mutate } = useRequest(() => api.resource(name).list({
|
// const { data, mutate } = useRequest(() => api.resource(name).list({
|
||||||
// associatedKey,
|
// associatedKey,
|
||||||
// }));
|
// }));
|
||||||
const { filter: defaultFilter = {} } = actionDefaultParams;
|
const { filter: defaultActionFilter = {} } = actionDefaultParams;
|
||||||
|
|
||||||
const [filterCount, setFilterCount] = useState(0);
|
const [filterCount, setFilterCount] = useState(0);
|
||||||
const name = associatedName ? `${associatedName}.${resourceName}` : resourceName;
|
const name = associatedName ? `${associatedName}.${resourceName}` : resourceName;
|
||||||
@ -65,6 +66,7 @@ export function Table(props: TableProps) {
|
|||||||
filter: {
|
filter: {
|
||||||
and: [
|
and: [
|
||||||
defaultFilter,
|
defaultFilter,
|
||||||
|
defaultActionFilter,
|
||||||
filter,
|
filter,
|
||||||
].filter(obj => obj && Object.keys(obj).length)
|
].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 mode = get(ctx.action.params, ['values', 'mode'], ctx.action.params.mode);
|
||||||
const schema = {};
|
const schema = {};
|
||||||
for (const field of fields) {
|
for (const field of fields) {
|
||||||
|
if (field.get('component.type') === 'hidden') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!field.get('component.showInForm')) {
|
if (!field.get('component.showInForm')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user