From 4737ad6650b2bedac226b31fbcab1f13a5c96956 Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Mon, 1 Oct 2018 20:55:06 -0500 Subject: [PATCH] support filtering by no Maintainer ref #269 --- .../components/listsTable/columns/Maintainers.tsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/FilterLists.Web/ClientApp/modules/home/components/listsTable/columns/Maintainers.tsx b/src/FilterLists.Web/ClientApp/modules/home/components/listsTable/columns/Maintainers.tsx index c052275de..2476f84e2 100644 --- a/src/FilterLists.Web/ClientApp/modules/home/components/listsTable/columns/Maintainers.tsx +++ b/src/FilterLists.Web/ClientApp/modules/home/components/listsTable/columns/Maintainers.tsx @@ -17,14 +17,12 @@ export const Maintainers = (columnVisibility: IColumnVisibility[], maintainers: const filterMethod = (f: Filter, r: any[], maintainers: IMaintainer[]): boolean => { const listMaintainerIds: number[] = r[f.id as any]; - if (f.value === "any") { - return true; - } else if (listMaintainerIds) { - const maintainerFiltered = maintainers.filter((m: IMaintainer) => m.id === parseInt(f.value))[0]; - return listMaintainerIds.indexOf(maintainerFiltered.id) > -1; - } else { - return false; - } + return f.value === "any" || + (listMaintainerIds + ? f.value === "none" + ? false + : listMaintainerIds.indexOf(maintainers.filter((m: IMaintainer) => m.id === parseInt(f.value))[0].id) > -1 + : f.value === "none"); }; const Filter = (props: any, maintainers: IMaintainer[]) => @@ -33,6 +31,7 @@ const Filter = (props: any, maintainers: IMaintainer[]) => style={{ width: "100%" }} value={props.filter ? props.filter.value : "any"}> + {maintainers.length > 0 ? maintainers.sort((a, b) => a.name.localeCompare(b.name)) .map((m: IMaintainer, i: number) =>