Skip to content

Commit

Permalink
Fix for "All Components" menu being not selected by default when new …
Browse files Browse the repository at this point in the history
…subsystem is selected.
  • Loading branch information
abrighton committed Sep 8, 2020
1 parent 311ef09 commit 518a98f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 27 deletions.
26 changes: 13 additions & 13 deletions icd-web-client/src/main/scala/icd/web/client/IcdWebClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ case class IcdWebClient(csrfToken: String, inputDirSupported: Boolean) {
if (saveHistory) {
pushState(
viewType = SelectView,
maybeSourceSubsystem = selectDialog.subsystem.getSubsystemWithVersion,
maybeTargetSubsystem = selectDialog.targetSubsystem.getSubsystemWithVersion,
maybeSourceSubsystem = selectDialog.subsystem.getSubsystemWithVersion(),
maybeTargetSubsystem = selectDialog.targetSubsystem.getSubsystemWithVersion(),
maybeIcd = selectDialog.icdChooser.getSelectedIcdVersion
)
} else {
Expand Down Expand Up @@ -281,8 +281,8 @@ case class IcdWebClient(csrfToken: String, inputDirSupported: Boolean) {
*/
private object ComponentLinkSelectionHandler extends ComponentListener {
def componentSelected(link: ComponentLink): Unit = {
val maybeSv = selectDialog.subsystem.getSubsystemWithVersion
val maybeTargetSv = selectDialog.targetSubsystem.getSubsystemWithVersion
val maybeSv = selectDialog.subsystem.getSubsystemWithVersion()
val maybeTargetSv = selectDialog.targetSubsystem.getSubsystemWithVersion()
val maybeSubsystem = maybeSv.map(_.subsystem)
val maybeTargetSubsystem = maybeTargetSv.map(_.subsystem)

Expand Down Expand Up @@ -495,8 +495,8 @@ case class IcdWebClient(csrfToken: String, inputDirSupported: Boolean) {
if (saveHistory) {
pushState(
viewType = SelectView,
maybeSourceSubsystem = selectDialog.subsystem.getSubsystemWithVersion,
maybeTargetSubsystem = selectDialog.targetSubsystem.getSubsystemWithVersion,
maybeSourceSubsystem = selectDialog.subsystem.getSubsystemWithVersion(),
maybeTargetSubsystem = selectDialog.targetSubsystem.getSubsystemWithVersion(),
maybeIcd = selectDialog.icdChooser.getSelectedIcdVersion
)
}
Expand All @@ -511,8 +511,8 @@ case class IcdWebClient(csrfToken: String, inputDirSupported: Boolean) {
pushState(
replace = false,
viewType = ComponentView,
maybeSourceSubsystem = selectDialog.subsystem.getSubsystemWithVersion,
maybeTargetSubsystem = selectDialog.targetSubsystem.getSubsystemWithVersion,
maybeSourceSubsystem = selectDialog.subsystem.getSubsystemWithVersion(),
maybeTargetSubsystem = selectDialog.targetSubsystem.getSubsystemWithVersion(),
maybeIcd = selectDialog.icdChooser.getSelectedIcdVersion,
maybeUri = Some(uri)
)
Expand Down Expand Up @@ -553,10 +553,10 @@ case class IcdWebClient(csrfToken: String, inputDirSupported: Boolean) {
val maybeSv =
if (currentView == StatusView)
statusDialog.getSubsystemWithVersion
else selectDialog.subsystem.getSubsystemWithVersion
else selectDialog.subsystem.getSubsystemWithVersion()

maybeSv.foreach { sv =>
val maybeTargetSv = selectDialog.targetSubsystem.getSubsystemWithVersion
val maybeTargetSv = selectDialog.targetSubsystem.getSubsystemWithVersion()
val maybeIcdVersion = selectDialog.icdChooser.getSelectedIcdVersion.map(_.icdVersion)
val searchAll = selectDialog.searchAllSubsystems()
val clientApi = selectDialog.clientApi()
Expand All @@ -582,10 +582,10 @@ case class IcdWebClient(csrfToken: String, inputDirSupported: Boolean) {
val maybeSv =
if (currentView == StatusView)
statusDialog.getSubsystemWithVersion
else selectDialog.subsystem.getSubsystemWithVersion
else selectDialog.subsystem.getSubsystemWithVersion()

maybeSv.foreach { sv =>
val maybeTargetSv = selectDialog.targetSubsystem.getSubsystemWithVersion
val maybeTargetSv = selectDialog.targetSubsystem.getSubsystemWithVersion()
val maybeIcdVersion = selectDialog.icdChooser.getSelectedIcdVersion.map(_.icdVersion)
val uri = ClientRoutes.makeGraph(sv, maybeTargetSv, maybeIcdVersion, options)
dom.window.open(uri) // opens in new window or tab
Expand All @@ -597,7 +597,7 @@ case class IcdWebClient(csrfToken: String, inputDirSupported: Boolean) {
val maybeSv =
if (currentView == StatusView)
statusDialog.getSubsystemWithVersion
else selectDialog.subsystem.getSubsystemWithVersion
else selectDialog.subsystem.getSubsystemWithVersion()

val uri =
if (maybeSv.isDefined)
Expand Down
14 changes: 7 additions & 7 deletions icd-web-client/src/main/scala/icd/web/client/SelectDialog.scala
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ case class SelectDialog(mainContent: MainContent, listener: SelectDialogListener
}

private def clientApiCheckboxChanged()(e: dom.Event): Unit = {
val maybeTargetSv = targetSubsystem.getSubsystemWithVersion
val maybeTargetSv = targetSubsystem.getSubsystemWithVersion()
searchAllCheckbox.disabled = maybeTargetSv.isDefined || !clientApi()
}

Expand Down Expand Up @@ -134,7 +134,7 @@ case class SelectDialog(mainContent: MainContent, listener: SelectDialogListener
): Future[Unit] = {
pdfItem.setEnabled(true)
graphItem.setEnabled(true)
val maybeTargetSv = targetSubsystem.getSubsystemWithVersion
val maybeTargetSv = targetSubsystem.getSubsystemWithVersion()
targetSubsystem.setEnabled(maybeSv.isDefined)
applyButton.disabled = maybeSv.isEmpty
clientApiCheckbox.disabled = maybeTargetSv.isDefined || maybeSv.isEmpty
Expand All @@ -160,7 +160,7 @@ case class SelectDialog(mainContent: MainContent, listener: SelectDialogListener
maybeTargetSv: Option[SubsystemWithVersion],
findMatchingIcd: Boolean
): Future[Unit] = {
val maybeSv = subsystem.getSubsystemWithVersion
val maybeSv = subsystem.getSubsystemWithVersion()
clientApiCheckbox.disabled = maybeTargetSv.isDefined || maybeSv.isEmpty
searchAllCheckbox.disabled = maybeTargetSv.isDefined || maybeSv.isEmpty || !clientApi()
maybeSv
Expand All @@ -181,8 +181,8 @@ case class SelectDialog(mainContent: MainContent, listener: SelectDialogListener
// Swap source and target subsystems
private def swapSubsystems(): Unit = {
for {
sv2 <- targetSubsystem.getSubsystemWithVersion
sv1 <- subsystem.getSubsystemWithVersion
sv2 <- targetSubsystem.getSubsystemWithVersion()
sv1 <- subsystem.getSubsystemWithVersion()
} {
// XXX TODO FIXME: Use of futures...
icdChooser.selectMatchingIcd(sv2, Some(sv1))
Expand Down Expand Up @@ -218,8 +218,8 @@ case class SelectDialog(mainContent: MainContent, listener: SelectDialogListener

// Display the selected subsystems and components
def applySettings(): Future[Unit] = {
val maybeSv = subsystem.getSubsystemWithVersion
val maybeTargetSv = targetSubsystem.getSubsystemWithVersion
val maybeSv = subsystem.getSubsystemWithVersion()
val maybeTargetSv = targetSubsystem.getSubsystemWithVersion()
val maybeIcd = icdChooser.getSelectedIcdVersion
val showClientApi = clientApi() || maybeTargetSv.isDefined
val searchAll = searchAllSubsystems() && maybeTargetSv.isEmpty
Expand Down
18 changes: 11 additions & 7 deletions icd-web-client/src/main/scala/icd/web/client/Subsystem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ case class Subsystem(
// called when a subsystem is selected
private def subsystemSelected(e: dom.Event): Unit = {
for (_ <- updateSubsystemVersionOptions())
listener.subsystemSelected(getSubsystemWithVersion)
listener.subsystemSelected(getSubsystemWithVersion(subsystemOnly = true))
}

// called when a subsystem version is selected
private def subsystemVersionSelected(e: dom.Event): Unit = {
listener.subsystemSelected(getSubsystemWithVersion)
listener.subsystemSelected(getSubsystemWithVersion())
}

// HTML markup displaying the subsystem and version comboboxes
Expand Down Expand Up @@ -159,10 +159,14 @@ case class Subsystem(
}

/**
* Gets the selected subsystem with the selected version
* Gets the selected subsystem with the selected version and component.
* If subsystemOnly is true, gets only the subsystem with no version or component selected.
*/
def getSubsystemWithVersion: Option[SubsystemWithVersion] = {
getSelectedSubsystem.map(subsystem => SubsystemWithVersion(subsystem, getSelectedSubsystemVersion, getSelectedComponent))
def getSubsystemWithVersion(subsystemOnly: Boolean = false): Option[SubsystemWithVersion] = {
getSelectedSubsystem.map(subsystem =>
SubsystemWithVersion(subsystem,
if (subsystemOnly) None else getSelectedSubsystemVersion,
if (subsystemOnly) None else getSelectedComponent))
}

/**
Expand All @@ -176,7 +180,7 @@ case class Subsystem(
maybeSv: Option[SubsystemWithVersion],
findMatchingIcd: Boolean = true
): Future[Unit] = {
if (maybeSv == getSubsystemWithVersion)
if (maybeSv == getSubsystemWithVersion())
Future.successful()
else {
maybeSv match {
Expand Down Expand Up @@ -249,7 +253,7 @@ case class Subsystem(
case None =>
versionItem.value = unpublishedVersion
}
listener.subsystemSelected(getSubsystemWithVersion, findMatchingIcd = false)
listener.subsystemSelected(getSubsystemWithVersion(), findMatchingIcd = false)
}
}

Expand Down

0 comments on commit 518a98f

Please sign in to comment.