From 537a4d45cc770ab1217a3de231329f9a3da77a77 Mon Sep 17 00:00:00 2001 From: Spectralitree <72747870+Spectralitree@users.noreply.github.com> Date: Sat, 18 Dec 2021 20:10:02 +0100 Subject: [PATCH] some stuff --- src/lib/group/List.svelte | 211 +++++++++++++++++++++++++++++++++ src/lib/member/List.svelte | 33 +++--- src/pages/Dash.svelte | 17 ++- src/pages/profiles/Main.svelte | 7 +- 4 files changed, 248 insertions(+), 20 deletions(-) create mode 100644 src/lib/group/List.svelte diff --git a/src/lib/group/List.svelte b/src/lib/group/List.svelte new file mode 100644 index 00000000..55ab605b --- /dev/null +++ b/src/lib/group/List.svelte @@ -0,0 +1,211 @@ + + + + + + +
+ +
Search groups +
+
+
+ + + + + Page length + + + + + + + + + + Search by + + + + + + + + + + + Sort by + + + + {#if !isPublic}{/if} + + + + + + + Sort order + + + + + + + {#if !isPublic} + + + Only show + + + + + + + + {/if} + + +
+ + +{#if listLoading && !err} +
+ +
+{:else if err} +{err} +{:else} + + + + + + + + + + + + {#each slicedList as group (group.id)} + + + + + + {/each} + + +{/if} \ No newline at end of file diff --git a/src/lib/member/List.svelte b/src/lib/member/List.svelte index 5d4c648c..b67d497f 100644 --- a/src/lib/member/List.svelte +++ b/src/lib/member/List.svelte @@ -5,6 +5,7 @@ import FaSearch from 'svelte-icons/fa/FaSearch.svelte' import { useParams } from 'svelte-navigator'; import type Member from '../../api/member'; + import type Group from '../../api/group' import PKAPI from '../../api'; import CardsHeader from '../CardsHeader.svelte'; import ListPagination from '../ListPagination.svelte'; @@ -12,7 +13,7 @@ export let isPublic: boolean; let itemLoading = false; - let list: Member[] = []; + export let list: Member[] = []; let token = localStorage.getItem("pk-token"); let listLoading = true; let err: string; @@ -53,29 +54,29 @@ $: {searchValue; privacyFilter; currentPage = 1}; - $: searchedList = list.filter((member) => { + $: searchedList = list.filter((item) => { if (!searchValue) return true; switch (searchBy) { - case "name": if (member.name.toLowerCase().includes(searchValue.toLowerCase())) return true; + case "name": if (item.name.toLowerCase().includes(searchValue.toLowerCase())) return true; break; - case "display name": if (member.display_name && member.display_name.toLowerCase().includes(searchValue.toLowerCase())) return true; + case "display name": if (item.display_name && item.display_name.toLowerCase().includes(searchValue.toLowerCase())) return true; break; - case "description": if (member.description && member.description.toLowerCase().includes(searchValue.toLowerCase())) return true; + case "description": if (item.description && item.description.toLowerCase().includes(searchValue.toLowerCase())) return true; break; - case "ID": if (member.id.toLowerCase().includes(searchValue.toLowerCase())) return true; + case "ID": if (item.id.toLowerCase().includes(searchValue.toLowerCase())) return true; break; - default: if (member.name.toLowerCase().includes(searchValue.toLowerCase())) return true; + default: if (item.name.toLowerCase().includes(searchValue.toLowerCase())) return true; break; } return false; }) - $: filteredList = searchedList.filter((member) => { + $: filteredList = searchedList.filter((item) => { if (privacyFilter === "all") return true; - if (privacyFilter === "public" && member.privacy.visibility === "public") return true; - if (privacyFilter === "private" && member.privacy.visibility === "private") return true; + if (privacyFilter === "public" && item.privacy.visibility === "public") return true; + if (privacyFilter === "private" && item.privacy.visibility === "private") return true; return false; }); @@ -101,7 +102,7 @@ } } - $: if (sortOrder === "descending") sortedList = sortedList.reverse(); + $:{sortOrder; if (sortOrder === "descending") sortedList = sortedList.reverse();} $: indexOfLastItem = currentPage * itemsPerPage; $: indexOfFirstItem = indexOfLastItem - itemsPerPage; @@ -150,7 +151,7 @@ - + {#if !isPublic}{/if} @@ -164,7 +165,8 @@ - + {#if !isPublic} + Only show @@ -174,6 +176,7 @@ + {/if} @@ -188,10 +191,10 @@ {:else} - + - + diff --git a/src/pages/Dash.svelte b/src/pages/Dash.svelte index 07fae917..981c1c27 100644 --- a/src/pages/Dash.svelte +++ b/src/pages/Dash.svelte @@ -6,10 +6,14 @@ import System from '../lib/system/Main.svelte'; import PKAPI from '../api'; import Sys from '../api/system'; - import List from '../lib/member/List.svelte'; + import MemberList from '../lib/member/List.svelte'; + import GroupList from '../lib/group/List.svelte'; let isPublic = false; + let group = true; + let member = false; + // get the state from the navigator so that we know which tab to start on let location = useLocation(); let params = $location.search && new URLSearchParams($location.search); @@ -64,6 +68,10 @@ } } + // some values that get passed from the member to the group components and vice versa + let members = []; + let groups = []; + @@ -78,8 +86,11 @@ - - + + + + + diff --git a/src/pages/profiles/Main.svelte b/src/pages/profiles/Main.svelte index 8c7403da..a0102390 100644 --- a/src/pages/profiles/Main.svelte +++ b/src/pages/profiles/Main.svelte @@ -6,13 +6,16 @@ import System from '../../lib/system/Main.svelte'; import PKAPI from '../../api'; import Sys from '../../api/system'; - import List from '../../lib/member/List.svelte'; + import MemberList from '../../lib/member/List.svelte'; let isPublic = true; let user = new Sys({}); let settings = JSON.parse(localStorage.getItem("pk-settings")); + let members = []; + let groups = []; + let params = useParams(); $: id = $params.id; @@ -59,7 +62,7 @@ - + {/if}