From f612de1d891bf8407cb24f7ff069b688527e6907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Mart=C3=ADnez?= Date: Fri, 8 Sep 2023 17:18:17 +0000 Subject: [PATCH] Add separate buttons to jump between non-duplicate entries --- frontend/src/reports/import/Extract.svelte | 68 ++++++++++------------ 1 file changed, 31 insertions(+), 37 deletions(-) diff --git a/frontend/src/reports/import/Extract.svelte b/frontend/src/reports/import/Extract.svelte index 302d9d8d3..2f52889cb 100644 --- a/frontend/src/reports/import/Extract.svelte +++ b/frontend/src/reports/import/Extract.svelte @@ -14,25 +14,24 @@ $: shown = entries.length > 0; $: entry = entries[currentIndex]; $: duplicate = entry && isDuplicate(entry); - $: skipDuplicates = true; $: duplicates = entries.filter(isDuplicate).length; $: if (entries.length > 0 && currentIndex >= entries.length) { currentIndex = 0; } - function nextEntry() { - if(skipDuplicates) { - for (let index = currentIndex+1; index < entries.length; index+=1) { - const newEntry = entries[index]; - if (newEntry !== undefined && !isDuplicate(newEntry)) { - currentIndex = index; - return; - } + function nextNonDuplicateEntry() { + for (let index = currentIndex+1; index < entries.length; index+=1) { + const newEntry = entries[index]; + if (newEntry !== undefined && !isDuplicate(newEntry)) { + currentIndex = index; + return; } - currentIndex = entries.length-1; - }else{ - currentIndex += 1; } + currentIndex = entries.length-1; + } + + function nextEntry() { + currentIndex += 1; } function submitOrNext() { @@ -43,19 +42,19 @@ } } - function previousEntry() { - if(skipDuplicates) { - for (let index = currentIndex-1; index >= 0; index-=1) { - const newEntry = entries[index]; - if (newEntry !== undefined && !isDuplicate(newEntry)) { - currentIndex = index; - return; - } + function previousNonDuplicateEntry() { + for (let index = currentIndex-1; index >= 0; index-=1) { + const newEntry = entries[index]; + if (newEntry !== undefined && !isDuplicate(newEntry)) { + currentIndex = index; + return; } - currentIndex = 0; - }else{ - currentIndex = Math.max(currentIndex - 1, 0); } + currentIndex = 0; + } + + function previousEntry() { + currentIndex = Math.max(currentIndex - 1, 0); } function toggleDuplicate() { @@ -63,9 +62,6 @@ entry.meta.__duplicate__ = !entry.meta.__duplicate__; } } - function toggleSkipDuplicates() { - skipDuplicates = !skipDuplicates; - } @@ -105,21 +101,19 @@ > ⏮ - + {/if} - {#if currentIndex < entries.length - 1} - + +