-
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.
#17 [front] added create storage form
- Loading branch information
Showing
4 changed files
with
62 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
11 changes: 11 additions & 0 deletions
11
frontend/src/main/scala/ru/vityaman/mylogistics/model/StorageDraft.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,11 @@ | ||
package ru.vityaman.mylogistics.model | ||
|
||
import upickle.default._ | ||
|
||
final case class StorageDraft( | ||
name: String | ||
) | ||
|
||
object StorageDraft { | ||
implicit val rw: ReadWriter[StorageDraft] = macroRW[StorageDraft] | ||
} |
39 changes: 39 additions & 0 deletions
39
frontend/src/main/scala/ru/vityaman/mylogistics/view/CreateStorageForm.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,39 @@ | ||
package ru.vityaman.mylogistics.view | ||
|
||
import ru.vityaman.mylogistics.API | ||
|
||
import scala.concurrent.ExecutionContext.Implicits.global | ||
import scala.util._ | ||
|
||
import com.raquo.laminar.api.L._ | ||
import org.scalajs.dom | ||
|
||
object CreateStorageForm { | ||
def apply(): HtmlElement = { | ||
val name: Var[String] = Var("") | ||
|
||
val create = () => { | ||
API.Storage | ||
.create(name.now()) | ||
.onComplete { | ||
case Failure(_) => dom.window.alert("Sad things happened... :.)") | ||
case Success(_) => dom.window.alert("Created, yoyoyo!") | ||
} | ||
} | ||
|
||
div( | ||
display.flex, | ||
flexDirection.row, | ||
justifyContent.center, | ||
div( | ||
margin.percent(1), | ||
a("Name: "), | ||
input(onInput.mapToValue --> name) | ||
), | ||
div( | ||
margin.percent(1), | ||
button(typ("button"), "Create", onClick --> (_ => create())) | ||
) | ||
) | ||
} | ||
} |
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