Skip to content

Commit

Permalink
fix ranglistetab switch between Einzel-/Teamrangliste
Browse files Browse the repository at this point in the history
- update filter-preset

#984, #1027
  • Loading branch information
luechtdiode committed Jan 1, 2025
1 parent 90a2385 commit 79583d3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 21 deletions.
2 changes: 2 additions & 0 deletions src/main/scala/ch/seidel/kutu/domain/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ package object domain {

case class TurnerGeschlecht(geschlecht: String) extends DataObject {
override def easyprint = geschlecht.toLowerCase() match {
case "m,w" => "TuTi"
case "w,m" => "TuTi"
case "m" => "Turner"
case "w" => "Turnerinnen"
case "f" => "Turnerinnen"
Expand Down
11 changes: 9 additions & 2 deletions src/main/scala/ch/seidel/kutu/view/DefaultRanglisteTab.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ abstract class DefaultRanglisteTab(wettkampfmode: BooleanProperty, override val
def print(printer: Printer): Unit = {
PrintUtil.printWebContent(webView.engine, printer, PageOrientation.Portrait)
}


def resetFilterPresets(combos: Seq[ComboBox[FilterBy]], scorelistKind: ScoreListKind): Unit = {

}

def populate(groupers: List[FilterBy]): Seq[ComboBox[FilterBy]] = {
val gr1Model = ObservableBuffer.from(groupers)
val kindModel = ObservableBuffer.from(Seq[ScoreListKind](Einzelrangliste, Teamrangliste, Kombirangliste))
Expand Down Expand Up @@ -312,8 +316,11 @@ abstract class DefaultRanglisteTab(wettkampfmode: BooleanProperty, override val
refreshRangliste(buildGrouper)
}
cbKind.onAction = _ => {
if(!restoring)
if(!restoring) {
restoring = true
resetFilterPresets(combs, cbKind.value.value)
refreshRangliste(buildGrouper)
}
}

val btnPrint = PrintUtil.btnPrintFuture(text.value, getSaveAsFilenameDefault, true,
Expand Down
49 changes: 30 additions & 19 deletions src/main/scala/ch/seidel/kutu/view/RanglisteTab.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import ch.seidel.kutu.Config._
import ch.seidel.kutu.ConnectionStates
import ch.seidel.kutu.KuTuApp.handleAction
import ch.seidel.kutu.data._
import ch.seidel.kutu.domain.{Altersklasse, Durchgang, KutuService, TeamRegel, WertungView, WettkampfView, encodeFileName, isNumeric}
import ch.seidel.kutu.domain.{Altersklasse, Durchgang, KutuService, TeamRegel, WertungView, WettkampfView, encodeFileName}
import ch.seidel.kutu.renderer.PrintUtil.FilenameDefault
import scalafx.Includes.when
import scalafx.beans.binding.Bindings
import scalafx.beans.property.BooleanProperty
import scalafx.event.ActionEvent
import scalafx.scene.Node
import scalafx.scene.control.{Button, Label, TextField}
import scalafx.scene.control.{Button, ComboBox, Label, TextField}
import scalafx.scene.layout.{BorderPane, Priority, VBox}

import scala.concurrent.Await
Expand Down Expand Up @@ -221,27 +221,38 @@ class RanglisteTab(wettkampfmode: BooleanProperty, wettkampf: WettkampfView, ove
btnPublikationFreigeben)
}

override def resetFilterPresets(combos: Seq[ComboBox[FilterBy]], scoreListKind: ScoreListKind): Unit = {
val team = groupers.find(p => p.isInstanceOf[ByTeamRule] && p.groupname.startsWith("Wettkampf"))
scoreListKind match {
case Teamrangliste if team.nonEmpty =>
combos(1).selectionModel.value.select(team.get)
combos(2).selectionModel.value.clearSelection()
combos(3).selectionModel.value.clearSelection()

case _ =>
val akg = groupers.find(p => p.isInstanceOf[ByAltersklasse] && p.groupname.startsWith("Wettkampf"))
val jakg = groupers.find(p => p.isInstanceOf[ByJahrgangsAltersklasse] && p.groupname.startsWith("Wettkampf"))
if (akg.nonEmpty) {
combos(1).selectionModel.value.select(ByProgramm(programmText))
combos(2).selectionModel.value.select(akg.get)
combos(3).selectionModel.value.select(ByGeschlecht())
} else if (jakg.nonEmpty) {
combos(1).selectionModel.value.select(ByProgramm(programmText))
combos(2).selectionModel.value.select(jakg.get)
combos(3).selectionModel.value.select(ByGeschlecht())
} else {
combos(1).selectionModel.value.select(ByProgramm(programmText))
combos(2).selectionModel.value.select(ByGeschlecht())
}
}
}

override def isPopulated = {
val combos = populate(groupers)
val akg = groupers.find(p => p.isInstanceOf[ByAltersklasse] && p.groupname.startsWith("Wettkampf"))
val jakg = groupers.find(p => p.isInstanceOf[ByJahrgangsAltersklasse] && p.groupname.startsWith("Wettkampf"))
val team = groupers.find(p => p.isInstanceOf[ByTeamRule] && p.groupname.startsWith("Wettkampf"))
if (akg.nonEmpty) {
combos(1).selectionModel.value.select(ByProgramm(programmText))
combos(2).selectionModel.value.select(akg.get)
combos(3).selectionModel.value.select(ByGeschlecht())
} else if (jakg.nonEmpty) {
combos(1).selectionModel.value.select(ByProgramm(programmText))
combos(2).selectionModel.value.select(jakg.get)
combos(3).selectionModel.value.select(ByGeschlecht())
} else if (team.nonEmpty) {
combos(1).selectionModel.value.select(team.get)
} else {
combos(1).selectionModel.value.select(ByProgramm(programmText))
combos(2).selectionModel.value.select(ByGeschlecht())
}

val team = groupers.find(p => p.isInstanceOf[ByTeamRule] && p.groupname.startsWith("Wettkampf"))
val kind: ScoreListKind = if (getData.exists(_.team > 0) || team.nonEmpty) Teamrangliste else Einzelrangliste
resetFilterPresets(combos, kind)
true
}

Expand Down

0 comments on commit 79583d3

Please sign in to comment.