Skip to content

Commit

Permalink
Port GroupEditBody
Browse files Browse the repository at this point in the history
  • Loading branch information
cquiroz committed Aug 16, 2024
1 parent fdca759 commit 9fa28f5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ import monocle.Lens

import scala.scalajs.js

case class GroupEditTile(
case class GroupEditBody(
group: UndoSetter[GroupTree.Group],
elementsLength: Int,
timeEstimateRange: Pot[Option[ProgramTimeRange]],
readonly: Boolean
) extends ReactFnProps(GroupEditTile.component)
) extends ReactFnProps(GroupEditBody.component)

object GroupEditTile:
private type Props = GroupEditTile
object GroupEditBody:
private type Props = GroupEditBody

private enum GroupEditType(val tag: String) derives Enumerated, Eq:
case And extends GroupEditType("And")
Expand Down Expand Up @@ -232,13 +232,21 @@ object GroupEditTile:
else <.div(ExploreStyles.GroupForm)(nameForm, minRequiredForm, plannedTime)

React.Fragment(
// props.renderInTitle(makeTitle(group, props.timeEstimateRange, props.elementsLength)),
<.div(ExploreStyles.GroupEditTile)(
selectGroupForm,
groupTypeSpecificForms
)
)

case class GroupEditTitle(
group: UndoSetter[GroupTree.Group],
elementsLength: Int,
timeEstimateRange: Pot[Option[ProgramTimeRange]]
) extends ReactFnProps(GroupEditTitle.component)

object GroupEditTitle:
private type Props = GroupEditTitle

private def makeTitle(
group: GroupTree.Group,
timeEstimateRange: Pot[Option[ProgramTimeRange]],
Expand All @@ -256,3 +264,9 @@ object GroupEditTile:
else s"Choose ${group.minimumRequired.getOrElse(1.refined[NonNegative])} of ${elementsLength}"

<.span("(", andOrStr, timeStr, ")")

val component = ScalaFnComponent
.withHooks[Props]
.useContext(AppContext.ctx)
.render: (props, _) =>
makeTitle(props.group.get, props.timeEstimateRange, props.elementsLength)
20 changes: 11 additions & 9 deletions explore/src/main/scala/explore/tabs/ObsGroupTiles.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,17 @@ object ObsGroupTiles:
s"${if group.get.isAnd then "AND" else "OR"} Group",
props.backButton.some,
tileTitleClass = ExploreStyles.GroupEditTitle
)(_ =>
GroupEditTile(
group,
node.get._1.children.length,
props.timeEstimateRange,
group.get.system
)
.withKey(props.groupId.toString)
.toUnmounted
)(
_ =>
GroupEditBody(
group,
node.get._1.children.length,
props.timeEstimateRange,
group.get.system
)
.withKey(props.groupId.toString)
.toUnmounted,
(_, _) => GroupEditTitle(group, node.get._1.children.length, props.timeEstimateRange)
)

val notesTile = Tile(
Expand Down

0 comments on commit 9fa28f5

Please sign in to comment.