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 <Card
label={tracker.string.TimeSpendReportAdd} label={tracker.string.TimeSpendReportAdd}
canSave={data.value !== 0} canSave={Number.isFinite(data.value) && data.value !== 0}
okAction={create} okAction={create}
on:close on:close
okLabel={value === undefined ? presentation.string.Create : presentation.string.Save} okLabel={value === undefined ? presentation.string.Create : presentation.string.Save}

View File

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