allow date edit
Some checks are pending
Deploy static content to Pages / deploy (push) Waiting to run
Some checks are pending
Deploy static content to Pages / deploy (push) Waiting to run
This commit is contained in:
parent
6d029efeaf
commit
b942799298
1 changed files with 12 additions and 1 deletions
|
|
@ -15,6 +15,12 @@ class EntryComponent(
|
||||||
):
|
):
|
||||||
def render: ReactiveHtmlElement[HTMLTableRowElement] = {
|
def render: ReactiveHtmlElement[HTMLTableRowElement] = {
|
||||||
if editMode then
|
if editMode then
|
||||||
|
val dateInput =
|
||||||
|
input(
|
||||||
|
cls := "input",
|
||||||
|
value := new Date(entry.date.payload).toDateString()
|
||||||
|
)
|
||||||
|
|
||||||
val driverInput = input(cls := "input", value := entry.driver.payload)
|
val driverInput = input(cls := "input", value := entry.driver.payload)
|
||||||
|
|
||||||
val startKmInput =
|
val startKmInput =
|
||||||
|
|
@ -78,7 +84,7 @@ class EntryComponent(
|
||||||
val paidCheckbox =
|
val paidCheckbox =
|
||||||
input(`type` := "checkbox", checked := entry.paid.payload)
|
input(`type` := "checkbox", checked := entry.paid.payload)
|
||||||
tr(
|
tr(
|
||||||
td(),
|
td(dateInput),
|
||||||
td(driverInput),
|
td(driverInput),
|
||||||
td(startKmInput),
|
td(startKmInput),
|
||||||
td(endKmInput),
|
td(endKmInput),
|
||||||
|
|
@ -90,6 +96,10 @@ class EntryComponent(
|
||||||
button(
|
button(
|
||||||
cls := "button is-success",
|
cls := "button is-success",
|
||||||
onClick --> {
|
onClick --> {
|
||||||
|
val newDate =
|
||||||
|
val parsed = Date.parse(dateInput.ref.value)
|
||||||
|
if parsed != entry.date.payload then entry.date.write(parsed)
|
||||||
|
else entry.date
|
||||||
val newDriver =
|
val newDriver =
|
||||||
if driverInput.ref.value != entry.driver.payload then
|
if driverInput.ref.value != entry.driver.payload then
|
||||||
entry.driver.write(driverInput.ref.value)
|
entry.driver.write(driverInput.ref.value)
|
||||||
|
|
@ -112,6 +122,7 @@ class EntryComponent(
|
||||||
else entry.paid
|
else entry.paid
|
||||||
entryEditBus.emit(
|
entryEditBus.emit(
|
||||||
entry.copy(
|
entry.copy(
|
||||||
|
date = newDate,
|
||||||
driver = newDriver,
|
driver = newDriver,
|
||||||
startKm = newStartKm,
|
startKm = newStartKm,
|
||||||
endKm = newEndKm,
|
endKm = newEndKm,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue