Skip to content

Commit

Permalink
webapp/filters: @to / @from inversion
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonish committed Dec 31, 2024
1 parent e21b6d1 commit ae23cd9
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions webapp/src/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ export function FilterStrip(props: { filters: any; setFilters: any }) {
return false;
};

const toggleToFrom = (filter: string) => {
props.setFilters((filters: string[]) => {
const i = filters.indexOf(filter);
if (filters[i].startsWith("@to")) {
filters[i] = filters[i].replace("@to", "@from");
} else {
filters[i] = filters[i].replace("@from", "@to");
}
return [...filters];
});
};

return (
<>
<div class="row">
Expand Down Expand Up @@ -165,6 +177,28 @@ export function FilterStrip(props: { filters: any; setFilters: any }) {
</a>
</li>
</Show>

<Show when={filter.startsWith("@to")}>
<li>
<a
class="dropdown-item"
onClick={() => toggleToFrom(filter)}
>
Change to @from
</a>
</li>
</Show>

<Show when={filter.startsWith("@from")}>
<li>
<a
class="dropdown-item"
onClick={() => toggleToFrom(filter)}
>
Change to @to
</a>
</li>
</Show>
</ul>

<button
Expand Down

0 comments on commit ae23cd9

Please sign in to comment.