mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-20 21:59:38 +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);
|
clearTimeout(this.timeout);
|
||||||
this.timeout = setTimeout(() => {
|
this.timeout = setTimeout(() => {
|
||||||
this.element.requestSubmit();
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ class ImportsTest < ApplicationSystemTestCase
|
||||||
within(form) do
|
within(form) do
|
||||||
select = form.find("select")
|
select = form.find("select")
|
||||||
select "Depository", from: select["id"]
|
select "Depository", from: select["id"]
|
||||||
sleep 1
|
sleep 0.5
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue