Support integer operator type
Summary: Project doc: https://docs.google.com/document/d/1miofxds9DJgWScj0zFyBbdpRH5Rj0T9FqiCapof5-vU Reviewed By: lblasa Differential Revision: D48605154 fbshipit-source-id: 4662b61b217568e593f6b65c8b4dd1d99ea5606a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a9fb5d9863
commit
143dce85f1
@@ -11,12 +11,13 @@ import {CloseOutlined} from '@ant-design/icons';
|
||||
import {Button, Space} from 'antd';
|
||||
import * as React from 'react';
|
||||
import {FieldConfig, OperatorConfig} from './PowerSearchConfig';
|
||||
import {PowerSearchIntegerTerm} from './PowerSearchIntegerTerm';
|
||||
import {PowerSearchStringTerm} from './PowerSearchStringTerm';
|
||||
|
||||
export type IncompleteSearchExpressionTerm = {
|
||||
field: FieldConfig;
|
||||
operator: OperatorConfig;
|
||||
searchValue?: string;
|
||||
searchValue?: any;
|
||||
};
|
||||
export type SearchExpressionTerm = Required<IncompleteSearchExpressionTerm>;
|
||||
|
||||
@@ -33,13 +34,10 @@ export const PowerSearchTerm: React.FC<PowerSearchTermProps> = ({
|
||||
onCancel,
|
||||
onFinalize,
|
||||
}) => {
|
||||
return (
|
||||
<Space.Compact block size="small">
|
||||
<Button>{searchTerm.field.label}</Button>
|
||||
<Button>{searchTerm.operator.label}</Button>
|
||||
{searchValueRenderer === 'button' ? (
|
||||
<Button>{searchTerm.searchValue ?? '...'}</Button>
|
||||
) : (
|
||||
let searchValueInputComponent: React.ReactNode = null;
|
||||
switch (searchTerm.operator.valueType) {
|
||||
case 'STRING': {
|
||||
searchValueInputComponent = (
|
||||
<PowerSearchStringTerm
|
||||
onCancel={onCancel}
|
||||
onChange={(newValue) => {
|
||||
@@ -49,6 +47,40 @@ export const PowerSearchTerm: React.FC<PowerSearchTermProps> = ({
|
||||
});
|
||||
}}
|
||||
/>
|
||||
);
|
||||
break;
|
||||
}
|
||||
case 'INTEGER': {
|
||||
searchValueInputComponent = (
|
||||
<PowerSearchIntegerTerm
|
||||
onCancel={onCancel}
|
||||
onChange={(newValue) => {
|
||||
onFinalize({
|
||||
...searchTerm,
|
||||
searchValue: newValue,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
console.error(
|
||||
'PowerSearchTerm -> unknownoperator.valueType',
|
||||
searchTerm.operator.valueType,
|
||||
searchTerm,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Space.Compact block size="small">
|
||||
<Button>{searchTerm.field.label}</Button>
|
||||
<Button>{searchTerm.operator.label}</Button>
|
||||
{searchValueRenderer === 'button' ? (
|
||||
<Button>{searchTerm.searchValue ?? '...'}</Button>
|
||||
) : (
|
||||
searchValueInputComponent
|
||||
)}
|
||||
<Button
|
||||
icon={<CloseOutlined />}
|
||||
|
||||
Reference in New Issue
Block a user