2020-09-19 13:06:45 +02:00
|
|
|
/**
|
|
|
|
* Submit on change
|
|
|
|
* Simply submits a parent form when this input is changed.
|
|
|
|
* @extends {Component}
|
|
|
|
*/
|
|
|
|
class SubmitOnChange {
|
|
|
|
|
|
|
|
setup() {
|
2021-08-04 21:48:23 +02:00
|
|
|
this.filter = this.$opts.filter;
|
|
|
|
|
|
|
|
this.$el.addEventListener('change', (event) => {
|
|
|
|
|
|
|
|
if (this.filter && !event.target.matches(this.filter)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-09-19 13:06:45 +02:00
|
|
|
const form = this.$el.closest('form');
|
|
|
|
if (form) {
|
|
|
|
form.submit();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SubmitOnChange;
|