diff --git a/build.gradle b/build.gradle index eed470a..b3c6fb7 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ repositories { maven { url 'https://jitpack.io' } } -version = "0.5.1" +version = "0.5.2" dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version" diff --git a/src/main/kotlin/com/github/wakingrufus/eloleague/game/GameView.kt b/src/main/kotlin/com/github/wakingrufus/eloleague/game/GameView.kt index 08a910d..1497d0b 100644 --- a/src/main/kotlin/com/github/wakingrufus/eloleague/game/GameView.kt +++ b/src/main/kotlin/com/github/wakingrufus/eloleague/game/GameView.kt @@ -45,66 +45,72 @@ class GameView : Fragment("Player View") { } } - - fieldset("Team 1") { - vbox { - children.bind(gameModel.team1Players.value) { player: PlayerItem -> - field(player.name) { - button("Remove") { - action { - gameModel.team1Players.value.remove(player) + hbox { + fieldset("Team 1") { + vbox { + style { + minHeight = 8.em + } + children.bind(gameModel.team1Players.value) { player: PlayerItem -> + field(player.name) { + button("Remove") { + action { + gameModel.team1Players.value.remove(player) + } } } } - } - } - button("Add Player") { - action { - gameModel.team1Players.value.add(choosePlayer( - leagueModel.players.value, - gameModel.team1Players.value)) } - /* - gameModel.addValidator(this, gameModel.team1Players) { - if (gameModel.team1Players.value.isEmpty()) { - tornadofx.error("team 1 required") + button("Add Player") { + action { + gameModel.team1Players.value.add(choosePlayer( + leagueModel.players.value, + gameModel.team1Players.value)) } - null + /* + gameModel.addValidator(this, gameModel.team1Players) { + if (gameModel.team1Players.value.isEmpty()) { + tornadofx.error("team 1 required") + } + null + } + */ } - */ - } - field("team 1 score") { - textfield(gameModel.team1Score).validator { - if (isValidInt(it)) null else error("must be numeric") + field("team 1 score") { + textfield(gameModel.team1Score).validator { + if (isValidInt(it)) null else error("must be numeric") + } } } - } - fieldset("Team 2") { - vbox { - children.bind(gameModel.team2Players.value) { player: PlayerItem -> - field(player.name) { - button("Remove") { - action { - gameModel.team2Players.value.remove(player) + fieldset("Team 2") { + vbox { + style { + minHeight = 8.em + } + children.bind(gameModel.team2Players.value) { player: PlayerItem -> + field(player.name) { + button("Remove") { + action { + gameModel.team2Players.value.remove(player) + } } } } } - } - button("Add Player").setOnAction { - gameModel.team2Players.value.add(choosePlayer( - leagueModel.players.value, - gameModel.team2Players.value)) - } - field("team 2 score") { - textfield(gameModel.team2Score).validator { - if (isValidInt(it)) null else error("must be numeric") + button("Add Player").setOnAction { + gameModel.team2Players.value.add(choosePlayer( + leagueModel.players.value, + gameModel.team2Players.value)) + } + field("team 2 score") { + textfield(gameModel.team2Score).validator { + if (isValidInt(it)) null else error("must be numeric") + } } } } - buttonbar { button("Save") { enableWhen(gameModel.dirty.and(gameModel.valid)) diff --git a/src/main/kotlin/com/github/wakingrufus/eloleague/results/ResultsDetailsView.kt b/src/main/kotlin/com/github/wakingrufus/eloleague/results/ResultsDetailsView.kt index a6142de..bee017c 100644 --- a/src/main/kotlin/com/github/wakingrufus/eloleague/results/ResultsDetailsView.kt +++ b/src/main/kotlin/com/github/wakingrufus/eloleague/results/ResultsDetailsView.kt @@ -14,7 +14,7 @@ class ResultsDetailsView : Fragment() { override val root = vbox { id = "result-details-wrapper" - visibleWhen { Bindings.isNotEmpty(gameResults) } + // visibleWhen { Bindings.isNotEmpty(gameResults) } val table = tableview(ReadOnlyListWrapper(gameResults)) { column("time", GameResultItem::entryDate) column("Player") { it.value.player.nameProperty } diff --git a/src/main/kotlin/com/github/wakingrufus/eloleague/results/ResultsView.kt b/src/main/kotlin/com/github/wakingrufus/eloleague/results/ResultsView.kt index 06623b2..107f0fa 100644 --- a/src/main/kotlin/com/github/wakingrufus/eloleague/results/ResultsView.kt +++ b/src/main/kotlin/com/github/wakingrufus/eloleague/results/ResultsView.kt @@ -1,7 +1,9 @@ package com.github.wakingrufus.eloleague.results +import javafx.beans.binding.Bindings import javafx.collections.FXCollections import javafx.collections.ObservableList +import javafx.stage.StageStyle import mu.KLogging import tornadofx.* @@ -13,7 +15,7 @@ class ResultsView : Fragment() { override val root = borderpane { - left { + center { id = "results-wrapper" val table = tableview(leagueResultItem.players) { @@ -39,9 +41,18 @@ class ResultsView : Fragment() { } } - center { - this += find(mapOf("gameResults" to gameResults)) + bottom { + button("View Details") { + enableWhen { Bindings.isNotEmpty(gameResults) } + setOnAction { + find(mapOf("gameResults" to gameResults)).apply { + openModal( + stageStyle = StageStyle.UTILITY, + block = true + ) + } + } + } } } - -} \ No newline at end of file +} diff --git a/src/test/kotlin/com/github/wakingrufus/eloleague/results/ResultsDetailsViewTest.kt b/src/test/kotlin/com/github/wakingrufus/eloleague/results/ResultsDetailsViewTest.kt index a4e9873..ee1101c 100644 --- a/src/test/kotlin/com/github/wakingrufus/eloleague/results/ResultsDetailsViewTest.kt +++ b/src/test/kotlin/com/github/wakingrufus/eloleague/results/ResultsDetailsViewTest.kt @@ -6,8 +6,6 @@ import com.github.wakingrufus.eloleague.printNodes import com.github.wakingrufus.eloleague.waitFor import javafx.collections.FXCollections import javafx.collections.ObservableList -import javafx.scene.Node -import javafx.scene.Parent import mu.KLogging import org.junit.Test import org.testfx.api.FxAssert @@ -44,9 +42,10 @@ class ResultsDetailsViewTest : TornadoFxTest() { showViewWithParams(mapOf( "gameResults" to resultDetails )) - waitFor({scene!!.root.childrenUnmodifiable[0].isVisible}) - FxAssert.verifyThat("#result-details-wrapper", NodeMatchers.isVisible()) + waitFor({ scene!!.root.childrenUnmodifiable[0].isVisible }) printNodes(scene!!.root) + FxAssert.verifyThat("#result-details-wrapper", NodeMatchers.isVisible()) + FxAssert.verifyThat("#result-details-wrapper .table-view", NodeMatchers.isVisible()) FxAssert.verifyThat("#result-details-wrapper .table-view .table-row-cell #team-1", NodeMatchers.hasText("Adam, Beth")) FxAssert.verifyThat("#result-details-wrapper .table-view .table-row-cell #team-2",