mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 11:56:29 +00:00
feat: add associatedKey property to filter field component
This commit is contained in:
parent
511ba90d99
commit
b050e4ce5d
@ -7,6 +7,8 @@ import { mapStyledProps } from '../shared'
|
|||||||
import get from 'lodash/get';
|
import get from 'lodash/get';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import './style.less';
|
import './style.less';
|
||||||
|
import api from '@/api-client';
|
||||||
|
import { useRequest } from 'umi';
|
||||||
|
|
||||||
export function FilterGroup(props: any) {
|
export function FilterGroup(props: any) {
|
||||||
const { showDeleteButton = true, fields = [], onDelete, onChange, onAdd, dataSource = {} } = props;
|
const { showDeleteButton = true, fields = [], onDelete, onChange, onAdd, dataSource = {} } = props;
|
||||||
@ -445,12 +447,23 @@ export const Filter = connect({
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
const { value, onChange, ...restProps } = props;
|
const { value, onChange, associatedKey, filter = {}, fields = [], ...restProps } = props;
|
||||||
console.log('valuevaluevaluevaluevaluevalue', value);
|
|
||||||
|
const { data = [], loading = true } = useRequest(() => {
|
||||||
|
return associatedKey ? api.resource(`collections.fields`).list({
|
||||||
|
associatedKey,
|
||||||
|
filter,
|
||||||
|
}) : Promise.resolve({
|
||||||
|
data: fields,
|
||||||
|
});
|
||||||
|
}, {
|
||||||
|
refreshDeps: [associatedKey]
|
||||||
|
});
|
||||||
|
|
||||||
return <FilterGroup showDeleteButton={false} dataSource={value ? toValues(value) : dataSource} onChange={(values) => {
|
return <FilterGroup showDeleteButton={false} dataSource={value ? toValues(value) : dataSource} onChange={(values) => {
|
||||||
console.log(values);
|
console.log(values);
|
||||||
onChange(toFilter(values));
|
onChange(toFilter(values));
|
||||||
}} {...restProps}/>
|
}} {...restProps} fields={data.filter(item => item.filterable)}/>
|
||||||
});
|
});
|
||||||
|
|
||||||
export default Filter;
|
export default Filter;
|
||||||
|
Loading…
Reference in New Issue
Block a user