Skip to content

Commit

Permalink
Updated CodeReferences and Owner Breakdown pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
handstandsam committed Nov 28, 2024
1 parent 51e65a5 commit d8297c0
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ import com.squareup.invert.models.OwnerName
import com.squareup.invert.models.StatDataType
import com.squareup.invert.models.js.StatTotalAndMetadata
import org.jetbrains.compose.web.dom.A
import org.jetbrains.compose.web.dom.H1
import org.jetbrains.compose.web.dom.H3
import org.jetbrains.compose.web.dom.H4
import org.jetbrains.compose.web.dom.Li
import org.jetbrains.compose.web.dom.P
import org.jetbrains.compose.web.dom.Text
import org.jetbrains.compose.web.dom.Ul
import ui.BootstrapColumn
import ui.BootstrapLoadingMessageWithSpinner
import ui.BootstrapLoadingSpinner
Expand Down Expand Up @@ -127,48 +129,74 @@ fun CodeReferencesComposable(
}

val metadata by reportDataRepo.reportMetadata.collectAsState(null)
H1 {
Text(buildString {
append("Code References")
codeReferencesNavRoute.statKey?.let { statKey ->
val statInfo = statInfosOrig?.filter { it.key == codeReferencesNavRoute.statKey }?.firstOrNull()
append(" for ${statInfo?.description ?: statKey} (${codeReferencesNavRoute.statKey})")
}
})
}
H4 {
codeReferencesNavRoute.statKey?.let { statKey ->
A("#", {
onClick {
navRouteRepo.updateNavRoute(StatDetailNavRoute(statKeys = listOf(statKey)))
}
}) {
Text("View Grouped by Module")
BootstrapRow {
BootstrapColumn(8) {
H4 {
Text(buildString {
append("Code References")
codeReferencesNavRoute.statKey?.let { statKey ->
val statInfo = statInfosOrig?.filter { it.key == codeReferencesNavRoute.statKey }?.firstOrNull()
append(" for ${statInfo?.description ?: statKey} (${codeReferencesNavRoute.statKey})")
}
})
}
}
BootstrapColumn(4) {

Text(" ")
A("#", {
onClick {
navRouteRepo.updateNavRoute(
codeReferencesNavRoute.copy(
treemap = if (codeReferencesNavRoute.treemap != null) {
!codeReferencesNavRoute.treemap
} else {
true
codeReferencesNavRoute.statKey?.let { statKey ->
P {
Ul {
Li {
A("#", {
onClick {
navRouteRepo.updateNavRoute(StatDetailNavRoute(statKeys = listOf(statKey)))
}
}) {
Text("View Grouped by Module")
}
)
)
}
}) {
if (codeReferencesNavRoute.treemap == true) {
Text("Hide Treemap")
} else {
Text("Show Treemap")
}
Li {
A("#", {
onClick {
navRouteRepo.updateNavRoute(
codeReferencesNavRoute.copy(
treemap = if (codeReferencesNavRoute.treemap != null) {
!codeReferencesNavRoute.treemap
} else {
true
}
)
)
}
}) {
if (codeReferencesNavRoute.treemap == true) {
Text("Hide Treemap")
} else {
Text("Show Treemap")
}
}
}
Li {
A("#", {
onClick {
navRouteRepo.updateNavRoute(
OwnerBreakdownNavRoute(
statKey = codeReferencesNavRoute.statKey,
owner = codeReferencesNavRoute.owner,
)
)
}
}) {
Text("View Owner Breakdown")
}
}
}
}
}
}
}


if (moduleToOwnerMapFlowValue == null || metadata == null) {
BootstrapLoadingSpinner()
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import org.jetbrains.compose.web.css.px
import org.jetbrains.compose.web.dom.A
import org.jetbrains.compose.web.dom.Br
import org.jetbrains.compose.web.dom.H1
import org.jetbrains.compose.web.dom.H3
import org.jetbrains.compose.web.dom.H5
import org.jetbrains.compose.web.dom.H6
import org.jetbrains.compose.web.dom.Hr
import org.jetbrains.compose.web.dom.Li
import org.jetbrains.compose.web.dom.P
Expand All @@ -42,7 +43,6 @@ import ui.BootstrapTabPane
import ui.BootstrapTable
import kotlin.reflect.KClass


data class OwnerBreakdownNavRoute(
val owner: String?,
val statKey: StatKey?,
Expand Down Expand Up @@ -177,24 +177,47 @@ fun ByOwnerComposable(
.sortedBy { it.description }

BootstrapRow {
BootstrapColumn(6) {
H3 {
Text("Filter by Owner")
BootstrapSelectDropdown(
placeholderText = "-- All Owners --",
currentValue = ownerParamValue,
options = allOwnerNames!!.map { BootstrapSelectOption(it, it) }
) {
navRouteRepo.updateNavRoute(
navRoute.copy(
owner = it?.value
BootstrapColumn(classes = listOf("text-center")) {
H5 {
Text("Owner Breakdown")
if (!navRoute.statKey.isNullOrBlank()) {
Text(" (")
A(href = "#", {
onClick {
navRouteRepo.updateNavRoute(
navRoute.copy(
owner = null,
statKey = null,
)
)
}
}) { Text("View All") }
Text(")")
}
}
}
}
BootstrapRow {
if (navRoute.statKey?.isNotBlank() == true) {
BootstrapColumn(6) {
H6 {
Text("Filter by Owner")
BootstrapSelectDropdown(
placeholderText = "-- All Owners --",
currentValue = ownerParamValue,
options = allOwnerNames!!.map { BootstrapSelectOption(it, it) }
) {
navRouteRepo.updateNavRoute(
navRoute.copy(
owner = it?.value
)
)
)
}
}
}
}
BootstrapColumn(6) {
H3 {
H6 {
Text("Filter by Stat")
BootstrapSelectDropdown(
placeholderText = "-- All Stats --",
Expand Down Expand Up @@ -228,21 +251,23 @@ fun ByOwnerComposable(
}
.map { it.key }

if(navRoute.statKey.isNullOrBlank()){

if (navRoute.statKey.isNullOrBlank()) {
val codeReferencesByCategory = codeReferenceStatTypes.groupBy { it.category }

H3{
Text("Select a Stat to view Owner Breakdown")
}
Ul {
codeReferenceStatTypes.forEach {statMetadata ->
Li {
A("#", {
onClick {
navRouteRepo.updateNavRoute(navRoute.copy(statKey = statMetadata.key))
codeReferencesByCategory.entries.sortedBy { it.key }.forEach { (category, codeReferenceStatTypes) ->
H6 {
Text(category)
}
Ul {
codeReferenceStatTypes.forEach { statMetadata ->
Li {
A("#", {
onClick {
navRouteRepo.updateNavRoute(navRoute.copy(statKey = statMetadata.key))
}
}) {
Text(statMetadata.description + " (" + statMetadata.key + ")")
}
}) {
Text(statMetadata.description + " (" + statMetadata.key + ")")
}
}
}
Expand Down

0 comments on commit d8297c0

Please sign in to comment.