mirror of
https://github.com/umami-software/umami.git
synced 2026-02-16 02:25:35 +01:00
Updated filtering logic.
This commit is contained in:
parent
6ee9bb07da
commit
810b0639c8
14 changed files with 97 additions and 83 deletions
|
|
@ -16,7 +16,7 @@ import {
|
|||
} from 'react-basics';
|
||||
import { useMessages, useFilters, useFormat, useLocale, useWebsiteValues } from 'components/hooks';
|
||||
import { OPERATORS } from 'lib/constants';
|
||||
import { operatorEquals } from 'lib/params';
|
||||
import { isEqualsOperator } from 'lib/params';
|
||||
import styles from './FieldFilterEditForm.module.css';
|
||||
|
||||
export interface FieldFilterFormProps {
|
||||
|
|
@ -50,7 +50,7 @@ export default function FieldFilterEditForm({
|
|||
const [operator, setOperator] = useState(defaultOperator);
|
||||
const [value, setValue] = useState(defaultValue);
|
||||
const [showMenu, setShowMenu] = useState(false);
|
||||
const isEquals = operatorEquals(operator);
|
||||
const isEquals = isEqualsOperator(operator);
|
||||
const [search, setSearch] = useState('');
|
||||
const [selected, setSelected] = useState(isEquals ? value : '');
|
||||
const { filters } = useFilters();
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import ParameterList from '../[reportId]/ParameterList';
|
|||
import PopupForm from '../[reportId]/PopupForm';
|
||||
import { ReportContext } from './Report';
|
||||
import FieldFilterEditForm from '../[reportId]/FieldFilterEditForm';
|
||||
import { operatorEquals } from 'lib/params';
|
||||
import { isSearchOperator } from 'lib/params';
|
||||
import styles from './FilterParameters.module.css';
|
||||
|
||||
export function FilterParameters() {
|
||||
|
|
@ -69,7 +69,7 @@ export function FilterParameters() {
|
|||
{filters.map(
|
||||
({ name, operator, value }: { name: string; operator: string; value: string }) => {
|
||||
const label = fields.find(f => f.name === name)?.label;
|
||||
const isEquals = operatorEquals(operator);
|
||||
const isSearch = isSearchOperator(operator);
|
||||
|
||||
return (
|
||||
<ParameterList.Item key={name} onRemove={() => handleRemove(name)}>
|
||||
|
|
@ -79,7 +79,7 @@ export function FilterParameters() {
|
|||
name={name}
|
||||
label={label}
|
||||
operator={operator}
|
||||
value={isEquals ? formatValue(value, name) : value}
|
||||
value={isSearch ? value : formatValue(value, name)}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</ParameterList.Item>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue