-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
frontend/src/main/scala/ru/vityaman/mylogistics/view/AddCellForm.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package ru.vityaman.mylogistics.view | ||
|
||
import ru.vityaman.mylogistics.API | ||
import ru.vityaman.mylogistics.model.Atom | ||
|
||
import scala.concurrent.ExecutionContext.Implicits.global | ||
import scala.util._ | ||
|
||
import com.raquo.laminar.api.L._ | ||
import org.scalajs.dom | ||
|
||
object AddCellForm { | ||
def apply(): HtmlElement = { | ||
val storageId: Var[String] = Var("") | ||
val itemKindId: Var[String] = Var("") | ||
val amount: Var[String] = Var("") | ||
|
||
val addCell = () => { | ||
API.Storage | ||
.addCell( | ||
storageId.now().toInt, | ||
Atom( | ||
itemKindId.now().toInt, | ||
amount.now().toInt | ||
) | ||
) | ||
.onComplete { | ||
case Failure(_) => dom.window.alert("Sad things happened... :.)") | ||
case Success(_) => dom.window.alert("Added, yoyoyo!") | ||
} | ||
} | ||
|
||
div( | ||
display.flex, | ||
flexDirection.row, | ||
justifyContent.center, | ||
div( | ||
margin.percent(1), | ||
a("Storage Id: "), | ||
input( | ||
onInput.mapToValue.filter( | ||
_.forall(Character.isDigit) | ||
) --> storageId | ||
) | ||
), | ||
div( | ||
margin.percent(1), | ||
a("Item Kind Id: "), | ||
input( | ||
onInput.mapToValue.filter( | ||
_.forall(Character.isDigit) | ||
) --> itemKindId | ||
) | ||
), | ||
div( | ||
margin.percent(1), | ||
a("Amount: "), | ||
input( | ||
onInput.mapToValue.filter( | ||
_.forall(Character.isDigit) | ||
) --> amount | ||
) | ||
), | ||
div( | ||
margin.percent(1), | ||
button(typ("button"), "Add", onClick --> (_ => addCell())) | ||
) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters