mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-20 13:49:39 +02:00
Fixes issue with mapping values during the transactions import (#1327)
* Adds custom debounce timeout to autosubmit form controller - There's a default debounce timeout based on element type - You can parameterize debounce timeout on a data-attribute * Adds corrections based on js_lint * Restores sleep on test --------- Co-authored-by: Nicolás Galdámez <nicolas.galdamez@unagisoftware.com>
This commit is contained in:
parent
9b6a2cce56
commit
1b654faf9a
2 changed files with 24 additions and 3 deletions
|
@ -24,10 +24,31 @@ export default class extends Controller {
|
|||
});
|
||||
}
|
||||
|
||||
handleInput = () => {
|
||||
handleInput = (event) => {
|
||||
const target = event.target
|
||||
|
||||
clearTimeout(this.timeout);
|
||||
this.timeout = setTimeout(() => {
|
||||
this.element.requestSubmit();
|
||||
}, 500);
|
||||
}, this.#debounceTimeout(target));
|
||||
};
|
||||
|
||||
#debounceTimeout(element) {
|
||||
if(element.dataset.autosubmitDebounceTimeout) {
|
||||
return Number.parseInt(element.dataset.autosubmitDebounceTimeout);
|
||||
}
|
||||
|
||||
const type = element.type || element.tagName;
|
||||
|
||||
switch (type.toLowerCase()) {
|
||||
case 'input':
|
||||
case 'textarea':
|
||||
return 500;
|
||||
case 'select-one':
|
||||
case 'select-multiple':
|
||||
return 0;
|
||||
default:
|
||||
return 500;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue