All Downloads are FREE. Search and download functionalities are using the official Maven repository.

.uniform.common-web_2.12.5.0.0-RC6.source-code.PageIn.scala Maven / Gradle / Ivy

The newest version!
package ltbs.uniform
package common.web

import cats.implicits._

case class PageIn[Html](
  targetId: List[String],
  breadcrumbs: Breadcrumbs,
  request: Option[Input],
  state: DB,
  pathPrefix: List[String],
  config: JourneyConfig,
  messages: UniformMessages[Html],
  queryParams: Map[String, Seq[String]]
) {

  def toPageOut[A](
    output: AskResult[Html, A],
    stateManipulation: DB => DB = identity
  ): PageOut[Html,A] = PageOut[Html, A](
    breadcrumbs,
    stateManipulation(state),
    output,
    pathPrefix,
    config
  )

  def leapPoints: Option[(List[String], List[String])] = (
    state.get("_leap-from"::Nil).map(_.split("/").toList),
    state.get("_leap-to"::Nil).map(_.split("/").toList)
  ).tupled

  val nonReturnPoint : Option[List[String]] =
    state.get("_non-return" :: Nil).map{_.split("/").toList}

  val nonReturnPointPassed: Option[Boolean] = {
    nonReturnPoint.map(breadcrumbs.contains)
  }

  val lastStepIsNonReturn = breadcrumbs.headOption.contains(nonReturnPoint)

  val forceContinuation = nonReturnPointPassed.contains(false)
  
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy