Skip to content

Open-source personal finance manager. Self-hosted, privacy-first.

Add select/deselect all checkbox to manual import (#1152)

Rogerio Camorim21bcd0c69d58
diff --git a/frontend/src/components/import-review-table.tsx b/frontend/src/components/import-review-table.tsx
index 05db4cd9..ddca134d 100644
--- a/frontend/src/components/import-review-table.tsx
+++ b/frontend/src/components/import-review-table.tsx
@@ -1,4 +1,4 @@
-import { useMemo, useState } from 'react'
+import { useMemo, useRef, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import type { ImportReviewTransaction, Category, CategoryGroup } from '@/types'
import { formatCurrency } from '@/lib/format'
@@ -42,6 +42,7 @@ interface ImportReviewTableProps {
statusFilter: 'all' | 'included' | 'excluded'
currentPage: number
onToggleExcluded: (id: string) => void
+ onToggleAllFiltered: (ids: string[], excluded: boolean) => void
onChangeCategory: (id: string, categoryId: string | null) => void
onSearchChange: (query: string) => void
onCategoryIdsChange: (ids: string[]) => void
@@ -63,6 +64,7 @@ export function ImportReviewTable({
statusFilter,
currentPage,
onToggleExcluded,
+ onToggleAllFiltered,
onChangeCategory,
onSearchChange,
onCategoryIdsChange,
@@ -80,6 +82,7 @@ export function ImportReviewTable({
}
})
+ const selectAllRef = useRef<HTMLInputElement>(null)
const hasCategoryFilter = filterCategoryIds.length > 0 || filterUncategorized
const filtered = useMemo(() => {
@@ -104,6 +107,15 @@ export function ImportReviewTable({
})
}, [transactions, searchQuery, filterCategoryIds, filterUncategorized, hasCategoryFilter, statusFilter])
+ const allFilteredIncluded = filtered.length > 0 && filtered.every(tx => !tx.excluded)
+ const someFilteredIncluded = filtered.some(tx => !tx.excluded)
+
+ useEffect(() => {
+ if (selectAllRef.current) {
+ selectAllRef.current.indeterminate = someFilteredIncluded && !allFilteredIncluded
+ }
+ }, [allFilteredIncluded, someFilteredIncluded])
+
const totalPages = Math.max(1, Math.ceil(filtered.length / pageSize))
const safePage = Math.min(currentPage, totalPages)
const pageItems = filtered.slice((safePage - 1) * pageSize, safePage * pageSize)
@@ -144,7 +156,18 @@ export function ImportReviewTable({
<TableHeader>
<TableRow className="hover:bg-transparent bg-transparent border-b border-border">
<TableHead className="text-xs font-medium text-muted-foreground py-3 pl-4 w-[40px]">
- <span className="sr-only">Toggle</span>
+ <input
+ ref={selectAllRef}
+ type="checkbox"
+ checked={allFilteredIncluded}
+ onChange={() => {
+ const ids = filtered.map(tx => tx._id)
+ onToggleAllFiltered(ids, allFilteredIncluded)
+ }}
+ disabled={filtered.length === 0}
+ title={t('import.selectAll')}
+ className="rounded border-border text-primary focus:ring-primary"
+ />
</TableHead>
<TableHead className="text-xs font-medium text-muted-foreground py-3 w-[100px]">
{t('transactions.date')}
diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json
index 0f73184f..6abe2685 100644
--- a/frontend/src/locales/de.json
+++ b/frontend/src/locales/de.json
@@ -1720,7 +1720,8 @@
"invalid_date": "Ungültiges Datumsformat",
"no_amount": "Kein Zu- oder Abflussbetrag",
"invalid_amount": "Ungültiges Betragsformat"
- }
+ },
+ "selectAll": "Alle auswählen"
},
"assetImport": {
"title": "Wertpapierorders importieren",
diff --git a/frontend/src/locales/el.json b/frontend/src/locales/el.json
index 8de8dd1e..936ee8b4 100644
--- a/frontend/src/locales/el.json
+++ b/frontend/src/locales/el.json
@@ -1719,7 +1719,8 @@
"invalid_date": "Μη έγκυρη μορφή ημερομηνίας",
"no_amount": "Χωρίς ποσό εισροής ή εκροής",
"invalid_amount": "Μη έγκυρη μορφή ποσού"
- }
+ },
+ "selectAll": "Επιλογή όλων"
},
"assetImport": {
"title": "Εισαγωγή επενδυτικών εντολών",
diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json
index 2f6e076c..b57396c9 100644
--- a/frontend/src/locales/en.json
+++ b/frontend/src/locales/en.json
@@ -1719,7 +1719,8 @@
"invalid_date": "Invalid Date Format",
"no_amount": "No Inflow or Outflow Amount",
"invalid_amount": "Invalid Amount Format"
- }
+ },
+ "selectAll": "Select all"
},
"assetImport": {
"title": "Import investment orders",
diff --git a/frontend/src/locales/es.json b/frontend/src/locales/es.json
index 094c8ab3..161f1767 100644
--- a/frontend/src/locales/es.json
+++ b/frontend/src/locales/es.json
@@ -1723,7 +1723,8 @@
"invalid_date": "Formato de fecha no válido",
"no_amount": "Sin importe de entrada o salida",
"invalid_amount": "Formato de importe no válido"
- }
+ },
+ "selectAll": "Seleccionar todo"
},
"assetImport": {
"title": "Importar órdenes de inversión",
diff --git a/frontend/src/locales/fr.json b/frontend/src/locales/fr.json
index dbd2bce7..101700a8 100644
--- a/frontend/src/locales/fr.json
+++ b/frontend/src/locales/fr.json
@@ -1723,7 +1723,8 @@
"invalid_date": "Format de date invalide",
"no_amount": "Aucun montant d'entrée ou de sortie",
"invalid_amount": "Format de montant invalide"
- }
+ },
+ "selectAll": "Tout sélectionner"
},
"assetImport": {
"title": "Importer des ordres d'investissement",
diff --git a/frontend/src/locales/hi.json b/frontend/src/locales/hi.json
index d203a845..5a94b42c 100644
--- a/frontend/src/locales/hi.json
+++ b/frontend/src/locales/hi.json
@@ -1719,7 +1719,8 @@
"invalid_date": "अमान्य तिथि प्रारूप",
"no_amount": "कोई आवक या जावक राशि नहीं",
"invalid_amount": "अमान्य राशि प्रारूप"
- }
+ },
+ "selectAll": "सभी चुनें"
},
"assetImport": {
"title": "निवेश ऑर्डर इंपोर्ट करें",
diff --git a/frontend/src/locales/it.json b/frontend/src/locales/it.json
index 52b51cf4..e5a0b672 100644
--- a/frontend/src/locales/it.json
+++ b/frontend/src/locales/it.json
@@ -1723,7 +1723,8 @@
"invalid_date": "Formato data non valido",
"no_amount": "Nessun importo in entrata o in uscita",
"invalid_amount": "Formato importo non valido"
- }
+ },
+ "selectAll": "Seleziona tutto"
},
"assetImport": {
"title": "Importa ordini di investimento",
diff --git a/frontend/src/locales/ja.json b/frontend/src/locales/ja.json
index 7eae6272..b80a2b8a 100644
--- a/frontend/src/locales/ja.json
+++ b/frontend/src/locales/ja.json
@@ -1719,7 +1719,8 @@
"invalid_date": "無効な日付形式",
"no_amount": "入金/出金金額なし",
"invalid_amount": "無効な金額形式"
- }
+ },
+ "selectAll": "すべて選択"
},
"assetImport": {
"title": "投資注文をインポート",
diff --git a/frontend/src/locales/nl.json b/frontend/src/locales/nl.json
index 2a9f7635..f50efad7 100644
--- a/frontend/src/locales/nl.json
+++ b/frontend/src/locales/nl.json
@@ -1721,7 +1721,8 @@
"invalid_date": "Ongeldige datumformaat",
"no_amount": "Geen in- of uitstroombedrag",
"invalid_amount": "Ongeldig bedragformaat"
- }
+ },
+ "selectAll": "Alles selecteren"
},
"assetImport": {
"title": "Investeringsorders importeren",
diff --git a/frontend/src/locales/pl.json b/frontend/src/locales/pl.json
index b20b75ca..40481e1c 100644
--- a/frontend/src/locales/pl.json
+++ b/frontend/src/locales/pl.json
@@ -1808,7 +1808,8 @@
"invalid_date": "Nieprawidłowy format daty",
"no_amount": "Brak kwoty wpływu lub wypływu",
"invalid_amount": "Nieprawidłowy format kwoty"
- }
+ },
+ "selectAll": "Zaznacz wszystko"
},
"assetImport": {
"title": "Importuj zlecenia inwestycyjne",
diff --git a/frontend/src/locales/pt-BR.json b/frontend/src/locales/pt-BR.json
index 39148a2f..f0740892 100644
--- a/frontend/src/locales/pt-BR.json
+++ b/frontend/src/locales/pt-BR.json
@@ -1723,7 +1723,8 @@
"invalid_date": "Formato de data inválido",
"no_amount": "Nenhum valor de entrada ou saída",
"invalid_amount": "Formato de valor inválido"
- }
+ },
+ "selectAll": "Selecionar todos"
},
"assetImport": {
"title": "Importar ordens de investimento",
diff --git a/frontend/src/locales/pt-PT.json b/frontend/src/locales/pt-PT.json
index 47ad59b0..31e7132a 100644
--- a/frontend/src/locales/pt-PT.json
+++ b/frontend/src/locales/pt-PT.json
@@ -1723,7 +1723,8 @@
"invalid_date": "Formato de data inválido",
"no_amount": "Nenhum valor de entrada ou saída",
"invalid_amount": "Formato de valor inválido"
- }
+ },
+ "selectAll": "Selecionar todos"
},
"assetImport": {
"title": "Importar ordens de investimento",
diff --git a/frontend/src/locales/ru.json b/frontend/src/locales/ru.json
index 883fbb9f..9be292cb 100644
--- a/frontend/src/locales/ru.json
+++ b/frontend/src/locales/ru.json
@@ -1736,7 +1736,8 @@
"invalid_date": "Неверный формат даты",
"no_amount": "Нет суммы прихода или расхода",
"invalid_amount": "Неверный формат суммы"
- }
+ },
+ "selectAll": "Выбрать все"
},
"assetImport": {
"title": "Импорт инвестиционных заявок",
diff --git a/frontend/src/locales/sk.json b/frontend/src/locales/sk.json
index 966a8599..73ece074 100644
--- a/frontend/src/locales/sk.json
+++ b/frontend/src/locales/sk.json
@@ -1835,7 +1835,8 @@
"invalid_date": "Neplatný formát dátumu",
"no_amount": "Chýba suma príjmu alebo výdaja",
"invalid_amount": "Neplatný formát sumy"
- }
+ },
+ "selectAll": "Vybrať všetko"
},
"assetImport": {
"title": "Import investičných pokynov",
diff --git a/frontend/src/locales/uk.json b/frontend/src/locales/uk.json
index 95afa408..964103a8 100644
--- a/frontend/src/locales/uk.json
+++ b/frontend/src/locales/uk.json
@@ -1736,7 +1736,8 @@
"invalid_date": "Недійсний формат дати",
"no_amount": "Немає суми надходження або витрати",
"invalid_amount": "Недійсний формат суми"
- }
+ },
+ "selectAll": "Вибрати все"
},
"assetImport": {
"title": "Імпорт інвестиційних заявок",
diff --git a/frontend/src/pages/import.tsx b/frontend/src/pages/import.tsx
index c675be99..cbb02e81 100644
--- a/frontend/src/pages/import.tsx
+++ b/frontend/src/pages/import.tsx
@@ -255,6 +255,13 @@ function TransactionImportPanel() {
))
}, [])
+ const handleToggleAllFiltered = useCallback((ids: string[], excluded: boolean) => {
+ const idSet = new Set(ids)
+ setReviewTransactions(prev => prev.map(t =>
+ idSet.has(t._id) ? { ...t, excluded } : t
+ ))
+ }, [])
+
const handleChangeCategory = useCallback((id: string, categoryId: string | null) => {
setReviewTransactions(prev => prev.map(t =>
t._id === id ? { ...t, selected_category_id: categoryId } : t
@@ -553,6 +560,7 @@ function TransactionImportPanel() {
statusFilter={statusFilter}
currentPage={currentPage}
onToggleExcluded={handleToggleExcluded}
+ onToggleAllFiltered={handleToggleAllFiltered}
onChangeCategory={handleChangeCategory}
onSearchChange={setSearchQuery}
onCategoryIdsChange={setFilterCategoryIds}