From 8a6c26696f4cb4a02b82883fd12927c3ff1b1694 Mon Sep 17 00:00:00 2001 From: Spectralitree <72747870+Spectralitree@users.noreply.github.com> Date: Tue, 21 Dec 2021 00:20:25 +0100 Subject: [PATCH] feat: filtering members & groups based on if they are in no group --- src/lib/group/List.svelte | 16 +++++++++++----- src/lib/member/List.svelte | 14 ++++++++++---- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/lib/group/List.svelte b/src/lib/group/List.svelte index d7a00c6e..83ac152b 100644 --- a/src/lib/group/List.svelte +++ b/src/lib/group/List.svelte @@ -114,14 +114,18 @@ let memberFilteredList = []; $: memberFilteredList = sortedList.filter((item: Group) => { + if (memberSearchMode === "none") { + if (item.members && item.members.length > 0) return false; + } + if (selectedMembers.length < 1) return true; switch (memberSearchMode) { - case "include": if (selectedMembers.some(value => item.members.includes(value))) return true; + case "include": if (item.members && selectedMembers.some(value => item.members.includes(value))) return true; break; - case "exclude": if (selectedMembers.every(value => !item.members.includes(value))) return true; + case "exclude": if (item.members && selectedMembers.every(value => !item.members.includes(value))) return true; break; - case "match": if (selectedMembers.every(value => item.members.includes(value))) return true; + case "match": if (item.members && selectedMembers.every(value => item.members.includes(value))) return true; break; default: return true; } @@ -231,9 +235,11 @@ memberSearchMode = "include"}>{@html memberSearchMode === "include" ? "include" : "include"} | memberSearchMode = "exclude"}>{@html memberSearchMode === "exclude" ? "exclude" : "exclude"} | memberSearchMode = "match"}>{@html memberSearchMode === "match" ? "exact match" : "exact match"} + | memberSearchMode = "none"}>{@html memberSearchMode === "none" ? "none" : "none"} Includes every group with any of the members. Excludes every group with any of the members, opposite of include. Only includes groups which have all the members selected. + Only includes groups that have no members. {/if} @@ -263,14 +269,14 @@ - + {:else} - + {/if} {/each} diff --git a/src/lib/member/List.svelte b/src/lib/member/List.svelte index 32b906f4..c0a7509f 100644 --- a/src/lib/member/List.svelte +++ b/src/lib/member/List.svelte @@ -113,15 +113,19 @@ } let memberFilteredList = []; - $: memberFilteredList = sortedList.filter((item: Member) => { + $: memberFilteredList = sortedList.filter((item: Member) => { + if (groupSearchMode === "none") { + if (groups.some(group => group.members && group.members.includes(item.uuid))) return false; + } + if (selectedGroups.length < 1) return true; switch (groupSearchMode) { - case "include": if (selectedGroups.some(group => group.members.includes(item.uuid))) return true; + case "include": if (selectedGroups.some(group => group.members && group.members.includes(item.uuid))) return true; break; - case "exclude": if (selectedGroups.every(group => !group.members.includes(item.uuid))) return true; + case "exclude": if (selectedGroups.every(group => group.members && !group.members.includes(item.uuid))) return true; break; - case "match": if (selectedGroups.every(group => group.members.includes(item.uuid))) return true; + case "match": if (selectedGroups.every(group => group.members && group.members.includes(item.uuid))) return true; break; default: return true; } @@ -223,9 +227,11 @@ groupSearchMode = "include"}>{@html groupSearchMode === "include" ? "include" : "include"} | groupSearchMode = "exclude"}>{@html groupSearchMode === "exclude" ? "exclude" : "exclude"} | groupSearchMode = "match"}>{@html groupSearchMode === "match" ? "exact match" : "exact match"} + | groupSearchMode = "none"}>{@html groupSearchMode === "none" ? "none" : "none"} Includes every member who's a part of any of the groups. Excludes every member who's a part of any of the groups, the opposite of include. Only includes members who are a part of every group. + Only includes members that are in no groups. {/if}