1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-19 13:19:39 +02:00

Bulk transaction deletion (#845)

* Clean up transaction show view, add delete button

* Clean up tailwind global styles, add switch

* Bulk deletion controller and tests

* Normalize translations

* Add bulk deletion button and form
This commit is contained in:
Zach Gollwitzer 2024-06-07 16:56:30 -04:00 committed by GitHub
parent 115f792198
commit d3f9be15f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 225 additions and 95 deletions

View file

@ -18,6 +18,12 @@ export default class extends Controller {
document.removeEventListener("turbo:load", this.#updateView)
}
submitBulkDeletionRequest(e) {
const form = e.target.closest("form");
this.#addHiddenFormInputsForSelectedIds(form, "bulk_delete[transaction_ids][]", this.selectedIdsValue)
form.requestSubmit()
}
togglePageSelection(e) {
if (e.target.checked) {
this.#selectAll()
@ -54,6 +60,16 @@ export default class extends Controller {
this.#updateView()
}
#addHiddenFormInputsForSelectedIds(form, paramName, transactionIds) {
transactionIds.forEach(id => {
const input = document.createElement("input");
input.type = 'hidden'
input.name = paramName
input.value = id
form.appendChild(input)
})
}
#rowsForGroup(group) {
return this.rowTargets.filter(row => group.contains(row))
}