move filter to options
This commit is contained in:
parent
d290a9c563
commit
1692aee3a2
@ -2,25 +2,17 @@ import { Form, Select as AntSelect } from 'antd';
|
||||
import { Status } from 'core/types/statuses';
|
||||
import React from 'react';
|
||||
|
||||
const Select = ({
|
||||
value,
|
||||
setCurrentValue,
|
||||
status,
|
||||
options,
|
||||
filter,
|
||||
...props
|
||||
}) => {
|
||||
const Select = ({ value, setCurrentValue, status, options, ...props }) => {
|
||||
return (
|
||||
<Form.Item>
|
||||
<AntSelect
|
||||
{...props}
|
||||
disabled={status === Status.Disabled}
|
||||
optionFilterProp="children"
|
||||
filterOption={filter}
|
||||
value={value}
|
||||
onChange={val => setCurrentValue(val)}
|
||||
>
|
||||
{(filter ? filter(options) : options).map((option, i) => {
|
||||
{options.map((option, i) => {
|
||||
if (option)
|
||||
return (
|
||||
<AntSelect.Option key={i} value={option.value}>
|
||||
|
||||
@ -28,7 +28,7 @@ export const withStoreValue = Component => ({
|
||||
validator: () => {},
|
||||
},
|
||||
});
|
||||
const { options, filter } = useOptions(name);
|
||||
const { options } = useOptions(name);
|
||||
|
||||
return (
|
||||
<Component
|
||||
@ -38,7 +38,6 @@ export const withStoreValue = Component => ({
|
||||
validateStatus={validateStatus}
|
||||
message={message}
|
||||
options={options}
|
||||
filter={filter}
|
||||
{...params}
|
||||
/>
|
||||
);
|
||||
|
||||
@ -6,24 +6,22 @@ export const useOptions = elementName => {
|
||||
const filter = calculationStore.filters[elementName];
|
||||
|
||||
return {
|
||||
options,
|
||||
filter,
|
||||
options: filter ? filter(options) : options,
|
||||
};
|
||||
};
|
||||
|
||||
export const useTableOptions = ({ tableName, rowIndex, propName }) => {
|
||||
const { calculationStore } = useStores();
|
||||
const options =
|
||||
calculationStore.tables[tableName].options &&
|
||||
calculationStore.tables[tableName].options &&
|
||||
calculationStore.tables[tableName].options[propName]
|
||||
? calculationStore.tables[tableName].options[propName]
|
||||
: [];
|
||||
(calculationStore.tables[tableName].options &&
|
||||
calculationStore.tables[tableName].options &&
|
||||
calculationStore.tables[tableName].options[propName]) ||
|
||||
[];
|
||||
const filter =
|
||||
calculationStore.tables[tableName].filters &&
|
||||
calculationStore.tables[tableName].filters[rowIndex] &&
|
||||
calculationStore.tables[tableName].filters[rowIndex][propName]
|
||||
? calculationStore.tables[tableName].filters[rowIndex][propName]
|
||||
: [];
|
||||
return { options, filter };
|
||||
calculationStore.tables[tableName].filters[rowIndex][propName];
|
||||
return {
|
||||
options: filter ? filter(options) : options,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user