Make NWFilter clickable when not editable
This commit is contained in:
parent
ff66a5cf97
commit
307e5d1b50
@ -1,7 +1,8 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { NWFilter } from "../../api/NWFilterApi";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { NWFilterSelectInput } from "./NWFilterSelectInput";
|
import { NWFilter, NWFilterURL } from "../../api/NWFilterApi";
|
||||||
import { NWFilterItem } from "../nwfilter/NWFilterItem";
|
import { NWFilterItem } from "../nwfilter/NWFilterItem";
|
||||||
|
import { NWFilterSelectInput } from "./NWFilterSelectInput";
|
||||||
|
|
||||||
export function NWFSelectReferencedFilters(p: {
|
export function NWFSelectReferencedFilters(p: {
|
||||||
editable: boolean;
|
editable: boolean;
|
||||||
@ -10,6 +11,8 @@ export function NWFSelectReferencedFilters(p: {
|
|||||||
onChange?: () => void;
|
onChange?: () => void;
|
||||||
excludedFilters?: string[];
|
excludedFilters?: string[];
|
||||||
}): React.ReactElement {
|
}): React.ReactElement {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const nwfilters = React.useMemo(
|
const nwfilters = React.useMemo(
|
||||||
() =>
|
() =>
|
||||||
p.excludedFilters
|
p.excludedFilters
|
||||||
@ -37,6 +40,11 @@ export function NWFSelectReferencedFilters(p: {
|
|||||||
}
|
}
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
|
onClick={
|
||||||
|
!p.editable && entry
|
||||||
|
? () => navigate(NWFilterURL(entry))
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { Autocomplete, TextField } from "@mui/material";
|
import { Autocomplete, TextField } from "@mui/material";
|
||||||
import { NWFilter } from "../../api/NWFilterApi";
|
|
||||||
import { NWFilterItem } from "../nwfilter/NWFilterItem";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
|
import { NWFilter, NWFilterURL } from "../../api/NWFilterApi";
|
||||||
|
import { NWFilterItem } from "../nwfilter/NWFilterItem";
|
||||||
|
|
||||||
export function NWFilterSelectInput(p: {
|
export function NWFilterSelectInput(p: {
|
||||||
editable: boolean;
|
editable: boolean;
|
||||||
@ -11,6 +12,8 @@ export function NWFilterSelectInput(p: {
|
|||||||
onChange?: (name?: string) => void;
|
onChange?: (name?: string) => void;
|
||||||
canBeNull: boolean;
|
canBeNull: boolean;
|
||||||
}): React.ReactElement {
|
}): React.ReactElement {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const [open, setOpen] = React.useState(false);
|
const [open, setOpen] = React.useState(false);
|
||||||
|
|
||||||
const selectedValue = p.nwfilters.find((o) => o.name === p.value);
|
const selectedValue = p.nwfilters.find((o) => o.name === p.value);
|
||||||
@ -21,6 +24,11 @@ export function NWFilterSelectInput(p: {
|
|||||||
<NWFilterItem
|
<NWFilterItem
|
||||||
value={selectedValue}
|
value={selectedValue}
|
||||||
onDelete={p.editable ? () => p.onChange?.(undefined) : undefined}
|
onDelete={p.editable ? () => p.onChange?.(undefined) : undefined}
|
||||||
|
onClick={
|
||||||
|
!p.editable && selectedValue
|
||||||
|
? () => navigate(NWFilterURL(selectedValue))
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user