{
  "$id": "/dcic/signature-commons-schema/v6/meta/schemas/ui-schema.json",
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "Metadata describing a signature commons ui schema",
  "allOf": [
    {
      "$ref": "/dcic/signature-commons-schema/v6/core/meta.json"
    },
    {
      "properties": {
        "match": {
          "description": "The partial rules to match a data instance `${variable}` can be used for variable substitution",
          "$ref": "/dcic/signature-commons-schema/v6/meta/schema/match.json"
        },
        "properties": {
          "description": "UI-defined properties for the given match",
          "type": "object",
          "patternProperties": {
            ".*": {
              "description": "Each property is followed by a the schema which defines what it represents",
              "allOf": [
                {
                  "type": "object",
                  "properties": {
                    "condition": {
                      "type": "object",
                      "description": "A mapping of conditions to compare",
                      "$ref": "/dcic/signature-commons-schema/v6/meta/schema/match.json"
                    },
                    "columnType": {
                      "type": "string",
                      "enum": [
                        "number"
                      ]
                    },
                    "columnOptions": {
                      "type": "object",
                      "properties": {
                        "sort": {
                          "type": "boolean"
                        },
                        "sortDirection": {
                          "type": "string",
                          "enum": ["asc", "desc"]
                        }
                      }
                    }
                  }
                }
              ],
              "oneOf": [
                {
                  "type": "object",
                  "description": "Header image",
                  "properties": {
                    "type": {
                      "description": "The field type",
                      "type": "string",
                      "enum": [ "header-img", "img" ]
                    },
                    "src": {
                      "description": "The image source url",
                      "type": "string"
                    },
                    "alt": {
                      "description": "The image alt description",
                      "type": "string"
                    }
                  },
                  "required": [
                    "src",
                    "type"
                  ]
                },
                {
                  "type": "object",
                  "description": "Title or Subtitle or alternative name",
                  "properties": {
                    "type": {
                      "description": "The field type",
                      "type": "string",
                      "enum": [ "title", "subtitle", "alternative" ]
                    },
                    "text": {
                      "description": "The text of the title",
                      "type": "string"
                    }
                  },
                  "required": [
                    "text",
                    "type"
                  ]
                },
                {
                  "type": "object",
                  "description": "Display: Non title/ subtitle display text",
                  "properties": {
                    "type": {
                      "description": "The field type",
                      "type": "string",
                      "enum": [ "display" ]
                    },
                    "text": {
                      "description": "The text of the display",
                      "type": "string"
                    },
                    "href": {
                      "description": "url of the display (optional)",
                      "type": "string"
                    },
                    "visibility": {
                      "description": "The visibility of the field (0: hidden, 1: usually visible, 2: always visible) default: 0",
                      "type": "integer"
                    },
                    "priority": {
                      "description": "The priority of the property",
                      "type": "integer"
                    }
                  },
                  "required": [
                    "text",
                    "type"
                  ]
                },
                {
                  "type": "object",
                  "description": "text chip",
                  "properties": {
                    "type": {
                      "description": "The field type",
                      "type": "string",
                      "enum": [ "text" ]
                    },
                    "text": {
                      "description": "The text of the display",
                      "type": "string"
                    },
                    "field": {
                      "description": "field to use for filtering, leave empty if not clickable",
                      "type": "string"
                    },
                    "icon": {
                      "description": "icon to use for the chip",
                      "type": "string"
                    },
                    "visibility": {
                      "description": "The visibility of the field (0: hidden, 1: usually visible, 2: always visible) default: 0",
                      "type": "integer"
                    },
                    "priority": {
                      "description": "The priority of the property",
                      "type": "integer"
                    }
                  },
                  "required": [
                    "text",
                    "type"
                  ]
                },
                {
                  "type": "object",
                  "description": "URL field",
                  "properties": {
                    "type": {
                      "description": "The field type",
                      "type": "string",
                      "enum": [ "url" ]
                    },
                    "url": {
                      "description": "The text of the display",
                      "type": "string"
                    },
                    "text": {
                      "description": "text to describe the url",
                      "type": "string"
                    },
                    "visibility": {
                      "description": "The visibility of the field (0: hidden, 1: usually visible, 2: always visible) default: 0",
                      "type": "integer"
                    },
                    "priority": {
                      "description": "The priority of the property",
                      "type": "integer"
                    }
                  },
                  "required": [
                    "text",
                    "url",
                    "type"
                  ]
                },
                {
                  "type": "object",
                  "description": "tooltip",
                  "properties": {
                    "type": {
                      "description": "The field type",
                      "type": "string",
                      "enum": [ "tooltip" ]
                    },
                    "text": {
                      "description": "The text of the display",
                      "type": "string"
                    },
                    "visibility": {
                      "description": "The visibility of the field (0: hidden, 1: usually visible, 2: always visible) default: 0",
                      "type": "integer"
                    },
                    "priority": {
                      "description": "The priority of the property",
                      "type": "integer"
                    }
                  },
                  "required": [
                    "text",
                    "type"
                  ]
                },
                {
                  "type": "object",
                  "description": "display array as multiple chips",
                  "properties": {
                    "type": {
                      "description": "The field type",
                      "type": "string",
                      "enum": [ "array" ]
                    },
                    "object": {
                      "description": "field of the object e.g. meta.Cell_Line",
                      "type": "string"
                    },
                    "text": {
                      "description": "The location of the text to use for each object in the array. Leave if it's array of strings example `${name}`",
                      "type": "string"
                    },
                    "icon": {
                      "description": "icon to use for the chip",
                      "type": "string"
                    },
                    "field": {
                      "description": "field to use for filtering, leave empty if not clickable",
                      "type": "string"
                    },
                    "visibility": {
                      "description": "The visibility of the field (0: hidden, 1: usually visible, 2: always visible) default: 0",
                      "type": "integer"
                    },
                    "priority": {
                      "description": "The priority of the property",
                      "type": "integer"
                    }
                  },
                  "required": [
                    "object",
                    "type",
                    "field"
                  ]
                },
                {
                  "type": "object",
                  "description": "component for the infocard",
                  "properties": {
                    "type": {
                      "description": "The field type",
                      "type": "string",
                      "enum": [ "component" ]
                    },
                    "component": {
                      "description": "link to the component",
                      "type": "string"
                    },
                    "text": {
                      "description": "component label",
                      "type": "string"
                    },
                    "props": {
                      "description": "props to pass to the component, format is similar to ui-schema properties",
                      "type": "object"
                    },
                    "location": {
                      "description": "location of the component wrt the infocard, type infocard if this is a replacement of infocard",
                      "type": "string",
                      "enum": ["top", "bottom", "infocard", "chip", "left", "right"]
                    },
                    "visibility": {
                      "description": "The visibility of the field (0: hidden, 1: usually visible, 2: always visible) default: 0",
                      "type": "integer"
                    },
                    "priority": {
                      "description": "The priority of the property",
                      "type": "integer"
                    }
                  },
                  "required": [
                    "type",
                    "component",
                    "location"
                  ]
                },
                {
                  "type": "object",
                  "description": "component for the metadata page",
                  "properties": {
                    "type": {
                      "description": "The field type",
                      "type": "string",
                      "enum": [ "page-component" ]
                    },
                    "component": {
                      "description": "link to the component",
                      "type": "string"
                    },
                    "props": {
                      "description": "props to pass to the component",
                      "type": "object"
                    },
                    "location": {
                      "description": "location of the component wrt the page",
                      "type": "string",
                      "enum": ["top", "bottom", "middle"]
                    }
                  },
                  "required": [
                    "type",
                    "component",
                    "location"
                  ]
                },
                {
                  "type": "object",
                  "description": "search props",
                  "properties": {
                    "type": {
                      "description": "The field type",
                      "type": "string",
                      "enum": [ "search-props" ]
                    },
                    "search_examples": {
                      "description": "search examples",
                      "type": "array",
                      "items": {
                        "type": "string",
                        "description": "items to put on search_examples"
                      }
                    },
                    "props": {
                      "description": "props to pass to chipinput",
                      "type": "object"
                    }
                  },
                  "required": [
                    "type"
                  ]
                },
                {
                  "type": "object",
                  "description": "filter options",
                  "properties": {
                    "type": {
                      "description": "The field type",
                      "type": "string",
                      "enum": [ "filter" ]
                    },
                    "field": {
                      "description": "filter field",
                      "type": "string"
                    },
                    "search_field": {
                      "description": "field used for searching. This may be different from field.",
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "field"
                  ]
                },
                {
                  "type": "object",
                  "description": "score text",
                  "properties": {
                    "type": {
                      "description": "The field type",
                      "type": "string",
                      "enum": [ "score" ]
                    },
                    "text": {
                      "description": "text to display",
                      "type": "string"
                    },
                    "field": {
                      "description": "field of the score",
                      "type": "string"
                    },
                    "icon": {
                      "description": "icon to use for the chip",
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "field"
                  ]
                }
              ]
            }
          }
        }
      },
      "required": [
        "match"
      ],
      "type": "object"
    }
  ]
}