mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-20 13:49:39 +02:00
Add transaction sidebar (#534)
* Create sidebar element and working with turbo * Add overview fields * Add columns to transations and tidy modal * permit new transaction params * Add autosubmit form controller * remove unused show code
This commit is contained in:
parent
9c9459211f
commit
7f2633f9da
9 changed files with 134 additions and 15 deletions
33
app/javascript/controllers/auto_submit_form_controller.js
Normal file
33
app/javascript/controllers/auto_submit_form_controller.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
import { Controller } from '@hotwired/stimulus';
|
||||
|
||||
export default class extends Controller {
|
||||
|
||||
get cssInputSelector() {
|
||||
return 'input:not(.no-auto-submit), textarea:not(.no-auto-submit)';
|
||||
}
|
||||
|
||||
get inputElements() {
|
||||
return this.element.querySelectorAll(this.cssInputSelector);
|
||||
}
|
||||
|
||||
get selectElements() {
|
||||
return this.element.querySelectorAll('select:not(.no-auto-submit)');
|
||||
}
|
||||
|
||||
connect() {
|
||||
this.inputElements.forEach(el => el.addEventListener('change', this.handler.bind(this)));
|
||||
this.selectElements.forEach(el => el.addEventListener('change', this.handler.bind(this)));
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
this.inputElements.forEach(el => el.removeEventListener('change', this.handler.bind(this)));
|
||||
this.selectElements.forEach(el => el.removeEventListener('change', this.handler.bind(this)));
|
||||
}
|
||||
|
||||
handler(e) {
|
||||
console.log(e);
|
||||
this.element.requestSubmit();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue