Skip to content

Commit

Permalink
fix(filter-picker): fix icon of Expression
Browse files Browse the repository at this point in the history
  • Loading branch information
maxin authored and jack0pan committed Mar 22, 2022
1 parent 9f395b5 commit c4bf358
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/legacy/filter-picker/components/FilterList/Expression/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState, useMemo, useContext } from 'react';
import { DeleteOutlined } from '@gio-design/icons';
import PropertySelector from '../../../../property-selector';
import PropertySelector, { PropertyValue } from '../../../../property-selector';
import FilterCondition from './FilterCondition';
import './index.less';
import { attributeValue, FilterValueType, StringValue, NumberValue, DateValue, ListValue } from '../../../interfaces';
Expand Down Expand Up @@ -40,6 +40,7 @@ function Expression(props: ExpressionProps) {
const [exprKey, setExprKey] = useState<string>(filterItem?.key || '');
const [exprName, setExprName] = useState<string>(filterItem?.name || '');
const [groupId, setGroupId] = useState<string>(filterItem?.groupId || '');
const [iconId, setIconId] = useState<string>(filterItem?.iconId || '');
const [op, setOp] = useState<StringValue | NumberValue | DateValue | ListValue>(filterItem?.op);
const [subFilterItem, setSubFilterItem] = useState<FilterValueType>(filterItem);
const { fetchDetailData, operationsOption } = React.useContext(FilterPickerContext);
Expand All @@ -65,28 +66,32 @@ function Expression(props: ExpressionProps) {
onChange(subFilterItem, index);
};

const changePropertyPicker = (v: any) => {
v && setValueType(v?.valueType || 'string');
v && setExprName(v.label);
v && setExprKey(v.value);
v && setValues([]);
v && setOp('=');
v && setGroupId(v.subGroupId);
const changePropertyPicker = (v: PropertyValue) => {
if (v) {
setValueType((v.valueType || 'string') as attributeValue);
setExprName(v.label ?? '');
setExprKey(v.value ?? '');
setValues([]);
setOp('=');
setGroupId(v.groupId ?? '');
setIconId(v.iconId ?? '');
}
const type = v?.valueType ? v?.valueType.toLowerCase() : 'string';
const expr: FilterValueType = {
key: v.value,
name: v.label,
valueType: type,
key: v?.value,
name: v?.label,
valueType: type as attributeValue,
op: type === 'list' ? 'hasAll' : '=',
groupId: v.subGroupId,
groupId: v?.groupId,
iconId: v?.iconId,
values: [],
};
onChange(expr, index);
};

const propertyValue = useMemo(
() => (exprKey ? { value: exprKey, label: exprName, id: exprKey, groupId, subGroupId: groupId } : undefined),
[exprKey, exprName, groupId]
() => (exprKey ? { value: exprKey, label: exprName, id: exprKey, groupId, iconId } : undefined),
[exprKey, exprName, groupId, iconId]
);

return (
Expand Down
1 change: 1 addition & 0 deletions src/legacy/filter-picker/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type FilterValueType = {
name?: string;
valueType?: attributeValue;
groupId?: string;
iconId?: string;
};

export type FilterValue = {
Expand Down

0 comments on commit c4bf358

Please sign in to comment.