From 3bae5344b651fd66ed38524f07eac471b07fea73 Mon Sep 17 00:00:00 2001 From: Jake Fulmine Date: Tue, 27 Sep 2022 20:53:18 +0200 Subject: [PATCH] fix(dashboard): list freeze when editing sorted-by field also fixes the wrong cards remaining open after resorting the list --- dashboard/src/lib/CardsHeader.svelte | 2 +- dashboard/src/lib/list/CardsList.svelte | 17 +++++++++-------- dashboard/src/lib/list/List.svelte | 9 --------- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/dashboard/src/lib/CardsHeader.svelte b/dashboard/src/lib/CardsHeader.svelte index 11a51bcb..66b939b4 100644 --- a/dashboard/src/lib/CardsHeader.svelte +++ b/dashboard/src/lib/CardsHeader.svelte @@ -49,7 +49,7 @@ {@html htmlName} ({item.id}) -
+
{#if item && (item.avatar_url || item.icon)} {if (event.key === "Enter") {avatarOpen = true}}} on:click|stopPropagation={toggleAvatarModal} class="rounded-circle avatar" src={icon_url_resized} alt={altText} /> {:else} diff --git a/dashboard/src/lib/list/CardsList.svelte b/dashboard/src/lib/list/CardsList.svelte index c1cc48c4..d1196efd 100644 --- a/dashboard/src/lib/list/CardsList.svelte +++ b/dashboard/src/lib/list/CardsList.svelte @@ -64,13 +64,14 @@ } } - let isOpenArray = []; + let isOpen = {}; - function toggleCard(index: number) { - if (isOpenArray[index] === true) { - isOpenArray[index] = false; + function toggleCard(index: string) { + isOpen[index] = isOpen[index] || {}; + if (isOpen[index] === true) { + isOpen[index] = false; } else { - isOpenArray[index] = true; + isOpen[index] = true; } } @@ -109,10 +110,10 @@ {#if !openByDefault && (settings && settings.accessibility ? (!settings.accessibility.expandedcards && !settings.accessibility.pagelinks) : true)}
- {#each list as item, index (item.id + index)} + {#each list as item, index (item.uuid)}

-

- + {#if itemType === "member"} diff --git a/dashboard/src/lib/list/List.svelte b/dashboard/src/lib/list/List.svelte index 7294f7a1..d3dae251 100644 --- a/dashboard/src/lib/list/List.svelte +++ b/dashboard/src/lib/list/List.svelte @@ -86,14 +86,6 @@ } } - /* function updateList(event: any) { - list = list.map(member => member.id !== event.detail.id ? member : event.detail); - } */ - - /* function updateGroups(event: any) { - groups = event.detail; - } */ - function updateDelete(event: any) { if (itemType === "member") { members = members.filter(m => m.id !== event.detail); @@ -105,7 +97,6 @@ } function update(event: any) { - console.log(event.detail); if (itemType === "member") { members = members.map(m => m.id === event.detail.id ? m = event.detail : m); list = members;