Open-source personal finance manager. Self-hosted, privacy-first.
feat: bulk delete transactions (#509)
Tai Nguyen83362ba0af59
diff --git a/backend/app/api/transactions.py b/backend/app/api/transactions.pyindex ac758489..6bbaf462 100644--- a/backend/app/api/transactions.py+++ b/backend/app/api/transactions.py@@ -15,7 +15,7 @@ from app.core.workspace_context import (current_workspace,current_writable_workspace,)-from app.schemas.transaction import BulkAddToGroupRequest, BulkCategorizeRequest, BulkTagsRequest, CreateCounterpartRequest, LinkTransferRequest, TransactionCreate, TransactionRead, TransactionUpdate, TransferCreate, TransferRead+from app.schemas.transaction import BulkAddToGroupRequest, BulkCategorizeRequest, BulkTagsRequest, CreateCounterpartRequest, LinkTransferRequest, TransactionBulkDeleteRequest, TransactionCreate, TransactionRead, TransactionUpdate, TransferCreate, TransferReadfrom app.schemas.transaction_calendar import TransactionCalendarResponsefrom app.services import transaction_servicefrom app.services.admin_service import get_credit_card_accounting_mode@@ -501,3 +501,15 @@ async def delete_transaction()if not deleted:raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Transaction not found")++[email protected]("/bulk-delete", status_code=status.HTTP_200_OK)+async def bulk_delete_transactions(+ data: TransactionBulkDeleteRequest,+ ctx: WorkspaceContext = Depends(current_writable_workspace),+ session: AsyncSession = Depends(get_async_session),+):+ deleted_count = await transaction_service.bulk_delete_transactions(+ session, ctx.workspace.id, data.transaction_ids+ )+ return {"deleted": deleted_count}diff --git a/backend/app/schemas/transaction.py b/backend/app/schemas/transaction.pyindex 63f9700a..920e746a 100644--- a/backend/app/schemas/transaction.py+++ b/backend/app/schemas/transaction.py@@ -120,6 +120,10 @@ class BulkCategorizeRequest(BaseModel):category_id: Optional[uuid.UUID] = None+class TransactionBulkDeleteRequest(BaseModel):+ transaction_ids: list[uuid.UUID]++class BulkAddToGroupRequest(BaseModel):transaction_ids: list[uuid.UUID]group_id: uuid.UUIDdiff --git a/backend/app/services/transaction_service.py b/backend/app/services/transaction_service.pyindex a0b5b85c..2fc47b86 100644--- a/backend/app/services/transaction_service.py+++ b/backend/app/services/transaction_service.py@@ -4,7 +4,7 @@ from datetime import datefrom decimal import Decimalfrom typing import Optional, cast-from sqlalchemy import CursorResult, select, func, or_, not_, update+from sqlalchemy import CursorResult, delete, select, func, or_, not_, updatefrom sqlalchemy.ext.asyncio import AsyncSessionfrom sqlalchemy.orm import selectinload@@ -1558,3 +1558,47 @@ async def delete_transaction(await session.delete(transaction)await session.commit()return True+++async def bulk_delete_transactions(+ session: AsyncSession,+ workspace_id: uuid.UUID,+ transaction_ids: list[uuid.UUID],+) -> int:+ from app.services.attachment_service import cleanup_attachment_files++ result = await session.execute(+ select(Transaction.id, Transaction.transfer_pair_id)+ .where(+ Transaction.id.in_(transaction_ids),+ Transaction.workspace_id == workspace_id,+ )+ )+ transactions = result.all()+ if not transactions:+ return 0++ valid_ids = [row[0] for row in transactions]+ transfer_pair_ids = {row[1] for row in transactions if row[1]}++ paired_ids = []+ if transfer_pair_ids:+ paired_result = await session.execute(+ select(Transaction.id)+ .where(+ Transaction.transfer_pair_id.in_(transfer_pair_ids),+ Transaction.id.notin_(valid_ids),+ Transaction.workspace_id == workspace_id,+ )+ )+ paired_ids = [row[0] for row in paired_result.all()]++ # Storage files must go before the rows: the DB cascade removes the+ # attachment records, and after that their storage keys are unreachable.+ await cleanup_attachment_files(session, valid_ids + paired_ids)++ await session.execute(+ delete(Transaction).where(Transaction.id.in_(valid_ids + paired_ids))+ )+ await session.commit()+ return len(valid_ids)diff --git a/backend/tests/test_transactions_api_coverage.py b/backend/tests/test_transactions_api_coverage.pyindex 0a8c29e3..b657345f 100644--- a/backend/tests/test_transactions_api_coverage.py+++ b/backend/tests/test_transactions_api_coverage.py@@ -356,6 +356,95 @@ async def test_bulk_categorize(client: AsyncClient, auth_headers, test_transactiassert resp.json()["updated"] == 2+async def test_bulk_delete_transactions(client: AsyncClient, auth_headers, test_transactions):+ ids = [str(t.id) for t in test_transactions[:2]]+ resp = await client.post(+ "/api/transactions/bulk-delete", headers=auth_headers,+ json={"transaction_ids": ids},+ )+ assert resp.status_code == 200+ assert resp.json()["deleted"] == 2+ for tx_id in ids:+ assert (await client.get(f"/api/transactions/{tx_id}", headers=auth_headers)).status_code == 404+++async def test_bulk_delete_ignores_other_workspace_ids(+ client: AsyncClient, auth_headers, session: AsyncSession, test_user, test_transactions+):+ other_ws = await create_workspace(+ session,+ name="Other",+ creator=test_user,+ self_membership=True,+ seed_defaults=False,+ )+ other_account = Account(+ id=uuid.uuid4(),+ user_id=test_user.id,+ workspace_id=other_ws.id,+ name="Other account",+ type="checking",+ currency="USD",+ )+ session.add(other_account)+ await session.flush()+ other_tx = Transaction(+ id=uuid.uuid4(),+ user_id=test_user.id,+ workspace_id=other_ws.id,+ account_id=other_account.id,+ description="Other workspace tx",+ amount=10,+ currency="USD",+ date=date.today(),+ type="debit",+ source="manual",+ )+ session.add(other_tx)+ await session.commit()++ resp = await client.post(+ "/api/transactions/bulk-delete", headers=auth_headers,+ json={"transaction_ids": [str(other_tx.id), NONEXISTENT]},+ )+ assert resp.status_code == 200+ assert resp.json()["deleted"] == 0+ still_there = await session.get(Transaction, other_tx.id)+ assert still_there is not None+++async def test_bulk_delete_cascades_transfer_pair(+ client: AsyncClient, auth_headers, test_account: Account+):+ other = await _manual_account(client, auth_headers, "Destino bulk delete")+ resp = await client.post(+ "/api/transactions/transfer", headers=auth_headers,+ json={+ "from_account_id": str(test_account.id),+ "to_account_id": other,+ "amount": "50.00",+ "date": date.today().isoformat(),+ "description": "Transferência bulk delete",+ },+ )+ assert resp.status_code == 201, resp.text+ debit_id = resp.json()["debit"]["id"]+ credit_id = resp.json()["credit"]["id"]++ resp = await client.post(+ "/api/transactions/bulk-delete", headers=auth_headers,+ json={"transaction_ids": [debit_id]},+ )+ assert resp.status_code == 200+ assert resp.json()["deleted"] == 1+ # The paired leg goes too, mirroring single-transaction delete semantics.+ assert (await client.get(f"/api/transactions/{debit_id}", headers=auth_headers)).status_code == 404+ assert (await client.get(f"/api/transactions/{credit_id}", headers=auth_headers)).status_code == 404++@pytest.mark.asyncioasync def test_bulk_categorize_rejects_category_from_other_workspace(client: AsyncClient, auth_headers, session: AsyncSession, test_user, test_transactionsdiff --git a/frontend/src/components/mobile-bulk-selection-actions.tsx b/frontend/src/components/mobile-bulk-selection-actions.tsxindex 1a80f39c..ef9a9bb3 100644--- a/frontend/src/components/mobile-bulk-selection-actions.tsx+++ b/frontend/src/components/mobile-bulk-selection-actions.tsx@@ -1,5 +1,5 @@import type { Category, CategoryGroup } from '@/types'-import { ArrowLeftRight, Check, MoreHorizontal, SlidersHorizontal, Users, X } from 'lucide-react'+import { ArrowLeftRight, Check, MoreHorizontal, SlidersHorizontal, Trash2, Users, X } from 'lucide-react'import { useTranslation } from 'react-i18next'import { CategorySelect } from '@/components/category-select'import { Button } from '@/components/ui/button'@@ -26,6 +26,7 @@ export type MobileBulkSelectionActionsProps = {onOpenGroup: () => voidonOpenTransfer: () => voidonCreateRule?: () => void+ onBulkDelete: () => voidonTagInputChange: (value: string) => voidonAddTags: (tags: string[]) => voidonRemoveTags: (tags: string[]) => void@@ -102,6 +103,9 @@ function BulkActionItems(props: MobileBulkSelectionActionsProps) {<ArrowLeftRight size={15} />{t('transactions.linkAsTransfer')}</DropdownMenuItem>{props.onCreateRule && <DropdownMenuItem onSelect={props.onCreateRule}><SlidersHorizontal size={15} />{t('transactions.createRule')}</DropdownMenuItem>}+ <DropdownMenuItem onSelect={props.onBulkDelete} className="text-destructive">+ <Trash2 size={15} />{t('transactions.bulkDelete')}+ </DropdownMenuItem><BulkTagEditor {...props} /></>)diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.tsindex 5082f353..5679bbaa 100644--- a/frontend/src/lib/api.ts+++ b/frontend/src/lib/api.ts@@ -540,6 +540,12 @@ export const transactions = {})return data},+ bulkDelete: async (transactionIds: string[]): Promise<{ deleted: number }> => {+ const { data } = await api.post('/transactions/bulk-delete', {+ transaction_ids: transactionIds,+ })+ return data+ },linkTransfer: async (transactionIds: string[]): Promise<{ debit: Transaction; credit: Transaction; transfer_pair_id: string }> => {const { data } = await api.post('/transactions/link-transfer', {transaction_ids: transactionIds,diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.jsonindex ffbf7258..1892a0ef 100644--- a/frontend/src/locales/de.json+++ b/frontend/src/locales/de.json@@ -369,6 +369,10 @@"summaryExcluded": "Ausgeschlossen","bulkCategorize": "Anwenden","bulkSuccess": "{{count}} Transaktionen kategorisiert",+ "bulkDelete": "Auswahl löschen",+ "bulkDeleteTitle": "{{count}} Transaktionen löschen?",+ "bulkDeleteDescription": "Dies löscht die ausgewählten Transaktionen dauerhaft, einschließlich Transfer-Gegenbuchungen und Anhängen. Dies kann nicht rückgängig gemacht werden.",+ "bulkDeleteSuccess": "{{count}} Transaktionen gelöscht","selectCategory": "Kategorie auswählen...","addToGroup": "Zur Gruppe hinzufügen","bulkAddToGroupTitle": "{{count}} Transaktionen zur Gruppe hinzufügen",diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.jsonindex 6eb4616f..4476a456 100644--- a/frontend/src/locales/en.json+++ b/frontend/src/locales/en.json@@ -369,6 +369,10 @@"summaryExcluded": "Excluded","bulkCategorize": "Apply","bulkSuccess": "{{count}} transactions categorized",+ "bulkDelete": "Delete selected",+ "bulkDeleteTitle": "Delete {{count}} transactions?",+ "bulkDeleteDescription": "This permanently deletes the selected transactions, including transfer counterparts and their attachments. This cannot be undone.",+ "bulkDeleteSuccess": "{{count}} transactions deleted","selectCategory": "Select category...","addToGroup": "Add to group","bulkAddToGroupTitle": "Add {{count}} transactions to a group",diff --git a/frontend/src/locales/es.json b/frontend/src/locales/es.jsonindex 0e7f9e5e..ce2e7c23 100644--- a/frontend/src/locales/es.json+++ b/frontend/src/locales/es.json@@ -369,6 +369,10 @@"summaryExcluded": "Excluido","bulkCategorize": "Aplicar","bulkSuccess": "{{count}} transacciones categorizadas",+ "bulkDelete": "Eliminar seleccionadas",+ "bulkDeleteTitle": "¿Eliminar {{count}} transacciones?",+ "bulkDeleteDescription": "Esto elimina permanentemente las transacciones seleccionadas, incluidas las contrapartes de transferencia y sus adjuntos. No se puede deshacer.",+ "bulkDeleteSuccess": "{{count}} transacciones eliminadas","selectCategory": "Seleccionar categoría...","addToGroup": "Agregar al grupo","bulkAddToGroupTitle": "Agregar {{count}} transacciones a un grupo",diff --git a/frontend/src/locales/fr.json b/frontend/src/locales/fr.jsonindex 50e68373..31b52622 100644--- a/frontend/src/locales/fr.json+++ b/frontend/src/locales/fr.json@@ -369,6 +369,10 @@"summaryExcluded": "Exclues","bulkCategorize": "Appliquer","bulkSuccess": "{{count}} transactions catégorisées",+ "bulkDelete": "Supprimer la sélection",+ "bulkDeleteTitle": "Supprimer {{count}} transactions ?",+ "bulkDeleteDescription": "Cela supprime définitivement les transactions sélectionnées, y compris les contreparties de virement et leurs pièces jointes. Cette action est irréversible.",+ "bulkDeleteSuccess": "{{count}} transactions supprimées","selectCategory": "Sélectionner une catégorie...","addToGroup": "Ajouter à un groupe","bulkAddToGroupTitle": "Ajouter {{count}} transactions à un groupe",diff --git a/frontend/src/locales/it.json b/frontend/src/locales/it.jsonindex f31c07bc..2e9f14da 100644--- a/frontend/src/locales/it.json+++ b/frontend/src/locales/it.json@@ -369,6 +369,10 @@"summaryExcluded": "Escluso","bulkCategorize": "Applica","bulkSuccess": "{{count}} transazioni categorizzate",+ "bulkDelete": "Elimina selezionate",+ "bulkDeleteTitle": "Eliminare {{count}} transazioni?",+ "bulkDeleteDescription": "Questo elimina definitivamente le transazioni selezionate, incluse le contropartite dei trasferimenti e i loro allegati. Non può essere annullato.",+ "bulkDeleteSuccess": "{{count}} transazioni eliminate","selectCategory": "Seleziona categoria...","addToGroup": "Aggiungi al gruppo","bulkAddToGroupTitle": "Aggiungi {{count}} transazioni a un gruppo",diff --git a/frontend/src/locales/pl.json b/frontend/src/locales/pl.jsonindex 55a35c0a..966f913d 100644--- a/frontend/src/locales/pl.json+++ b/frontend/src/locales/pl.json@@ -384,6 +384,16 @@"bulkSuccess_few": "Skategoryzowano {{count}} transakcje","bulkSuccess_many": "Skategoryzowano {{count}} transakcji","bulkSuccess_other": "Skategoryzowano {{count}} transakcji",+ "bulkDelete": "Usuń zaznaczone",+ "bulkDeleteTitle_one": "Usunąć {{count}} transakcję?",+ "bulkDeleteTitle_few": "Usunąć {{count}} transakcje?",+ "bulkDeleteTitle_many": "Usunąć {{count}} transakcji?",+ "bulkDeleteTitle_other": "Usunąć {{count}} transakcji?",+ "bulkDeleteDescription": "Spowoduje to trwałe usunięcie zaznaczonych transakcji, w tym powiązanych transferów i ich załączników. Nie można tego cofnąć.",+ "bulkDeleteSuccess_one": "Usunięto {{count}} transakcję",+ "bulkDeleteSuccess_few": "Usunięto {{count}} transakcje",+ "bulkDeleteSuccess_many": "Usunięto {{count}} transakcji",+ "bulkDeleteSuccess_other": "Usunięto {{count}} transakcji","selectCategory": "Wybierz kategorię...","addToGroup": "Dodaj do grupy","bulkAddToGroupTitle_one": "Dodaj {{count}} transakcję do grupy",diff --git a/frontend/src/locales/pt-BR.json b/frontend/src/locales/pt-BR.jsonindex ddece321..f839b242 100644--- a/frontend/src/locales/pt-BR.json+++ b/frontend/src/locales/pt-BR.json@@ -369,6 +369,10 @@"summaryExcluded": "Excluído","bulkCategorize": "Aplicar","bulkSuccess": "{{count}} transações categorizadas",+ "bulkDelete": "Excluir selecionadas",+ "bulkDeleteTitle": "Excluir {{count}} transações?",+ "bulkDeleteDescription": "Isso exclui permanentemente as transações selecionadas, incluindo contrapartes de transferência e seus anexos. Não dá para desfazer.",+ "bulkDeleteSuccess": "{{count}} transações excluídas","selectCategory": "Selecionar categoria...","addToGroup": "Adicionar ao grupo","bulkAddToGroupTitle": "Adicionar {{count}} transações a um grupo",diff --git a/frontend/src/locales/pt-PT.json b/frontend/src/locales/pt-PT.jsonindex 9df31504..98206d68 100644--- a/frontend/src/locales/pt-PT.json+++ b/frontend/src/locales/pt-PT.json@@ -369,6 +369,10 @@"summaryExcluded": "Excluído","bulkCategorize": "Aplicar","bulkSuccess": "{{count}} transações categorizadas",+ "bulkDelete": "Eliminar selecionadas",+ "bulkDeleteTitle": "Eliminar {{count}} transações?",+ "bulkDeleteDescription": "Isto elimina permanentemente as transações selecionadas, incluindo contrapartidas de transferência e os seus anexos. Não pode ser anulado.",+ "bulkDeleteSuccess": "{{count}} transações eliminadas","selectCategory": "Selecionar categoria...","addToGroup": "Adicionar ao grupo","bulkAddToGroupTitle": "Adicionar {{count}} transações a um grupo",diff --git a/frontend/src/locales/ru.json b/frontend/src/locales/ru.jsonindex 0fd3a7c7..959093dd 100644--- a/frontend/src/locales/ru.json+++ b/frontend/src/locales/ru.json@@ -369,6 +369,16 @@"summaryExcluded": "Исключено","bulkCategorize": "Применить","bulkSuccess": "{{count}} транзакций категоризированы",+ "bulkDelete": "Удалить выбранные",+ "bulkDeleteTitle_one": "Удалить {{count}} транзакцию?",+ "bulkDeleteTitle_few": "Удалить {{count}} транзакции?",+ "bulkDeleteTitle_many": "Удалить {{count}} транзакций?",+ "bulkDeleteTitle_other": "Удалить {{count}} транзакций?",+ "bulkDeleteDescription": "Выбранные транзакции будут удалены безвозвратно, включая парные переводы и вложения. Это действие нельзя отменить.",+ "bulkDeleteSuccess_one": "{{count}} транзакция удалена",+ "bulkDeleteSuccess_few": "{{count}} транзакции удалены",+ "bulkDeleteSuccess_many": "{{count}} транзакций удалено",+ "bulkDeleteSuccess_other": "{{count}} транзакций удалено","selectCategory": "Выберите категорию...","addToGroup": "Добавить в группу","bulkAddToGroupTitle": "Добавить {{count}} транзакций в группу",diff --git a/frontend/src/locales/uk.json b/frontend/src/locales/uk.jsonindex 0db7ccc6..2a03789a 100644--- a/frontend/src/locales/uk.json+++ b/frontend/src/locales/uk.json@@ -369,6 +369,16 @@"summaryExcluded": "Виключено","bulkCategorize": "Застосувати","bulkSuccess": "{{count}} транзакцій категоризовано",+ "bulkDelete": "Видалити вибрані",+ "bulkDeleteTitle_one": "Видалити {{count}} транзакцію?",+ "bulkDeleteTitle_few": "Видалити {{count}} транзакції?",+ "bulkDeleteTitle_many": "Видалити {{count}} транзакцій?",+ "bulkDeleteTitle_other": "Видалити {{count}} транзакцій?",+ "bulkDeleteDescription": "Вибрані транзакції буде видалено назавжди, включно з парними переказами та вкладеннями. Цю дію не можна скасувати.",+ "bulkDeleteSuccess_one": "{{count}} транзакція видалена",+ "bulkDeleteSuccess_few": "{{count}} транзакції видалені",+ "bulkDeleteSuccess_many": "{{count}} транзакцій видалено",+ "bulkDeleteSuccess_other": "{{count}} транзакцій видалено","selectCategory": "Оберіть категорію...","addToGroup": "Додати до групи","bulkAddToGroupTitle": "Додати {{count}} транзакцій до групи",diff --git a/frontend/src/pages/transactions.tsx b/frontend/src/pages/transactions.tsxindex d504675e..0b63925d 100644--- a/frontend/src/pages/transactions.tsx+++ b/frontend/src/pages/transactions.tsx@@ -14,6 +14,7 @@ import { Button } from '@/components/ui/button'import {Dialog,DialogContent,+ DialogDescription,DialogFooter,DialogHeader,DialogTitle,@@ -34,7 +35,7 @@ import {TableRow,} from '@/components/ui/table'import { Skeleton } from '@/components/ui/skeleton'-import { AlertTriangle, ArrowLeftRight, ArrowUp, ArrowDown, Check, HelpCircle, Info, Paperclip, Users, X, EyeClosed, SlidersHorizontal } from 'lucide-react'+import { AlertTriangle, ArrowLeftRight, ArrowUp, ArrowDown, Check, HelpCircle, Info, Paperclip, Trash2, Users, X, EyeClosed, SlidersHorizontal } from 'lucide-react'import type { Transaction, Rule } from '@/types'import { RuleDialog, type RuleDialogInitialData } from '@/components/rule-dialog'import { PageHeader } from '@/components/page-header'@@ -613,6 +614,20 @@ export default function TransactionsPage() {},})+ const [bulkDeleteConfirmOpen, setBulkDeleteConfirmOpen] = useState(false)+ const bulkDeleteMutation = useMutation({+ mutationFn: () => transactions.bulkDelete(Array.from(selectedIds)),+ onSuccess: (result) => {+ invalidateAfterTxMutation()+ setSelectedIds(new Set())+ setBulkDeleteConfirmOpen(false)+ toast.success(t('transactions.bulkDeleteSuccess', { count: result.deleted }))+ },+ onError: (error) => {+ toast.error(extractApiError(error))+ },+ })+const createCounterpartMutation = useMutation({mutationFn: ({ anchorId, toAccountId }: { anchorId: string; toAccountId: string }) =>transactions.createTransferCounterpart(anchorId, toAccountId),@@ -1675,6 +1690,7 @@ export default function TransactionsPage() {onTagInputChange={setBulkTagInput}onAddTags={(tags) => bulkAddTagsMutation.mutate({ ids: Array.from(selectedIds), tags })}onRemoveTags={(tags) => bulkRemoveTagsMutation.mutate({ ids: Array.from(selectedIds), tags })}+ onBulkDelete={() => setBulkDeleteConfirmOpen(true)}onClear={() => { setSelectedIds(new Set()); setBulkCategory(''); setBulkTagInput('') }}/>@@ -1826,6 +1842,18 @@ export default function TransactionsPage() {)})()}+ {/* Bulk Delete */}+ <Button+ size="sm"+ variant="destructive"+ onClick={() => setBulkDeleteConfirmOpen(true)}+ disabled={bulkDeleteMutation.isPending}+ className="h-8 px-3 shrink-0 text-sm"+ >+ <Trash2 size={15} className="lg:mr-1.5" />+ <span className="hidden lg:inline">{t('common.delete')}</span>+ </Button>+<div className="ml-auto" />{/* Close */}@@ -1959,6 +1987,30 @@ export default function TransactionsPage() {</DialogContent></Dialog>+ {/* Bulk Delete confirmation */}+ <Dialog open={bulkDeleteConfirmOpen} onOpenChange={setBulkDeleteConfirmOpen}>+ <DialogContent>+ <DialogHeader>+ <DialogTitle>{t('transactions.bulkDeleteTitle', { count: selectedIds.size })}</DialogTitle>+ <DialogDescription>+ {t('transactions.bulkDeleteDescription')}+ </DialogDescription>+ </DialogHeader>+ <DialogFooter>+ <Button variant="ghost" onClick={() => setBulkDeleteConfirmOpen(false)}>+ {t('common.cancel')}+ </Button>+ <Button+ variant="destructive"+ onClick={() => bulkDeleteMutation.mutate()}+ disabled={bulkDeleteMutation.isPending}+ >+ {bulkDeleteMutation.isPending ? t('common.loading') : t('common.delete')}+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>+{/* Create Rule from Transaction Dialog */}<RuleDialogkey={createRuleOpen ? 'rule-open' : 'rule-closed'}