function getCurrentPage()

in src/dispatch/static/dispatch/src/forms/store.js [158:254]


function getCurrentPage(form_schema) {
  state.has_formkit_pro = hasFormkitPro
  let schema = JSON.parse(form_schema)
  let output_schema = []
  if (schema == null) {
    return output_schema
  }
  for (let item of schema) {
    let obj = {
      name: item.name,
      id: item.name,
      key: item.name,
      label: item.title,
      help: item.hint ? item.hint : null,
      if: item.if ? item.if : null,
    }
    if (item.type == "text") {
      obj = {
        $formkit: "text",
        ...obj,
      }
      output_schema.push(obj)
    }
    if (item.type == "date") {
      obj = {
        $formkit: "date",
        ...obj,
      }
      output_schema.push(obj)
    }
    if (item.type == "boolean") {
      obj = {
        $formkit: "checkbox",
        ...obj,
      }
      output_schema.push(obj)
    }
    if (item.type == "select") {
      if (item.multiple) {
        if (item.multiple == false) {
          obj = {
            $formkit: "checkbox",
            multiple: true,
            options: item.options,
            ...obj,
          }
        } else {
          if (hasFormkitPro) {
            if (item.allow_new) {
              obj = {
                $formkit: "taglist",
                allowNewValues: true,
                options: item.options,
                ...obj,
              }
            } else {
              obj = {
                $formkit: "dropdown",
                multiple: true,
                options: item.options,
                "selection-appearance": "tags",
                ...obj,
              }
            }
          } else {
            obj = {
              $formkit: "checkbox",
              multiple: true,
              options: item.options,
              ...obj,
              help: "Select all that apply by holding command (macOS) or control (PC).",
            }
          }
        }
        output_schema.push(obj)
      } else {
        if (hasFormkitPro) {
          obj = {
            $formkit: "dropdown",
            options: item.options,
            "selection-removable": true,
            ...obj,
          }
        } else {
          obj = {
            $formkit: "checkbox",
            options: item.options,
            validation: "max:1",
            ...obj,
          }
        }
        output_schema.push(obj)
      }
    }
  }
  return output_schema
}