mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 14:31:25 +00: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:
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user