TSK-404 Add number value check in editor (#2367)

Signed-off-by: Alexander Onnikov <alexander.onnikov@xored.com>
This commit is contained in:
Alexander Onnikov 2022-11-09 13:56:24 +07:00 committed by GitHub
parent 19429e2977
commit e70ca4f65e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -72,7 +72,7 @@
<Card
label={tracker.string.TimeSpendReportAdd}
canSave={data.value !== 0}
canSave={Number.isFinite(data.value) && data.value !== 0}
okAction={create}
on:close
okLabel={value === undefined ? presentation.string.Create : presentation.string.Save}

View File

@ -30,7 +30,10 @@
let shown: boolean = false
function _onchange (ev: Event) {
onChange((ev.target as HTMLInputElement).valueAsNumber)
const value = (ev.target as HTMLInputElement).valueAsNumber
if (Number.isFinite(value)) {
onChange(value)
}
}
</script>
@ -40,7 +43,7 @@
on:click={(ev) => {
if (!shown && !readonly) {
showPopup(EditBoxPopup, { value, format: 'number' }, eventToHTMLElement(ev), (res) => {
if (res !== undefined) {
if (Number.isFinite(res)) {
value = res
onChange(value)
}