Skip to content

Commit

Permalink
fix(signatures): show EOL status when connection target is unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
updraft0 committed Jun 13, 2024
1 parent 3b58e13 commit 8ce8799
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 27 deletions.
16 changes: 7 additions & 9 deletions ui/src/main/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ mark.system-class, mark.system-online-chars {
margin-left: 2px;
margin-right: 2px;
width: 1.3em;
text-align: center;
}

.system-class-h {
Expand Down Expand Up @@ -272,15 +273,6 @@ mark.system-online-chars {

span.wormhole-connection-option {
margin: 1px 0 1px 0;

/* TODO this is a mess - use @mixin wormhole-type-cell */
}

span.wormhole-connection-option.wormhole-eol {
& :first-child {
border-top: 2px solid $pink-dark;
border-bottom: 2px solid $pink-dark;
}
}

td.signature-type {
Expand All @@ -296,6 +288,12 @@ td.signature-target {
color: $red;
text-decoration: $red-dark dotted underline;
}

& span.wormhole-eol {
/* FIXME duplication */
border-top: 2px solid $pink-dark;
border-bottom: 2px solid $pink-dark;
}
}

span.connection-system-name {
Expand Down
4 changes: 2 additions & 2 deletions ui/src/main/css/views/map-system-signature-view.css
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@
}

& tr td:not(:first-of-type) {
padding-left: 2px;
padding-left: 4px;
}

& tr td:not(:last-of-type) {
padding-left: 2px;
padding-left: 4px;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@ enum SignatureFilter derives CanEqual:
enum ConnectionTarget derives CanEqual:
def idOpt: Option[ConnectionId] =
this match
case Unknown => None
case Wormhole(id, _, _, _, _) => Some(id)
case _: Unknown => None
case w: Wormhole => Some(w.id)

case Unknown extends ConnectionTarget
case Unknown(isEol: Boolean, massStatus: WormholeMassStatus) extends ConnectionTarget
case Wormhole(
id: ConnectionId,
toSystemId: SystemId,
toSystemName: Signal[Option[String]],
toSolarSystem: SolarSystem,
connection: Signal[Option[MapWormholeConnectionWithSigs]]
isEol: Signal[Boolean],
connection: Signal[Option[MapWormholeConnectionWithSigs]],
massStatus: WormholeMassStatus
) extends ConnectionTarget

class SystemSignatureView(
Expand Down Expand Up @@ -247,22 +249,32 @@ private inline def sigView(
)
),
tbody(
mss.signatures.map(
mss.signatures.map(sig =>
signatureRow(
time,
currentFilter.signal,
settings,
selectedSigs,
actions.contramap(nss => MapAction.UpdateSignatures(solarSystem.id, false, Array(nss))),
_,
sig,
mss.connections.map { whc =>
val targetId = if (whc.fromSystemId == solarSystem.id) whc.toSystemId else whc.fromSystemId
ConnectionTarget.Wormhole(
id = whc.id,
toSystemId = targetId,
toSystemName = mapCtx.systemName(targetId),
toSolarSystem = static.solarSystemMap(targetId),
connection = mapCtx.connection(whc.id)
connection = mapCtx.connection(whc.id),
isEol = mapCtx
.connection(whc.id)
.map(
_.exists(whcs =>
whcs.toSignature.exists(_.eolAt.nonEmpty) || whcs.fromSignature.exists(_.eolAt.nonEmpty)
)
),
massStatus = sig match
case w: MapSystemSignature.Wormhole => w.massStatus
case _ => WormholeMassStatus.Unknown
)
},
solarSystem,
Expand Down Expand Up @@ -355,9 +367,15 @@ private def signatureRow(

def wormholeTargetSelect(w: MapSystemSignature.Wormhole) =
// TODO: current approach prevents filtering out connections that are already targeted - rethink
val current = Var(w.connectionId.flatMap(cId => connections.find(_.id == cId)).getOrElse(ConnectionTarget.Unknown))
val current = Var(
w.connectionId
.flatMap(cId => connections.find(_.id == cId))
.getOrElse(ConnectionTarget.Unknown(isEol = w.eolAt.isDefined, massStatus = w.massStatus))
)
val dropdown = OptionDropdown(
connections.prepended(ConnectionTarget.Unknown).toIndexedSeq,
connections
.prepended(ConnectionTarget.Unknown(isEol = w.eolAt.isDefined, massStatus = w.massStatus))
.toIndexedSeq,
current,
isDisabled = isEditingDisabled
)
Expand Down Expand Up @@ -529,19 +547,24 @@ given DropdownItem[SignatureClassified] with

given DropdownItem[ConnectionTarget] with
def key(ct: ConnectionTarget): String = ct match
case ConnectionTarget.Unknown => "unknown"
case ConnectionTarget.Wormhole(id, _, _, _, _) => id.toString
case _: ConnectionTarget.Unknown => "unknown"
case w: ConnectionTarget.Wormhole => w.id.toString
def group(ct: ConnectionTarget): Option[String] = None
def view(ct: ConnectionTarget): Element = ct match
case ConnectionTarget.Unknown => span(dataAttr("connection-type") := "Unknown", "Unknown")
case ConnectionTarget.Wormhole(id, _, toName, toSystem, connection) =>
case ConnectionTarget.Unknown(isEol, massStatus) =>
span(
dataAttr("connection-type") := "Unknown",
dataAttr("mass-status") := massStatus.toString,
cls("wormhole-eol") := isEol,
"Unknown"
)
case ConnectionTarget.Wormhole(id, _, toName, toSystem, isEol, _, massStatus) =>
// TODO: this code duplicates the wormhole rendering code in the paste signature view
span(
cls := "wormhole-connection-option",
dataAttr("connection-id") := id.toString,
cls("wormhole-eol") <-- connection.map(
_.exists(whcs => whcs.toSignature.exists(_.eolAt.nonEmpty) || whcs.fromSignature.exists(_.eolAt.nonEmpty))
),
dataAttr("mass-status") := massStatus.toString,
cls("wormhole-eol") <-- isEol,
span(
cls := "connection-system-name",
child.text <-- toName.map(_.getOrElse(toSystem.name))
Expand Down

0 comments on commit 8ce8799

Please sign in to comment.