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