diff --git a/icd-web-client/src/main/scala/icd/web/client/IcdWebClient.scala b/icd-web-client/src/main/scala/icd/web/client/IcdWebClient.scala index 6c817585..dc9b63a5 100644 --- a/icd-web-client/src/main/scala/icd/web/client/IcdWebClient.scala +++ b/icd-web-client/src/main/scala/icd/web/client/IcdWebClient.scala @@ -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 { @@ -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) @@ -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 ) } @@ -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) ) @@ -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() @@ -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 @@ -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) diff --git a/icd-web-client/src/main/scala/icd/web/client/SelectDialog.scala b/icd-web-client/src/main/scala/icd/web/client/SelectDialog.scala index fbe04545..76032386 100644 --- a/icd-web-client/src/main/scala/icd/web/client/SelectDialog.scala +++ b/icd-web-client/src/main/scala/icd/web/client/SelectDialog.scala @@ -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() } @@ -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 @@ -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 @@ -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)) @@ -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 diff --git a/icd-web-client/src/main/scala/icd/web/client/Subsystem.scala b/icd-web-client/src/main/scala/icd/web/client/Subsystem.scala index e2366f2d..81777f4c 100644 --- a/icd-web-client/src/main/scala/icd/web/client/Subsystem.scala +++ b/icd-web-client/src/main/scala/icd/web/client/Subsystem.scala @@ -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 @@ -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)) } /** @@ -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 { @@ -249,7 +253,7 @@ case class Subsystem( case None => versionItem.value = unpublishedVersion } - listener.subsystemSelected(getSubsystemWithVersion, findMatchingIcd = false) + listener.subsystemSelected(getSubsystemWithVersion(), findMatchingIcd = false) } }