From e3dde36d0e4397a2d2296499a53b91997d8d0a9c Mon Sep 17 00:00:00 2001 From: Jake Fulmine Date: Sun, 20 Aug 2023 20:02:03 +0200 Subject: [PATCH] feat(dashboard): add text only list view --- .../src/components/list/GroupList.svelte | 3 + .../src/components/list/ListControl.svelte | 54 ++++--- .../src/components/list/MemberList.svelte | 3 + dashboard/src/components/list/TextView.svelte | 140 ++++++++++++++++++ dashboard/src/components/list/types.ts | 7 +- 5 files changed, 184 insertions(+), 23 deletions(-) create mode 100644 dashboard/src/components/list/TextView.svelte diff --git a/dashboard/src/components/list/GroupList.svelte b/dashboard/src/components/list/GroupList.svelte index fdd3c2da..ecf3229a 100644 --- a/dashboard/src/components/list/GroupList.svelte +++ b/dashboard/src/components/list/GroupList.svelte @@ -14,6 +14,7 @@ import type { ListOptions, PageOptions } from './types'; import { createShortList, filterList, getPageAmount, paginateList } from './functions'; import TinyView from './TinyView.svelte'; + import TextView from './TextView.svelte'; $: memberList = getContext>("members") $: groupList = getContext>("groups") @@ -89,6 +90,8 @@ {:else if pageOptions.view === "tiny"} +{:else if pageOptions.view === "text"} + {:else} {/if} diff --git a/dashboard/src/components/list/ListControl.svelte b/dashboard/src/components/list/ListControl.svelte index ae12b855..cb626351 100644 --- a/dashboard/src/components/list/ListControl.svelte +++ b/dashboard/src/components/list/ListControl.svelte @@ -46,26 +46,11 @@ const dispatch = createEventDispatcher(); function onViewChange(e: any) { resetPage(); if (e.target?.value === 'card') { - switch (pageOptions.itemsPerPage) { - case 10: pageOptions.itemsPerPage = 12; - break; - case 25: pageOptions.itemsPerPage = 24; - break; - case 50: pageOptions.itemsPerPage = 60; - break; - default: pageOptions.itemsPerPage = 24; - break; - } - } else if (e.target?.value === 'list') { - switch (pageOptions.itemsPerPage) { - case 12: pageOptions.itemsPerPage = 10; - break; - case 24: pageOptions.itemsPerPage = 25; - break; - case 60: pageOptions.itemsPerPage = 50; - break; - default: pageOptions.itemsPerPage = 25 - } + pageOptions.itemsPerPage = 24 + } else if (e.target?.value === 'tiny') { + pageOptions.itemsPerPage = 36 + } else { + pageOptions.itemsPerPage = 25 } dispatch("viewChange", e.target.value); } @@ -179,11 +164,31 @@ function resetPage() { + - + {#if pageOptions.view === "text"} + + Extra Info + onViewChange(e)} > + + + {#if pageOptions.type === "member"} + + + + + {:else if pageOptions.type === "group"} + + {/if} + + + + + + {/if}
@@ -452,5 +457,12 @@ function resetPage() { {/if} {/if} +
+ + + + + + \ No newline at end of file diff --git a/dashboard/src/components/list/MemberList.svelte b/dashboard/src/components/list/MemberList.svelte index 6ea46340..96063c7c 100644 --- a/dashboard/src/components/list/MemberList.svelte +++ b/dashboard/src/components/list/MemberList.svelte @@ -14,6 +14,7 @@ import type { ListOptions, List, PageOptions } from './types'; import { createShortList, filterList, getPageAmount, paginateList } from './functions'; import TinyView from './TinyView.svelte'; + import TextView from './TextView.svelte'; $: memberList = getContext>("members") $: groupList = getContext>("groups") @@ -89,6 +90,8 @@ {:else if pageOptions.view === "tiny"} +{:else if pageOptions.view === "text"} + {:else} {/if} diff --git a/dashboard/src/components/list/TextView.svelte b/dashboard/src/components/list/TextView.svelte new file mode 100644 index 00000000..cefa50c1 --- /dev/null +++ b/dashboard/src/components/list/TextView.svelte @@ -0,0 +1,140 @@ + + +
    + {#each currentList as item (item.uuid)} +
  1. + + + + {item.name} ({item.id}) + {copiedItems[item.uuid] ? "Copied!" : "Copy public link"} + + {#if listOptions.extra && item[listOptions.extra]} + +
    + {#if ["avatar_url", "webhook_avatar_url", "icon", "banner"].some(i => i === listOptions.extra)} + {item[listOptions.extra].slice(0, 50)}... + {:else if listOptions.extra === "birthday"} + birthday - {moment(item.birthday, "YYYY-MM-DD").format("MMM D, YYYY").replace(', 0004', '')} + {:else if listOptions.extra === "created"} + created on {moment(item.created, "YYYY-MM-DD").format("MMM D, YYYY").replace(', 0004', '')} + {:else if ["pronouns", "display_name"].some(i => i === listOptions.extra)} + + {:else if listOptions.extra === "color"} +
    + #{item.color} +
    +
    + {:else} + {item[listOptions.extra]} + {/if} +
    + + {/if} +
    +
    +
  2. + {/each} +
+ + \ No newline at end of file diff --git a/dashboard/src/components/list/types.ts b/dashboard/src/components/list/types.ts index 40a319da..142188ca 100644 --- a/dashboard/src/components/list/types.ts +++ b/dashboard/src/components/list/types.ts @@ -57,7 +57,9 @@ export interface ListOptions { sort: 'name'|'description'|'birthday'|'pronouns'|'display_name'|'id'|'none'|'created' | 'color', order: "ascending"|"descending", show: "all"|"private"|"public", - // so we can change the key for duplicate members on the randomize page + + // text only view options + extra: keyof Member | keyof Group | null } export interface PageOptions { @@ -125,7 +127,8 @@ export const defaultListOptions: ListOptions = { }, sort: 'name', order: 'ascending', - show: 'all' + show: 'all', + extra: 'display_name' } export const defaultPageOptions: PageOptions = {