🖼️
KASKO Frontend Documentation
  • README
  • Getting started
    • Setting up a new webapp
    • Webapp manifest
    • Building the flow
    • Defining layouts
    • Defining computed values
    • Defining dynamic paths
  • Core concepts
    • Forms
    • Validation
      • Using existing validators
      • Adding custom validators
    • Configuration
      • Price format
      • Date format
    • Performing API calls
    • Toggling visibility of components
    • Translations
    • Rules For Robust Application
  • Guides
    • Using logical statements (JsonLogic)
    • Adding discount codes
    • Developing Custom Plugins
    • Setting required requests
    • Adding save quote for later
    • Transforming request data
    • Manifest merging strategy
    • Knockout flow
    • Local pricing logic
    • Setting up dashboard policy profile
    • Handling offers
    • Repeater
  • Snippets
    • Reset input state
  • Useful resources
    • All component descriptions
    • JsonLogic core documentation
    • Kasko.js documentation
    • Example webapp
    • Example plugins (w/ various frameworks)
Powered by GitBook
On this page
  1. Getting started

Defining dynamic paths

There are cases where there may be need for multiple similar screens where only thing that changes is some index value and the rest of the screen is the same. We can use dynamic path for this.

Usage

In flow part of manifest, inside screen object, we can define path value that feels similar to router path by seperating route sections with / and naming dynamic variables starting with $.

Example:

{
  "flow": [
    {
      "path": "agent/$index",
      "components": [...]
    }
  ]
}

In this case we will be able to navigate user to agent/1, agent/2, ... agent/other_value and user will land on this screen we defined with agent/$index.

This will also expose this route variable to jsonlogic and contents as route.params.index (index being the name of the path variable $index).

Example:

{
  "flow": [
    {
      "path": "agent/$index",
      "components": [...]
      "next": {
        "type": "jsonlogic",
        "schema": {
          "if": [
            {
              "<": [{"var": "route.params.index"}, 1]
            },
            {
              "cat": ["agent/", {"+": [{"var": "route.params.index"}, 1]}]
            },
            "summary"
          ]
        }
      }
    }
  ]
}

And in contents we can access this value like so:

"flow.agent.title","Fill out details for agent nr.{route.params.index}"

Full example:

{
  "flow": [
  {
    "path": "agent/$index",
    "components": [
      {
        "type": "form",
        "config": {
          "components": [
            {
              "type": "form-input",
              "config": {
                "field_name": {
                  "type": "jsonlogic",
                  "schema": {
                    "cat": ["data.agents.", {"var": "route.params.index"}, ".name"]
                  }
                },
                "content_key": {
                  "label": "form.agent.label",
                  "placeholder": "form.agent.placeholder"
                }
              }
            }
          ],
          "footer_components": [
            {
              "type": "form-button-next",
              "config": {
                "content_key": "flow.next"
              }
            }
          ]
        }
      }
    ],
    "next": {
      "type": "jsonlogic",
      "schema": {
        "if": [
          {
            "<": [{"var": "route.params.index"}, 1]
          },
          {
            "cat": ["agent/", {"+": [{"var": "route.params.index"}, 1]}]
          },
          "summary"
        ]
      }
    }
  }
  ]
}

Last updated 9 months ago

In this case we would also want to adjust field names for input components on this screen (also dynamically). For this we can use .

dynamic config