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

Feat transactions search (#532)

* gem: Add ransack gem

* feat: Implement transactions search
This commit is contained in:
Ciocanel Razvan 2024-03-11 14:51:16 +02:00 committed by GitHub
parent 7f2633f9da
commit cca779d3c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 116 additions and 33 deletions

View file

@ -0,0 +1,29 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["search", "date"]
connect() {
this.timeout = null
}
search() {
clearTimeout(this.timeout);
this.timeout = setTimeout(() => {
this.submitForm();
}, 300); // Debounce time in milliseconds
}
submitForm() {
const formData = new FormData(this.searchTarget.form);
const searchParams = new URLSearchParams(formData).toString();
const newUrl = `${window.location.pathname}?${searchParams}`;
history.pushState({}, '', newUrl);
this.searchTarget.form.requestSubmit();
}
afterSubmit() {
this.searchTarget.focus();
}
}