Skip to content

Commit 21b658e

Browse files
committed
fix ranglistetab switch between Einzel-/Teamrangliste
- update filter-preset #984, #1027
1 parent 90a2385 commit 21b658e

File tree

2 files changed

+39
-21
lines changed

2 files changed

+39
-21
lines changed

src/main/scala/ch/seidel/kutu/view/DefaultRanglisteTab.scala

+9-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ abstract class DefaultRanglisteTab(wettkampfmode: BooleanProperty, override val
8888
def print(printer: Printer): Unit = {
8989
PrintUtil.printWebContent(webView.engine, printer, PageOrientation.Portrait)
9090
}
91-
91+
92+
def resetFilterPresets(combos: Seq[ComboBox[FilterBy]], scorelistKind: ScoreListKind): Unit = {
93+
94+
}
95+
9296
def populate(groupers: List[FilterBy]): Seq[ComboBox[FilterBy]] = {
9397
val gr1Model = ObservableBuffer.from(groupers)
9498
val kindModel = ObservableBuffer.from(Seq[ScoreListKind](Einzelrangliste, Teamrangliste, Kombirangliste))
@@ -312,8 +316,11 @@ abstract class DefaultRanglisteTab(wettkampfmode: BooleanProperty, override val
312316
refreshRangliste(buildGrouper)
313317
}
314318
cbKind.onAction = _ => {
315-
if(!restoring)
319+
if(!restoring) {
320+
restoring = true
321+
resetFilterPresets(combs, cbKind.value.value)
316322
refreshRangliste(buildGrouper)
323+
}
317324
}
318325

319326
val btnPrint = PrintUtil.btnPrintFuture(text.value, getSaveAsFilenameDefault, true,

src/main/scala/ch/seidel/kutu/view/RanglisteTab.scala

+30-19
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import ch.seidel.kutu.Config._
66
import ch.seidel.kutu.ConnectionStates
77
import ch.seidel.kutu.KuTuApp.handleAction
88
import ch.seidel.kutu.data._
9-
import ch.seidel.kutu.domain.{Altersklasse, Durchgang, KutuService, TeamRegel, WertungView, WettkampfView, encodeFileName, isNumeric}
9+
import ch.seidel.kutu.domain.{Altersklasse, Durchgang, KutuService, TeamRegel, WertungView, WettkampfView, encodeFileName}
1010
import ch.seidel.kutu.renderer.PrintUtil.FilenameDefault
1111
import scalafx.Includes.when
1212
import scalafx.beans.binding.Bindings
1313
import scalafx.beans.property.BooleanProperty
1414
import scalafx.event.ActionEvent
1515
import scalafx.scene.Node
16-
import scalafx.scene.control.{Button, Label, TextField}
16+
import scalafx.scene.control.{Button, ComboBox, Label, TextField}
1717
import scalafx.scene.layout.{BorderPane, Priority, VBox}
1818

1919
import scala.concurrent.Await
@@ -221,27 +221,38 @@ class RanglisteTab(wettkampfmode: BooleanProperty, wettkampf: WettkampfView, ove
221221
btnPublikationFreigeben)
222222
}
223223

224+
override def resetFilterPresets(combos: Seq[ComboBox[FilterBy]], scoreListKind: ScoreListKind): Unit = {
225+
scoreListKind match {
226+
case Teamrangliste =>
227+
val team = groupers.find(p => p.isInstanceOf[ByTeamRule] && p.groupname.startsWith("Wettkampf"))
228+
combos(1).selectionModel.value.select(team.get)
229+
combos(2).selectionModel.value.clearSelection()
230+
combos(3).selectionModel.value.clearSelection()
231+
232+
case _ =>
233+
val akg = groupers.find(p => p.isInstanceOf[ByAltersklasse] && p.groupname.startsWith("Wettkampf"))
234+
val jakg = groupers.find(p => p.isInstanceOf[ByJahrgangsAltersklasse] && p.groupname.startsWith("Wettkampf"))
235+
if (akg.nonEmpty) {
236+
combos(1).selectionModel.value.select(ByProgramm(programmText))
237+
combos(2).selectionModel.value.select(akg.get)
238+
combos(3).selectionModel.value.select(ByGeschlecht())
239+
} else if (jakg.nonEmpty) {
240+
combos(1).selectionModel.value.select(ByProgramm(programmText))
241+
combos(2).selectionModel.value.select(jakg.get)
242+
combos(3).selectionModel.value.select(ByGeschlecht())
243+
} else {
244+
combos(1).selectionModel.value.select(ByProgramm(programmText))
245+
combos(2).selectionModel.value.select(ByGeschlecht())
246+
}
247+
}
248+
}
224249

225250
override def isPopulated = {
226251
val combos = populate(groupers)
227-
val akg = groupers.find(p => p.isInstanceOf[ByAltersklasse] && p.groupname.startsWith("Wettkampf"))
228-
val jakg = groupers.find(p => p.isInstanceOf[ByJahrgangsAltersklasse] && p.groupname.startsWith("Wettkampf"))
229-
val team = groupers.find(p => p.isInstanceOf[ByTeamRule] && p.groupname.startsWith("Wettkampf"))
230-
if (akg.nonEmpty) {
231-
combos(1).selectionModel.value.select(ByProgramm(programmText))
232-
combos(2).selectionModel.value.select(akg.get)
233-
combos(3).selectionModel.value.select(ByGeschlecht())
234-
} else if (jakg.nonEmpty) {
235-
combos(1).selectionModel.value.select(ByProgramm(programmText))
236-
combos(2).selectionModel.value.select(jakg.get)
237-
combos(3).selectionModel.value.select(ByGeschlecht())
238-
} else if (team.nonEmpty) {
239-
combos(1).selectionModel.value.select(team.get)
240-
} else {
241-
combos(1).selectionModel.value.select(ByProgramm(programmText))
242-
combos(2).selectionModel.value.select(ByGeschlecht())
243-
}
244252

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

0 commit comments

Comments
 (0)