Skip to content

Commit

Permalink
fix results view column crowding fixes #9 (#13)
Browse files Browse the repository at this point in the history
move details view to its own modal
make teams side-by-side in game view

Signed-off-by: John Burns <[email protected]>
  • Loading branch information
wakingrufus authored Jan 12, 2018
1 parent 561e45a commit 4f477fa
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 54 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
92 changes: 49 additions & 43 deletions src/main/kotlin/com/github/wakingrufus/eloleague/game/GameView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<GameResultItem, String>("Player") { it.value.player.nameProperty }
Expand Down
Original file line number Diff line number Diff line change
@@ -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.*

Expand All @@ -13,7 +15,7 @@ class ResultsView : Fragment() {

override val root = borderpane {

left {
center {
id = "results-wrapper"

val table = tableview(leagueResultItem.players) {
Expand All @@ -39,9 +41,18 @@ class ResultsView : Fragment() {
}

}
center {
this += find<ResultsDetailsView>(mapOf("gameResults" to gameResults))
bottom {
button("View Details") {
enableWhen { Bindings.isNotEmpty(gameResults) }
setOnAction {
find<ResultsDetailsView>(mapOf("gameResults" to gameResults)).apply {
openModal(
stageStyle = StageStyle.UTILITY,
block = true
)
}
}
}
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -44,9 +42,10 @@ class ResultsDetailsViewTest : TornadoFxTest() {
showViewWithParams<ResultsDetailsView>(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",
Expand Down

0 comments on commit 4f477fa

Please sign in to comment.