From 5f372f50cf17608abda86312904180e774981266 Mon Sep 17 00:00:00 2001 From: Spectralitree <72747870+Spectralitree@users.noreply.github.com> Date: Thu, 30 Dec 2021 08:27:52 +0100 Subject: [PATCH] feat: search for items without desc or display name in lists --- src/lib/group/List.svelte | 14 +++++++++++--- src/lib/member/List.svelte | 22 +++++++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/lib/group/List.svelte b/src/lib/group/List.svelte index 499fd2bb..e547c117 100644 --- a/src/lib/group/List.svelte +++ b/src/lib/group/List.svelte @@ -63,14 +63,22 @@ $: {searchValue; privacyFilter; currentPage = 1}; $: searchedList = list.filter((item) => { - if (!searchValue) return true; + if (!searchValue && searchBy !== "description" && searchBy !== "display name") return true; switch (searchBy) { case "name": if (item.name.toLowerCase().includes(searchValue.toLowerCase())) return true; break; - case "display name": if (item.display_name && item.display_name.toLowerCase().includes(searchValue.toLowerCase())) return true; + case "display name": if (!searchValue) { + if (!item.display_name) return true; + else return false; + } + if (item.display_name && item.display_name.toLowerCase().includes(searchValue.toLowerCase())) return true; break; - case "description": if (item.description && item.description.toLowerCase().includes(searchValue.toLowerCase())) return true; + case "description": if (!searchValue) { + if (!item.description) return true; + else return false; + } + else if (item.description && item.description.toLowerCase().includes(searchValue.toLowerCase())) return true; break; case "ID": if (item.id.toLowerCase().includes(searchValue.toLowerCase())) return true; break; diff --git a/src/lib/member/List.svelte b/src/lib/member/List.svelte index c1960298..86adc489 100644 --- a/src/lib/member/List.svelte +++ b/src/lib/member/List.svelte @@ -64,14 +64,22 @@ $: {searchValue; privacyFilter; currentPage = 1}; $: searchedList = list.filter((item) => { - if (!searchValue) return true; + if (!searchValue && searchBy !== "description" && searchBy !== "display name") return true; switch (searchBy) { case "name": if (item.name.toLowerCase().includes(searchValue.toLowerCase())) return true; break; - case "display name": if (item.display_name && item.display_name.toLowerCase().includes(searchValue.toLowerCase())) return true; + case "display name": if (!searchValue) { + if (!item.display_name) return true; + else return false; + } + if (item.display_name && item.display_name.toLowerCase().includes(searchValue.toLowerCase())) return true; break; - case "description": if (item.description && item.description.toLowerCase().includes(searchValue.toLowerCase())) return true; + case "description": if (!searchValue) { + if (!item.description) return true; + else return false; + } + else if (item.description && item.description.toLowerCase().includes(searchValue.toLowerCase())) return true; break; case "ID": if (item.id.toLowerCase().includes(searchValue.toLowerCase())) return true; break; @@ -152,6 +160,14 @@ addFormatter({ 'member-list': groupListRenderer }); + + function updateList(event: any) { + list = list.map(member => member.id !== event.detail.id ? member : event.detail); + } + + function updateGroups(event: any) { + groups = list.map(group => group.id !== event.detail.id ? group : event.detail) + }