{
  "additionalProperties": false,
  "definitions": {
    "additionalField": {
      "additionalProperties": false,
      "properties": {
        "is_required_field": {
          "enum": [
            false
          ],
          "options": {
            "hidden": true
          },
          "type": "boolean"
        },
        "required_role_to_create": {
          "allOf": [
            {
              "title": "Required Role for setting this field on creation."
            },
            {
              "$ref": "#/definitions/allRolesFromCommentator"
            }
          ]
        }
      },
      "required": [
        "is_required_field",
        "required_role_to_create"
      ],
      "title": "Additional Field",
      "type": "object"
    },
    "allRoles": {
      "default": "reader",
      "enum": [
        "ADMIN",
        "approver",
        "editor",
        "commentator",
        "reader"
      ],
      "type": "string"
    },
    "allRolesFromCommentator": {
      "default": "commentator",
      "enum": [
        "ADMIN",
        "approver",
        "editor",
        "commentator"
      ],
      "type": "string"
    },
    "checkboxSpecificFields": {
      "additionalProperties": false,
      "properties": {
        "default_value": {
          "title": "Default Value",
          "type": "boolean"
        },
        "field_type": {
          "enum": [
            "DynamicConversationCheckbox"
          ],
          "options": {
            "hidden": true
          },
          "type": "string"
        }
      },
      "required": [
        "default_value",
        "field_type"
      ],
      "title": "Checkbox",
      "type": "object"
    },
    "dropdownSpecificFields": {
      "additionalProperties": false,
      "properties": {
        "choices": {
          "format": "table",
          "items": {
            "minLength": 1,
            "type": "string"
          },
          "minItems": 1,
          "title": "Choices for Dropdown",
          "type": "array",
          "uniqueItems": true
        },
        "default_value": {
          "oneOf": [
            {
              "minLength": 1,
              "title": "String Value",
              "type": "string"
            },
            {
              "title": "Null Value",
              "type": "null"
            }
          ],
          "title": "Default Value"
        },
        "field_type": {
          "enum": [
            "DynamicConversationDropdown"
          ],
          "options": {
            "hidden": true
          },
          "type": "string"
        }
      },
      "required": [
        "choices",
        "default_value",
        "field_type"
      ],
      "title": "Dropdown",
      "type": "object"
    },
    "dynamicConversationField": {
      "additionalProperties": false,
      "headerTemplate": "{{ i1 }} - {{ self.key }}",
      "properties": {
        "editable_by_creator": {
          "format": "checkbox",
          "propertyOrder": 14,
          "title": "Creator of conversation can edit this field independent from role",
          "type": "boolean"
        },
        "is_export_filter": {
          "format": "checkbox",
          "propertyOrder": 20,
          "title": "Offer as filter for export",
          "type": "boolean"
        },
        "is_list_filter": {
          "format": "checkbox",
          "propertyOrder": 21,
          "title": "Offer as filter in conversation list",
          "type": "boolean"
        },
        "key": {
          "minLength": 1,
          "pattern": "^[a-z_]+$",
          "propertyOrder": 1,
          "type": "string"
        },
        "name": {
          "allOf": [
            {
              "propertyOrder": 2,
              "title": "Name of Field"
            },
            {
              "$ref": "#/definitions/translatedField"
            }
          ]
        },
        "required_role_to_edit": {
          "allOf": [
            {
              "propertyOrder": 12,
              "title": "Required Role to change this field after the conversation is created."
            },
            {
              "$ref": "#/definitions/allRolesFromCommentator"
            }
          ]
        },
        "required_role_to_view": {
          "allOf": [
            {
              "propertyOrder": 10,
              "title": "Required Role to view this field"
            },
            {
              "$ref": "#/definitions/allRoles"
            }
          ]
        },
        "requirement_specific": {
          "oneOf": [
            {
              "$ref": "#/definitions/requiredField"
            },
            {
              "$ref": "#/definitions/additionalField"
            }
          ],
          "propertyOrder": 30,
          "title": "Requirement"
        },
        "tooltip_text": {
          "allOf": [
            {
              "propertyOrder": 5,
              "title": "Tooltip Text"
            },
            {
              "$ref": "#/definitions/translatedField"
            }
          ]
        },
        "tracking_specific": {
          "oneOf": [
            {
              "$ref": "#/definitions/trackedField"
            },
            {
              "$ref": "#/definitions/untrackedField"
            }
          ],
          "propertyOrder": 40,
          "title": "Tracking of this field"
        },
        "type_specific": {
          "format": "grid",
          "oneOf": [
            {
              "$ref": "#/definitions/textboxSpecificFields"
            },
            {
              "$ref": "#/definitions/dropdownSpecificFields"
            },
            {
              "$ref": "#/definitions/checkboxSpecificFields"
            }
          ],
          "propertyOrder": 7,
          "title": "Field Type"
        }
      },
      "required": [
        "editable_by_creator",
        "is_export_filter",
        "is_list_filter",
        "key",
        "name",
        "required_role_to_edit",
        "required_role_to_view",
        "requirement_specific",
        "tooltip_text",
        "tracking_specific",
        "type_specific"
      ],
      "title": "Dynamic Conversation Field",
      "type": "object"
    },
    "requiredField": {
      "additionalProperties": false,
      "properties": {
        "is_required_field": {
          "enum": [
            true
          ],
          "options": {
            "hidden": true
          },
          "type": "boolean"
        },
        "validation_error_message": {
          "allOf": [
            {
              "title": "Validation Error Message"
            },
            {
              "$ref": "#/definitions/translatedField"
            }
          ]
        }
      },
      "required": [
        "is_required_field",
        "validation_error_message"
      ],
      "title": "Required Field",
      "type": "object"
    },
    "textboxSpecificFields": {
      "additionalProperties": false,
      "properties": {
        "default_value": {
          "enum": [
            "empty",
            "clean_section",
            "redline_section"
          ],
          "title": "Default Value",
          "type": "string"
        },
        "field_type": {
          "enum": [
            "DynamicConversationTextfield"
          ],
          "options": {
            "hidden": true
          },
          "type": "string"
        },
        "height_in_lines": {
          "default": 1,
          "minimum": 1,
          "title": "Height in Lines",
          "type": "integer"
        },
        "max_length": {
          "default": 1000,
          "minimum": 1,
          "title": "Maximum length in chars",
          "type": "integer"
        },
        "static_field": {
          "default": false,
          "description": "If chosen, the default value can not be changed at all, also not at creation.",
          "format": "checkbox",
          "title": "Static Field",
          "type": "boolean"
        }
      },
      "required": [
        "default_value",
        "field_type",
        "height_in_lines",
        "max_length",
        "static_field"
      ],
      "title": "Textfield",
      "type": "object"
    },
    "trackedField": {
      "additionalProperties": false,
      "properties": {
        "is_tracked_changes": {
          "enum": [
            true
          ],
          "options": {
            "hidden": true
          },
          "type": "boolean"
        },
        "stream_change_message": {
          "description": "Can contain placeholders {actorName}, {oldValue}, {newValue}, {redline} (redline only for text field)",
          "properties": {
            "de_DE": {
              "minLength": 1,
              "pattern": "^([^\\{\\}]|\\{actorName\\}|\\{oldValue\\}|\\{newValue\\}|\\{redline\\})*$",
              "title": "German",
              "type": "string"
            },
            "en_EN": {
              "minLength": 1,
              "pattern": "^([^\\{\\}]|\\{actorName\\}|\\{oldValue\\}|\\{newValue\\}|\\{redline\\})*$",
              "title": "English",
              "type": "string"
            }
          },
          "title": "Message for the log on change",
          "type": "object"
        }
      },
      "required": [
        "is_tracked_changes",
        "stream_change_message"
      ],
      "title": "Tracked Field",
      "type": "object"
    },
    "translatedField": {
      "properties": {
        "de_DE": {
          "minLength": 1,
          "title": "German",
          "type": "string"
        },
        "en_EN": {
          "minLength": 1,
          "title": "English",
          "type": "string"
        }
      },
      "required": [
        "de_DE",
        "en_EN"
      ],
      "type": "object"
    },
    "untrackedField": {
      "additionalProperties": false,
      "properties": {
        "is_tracked_changes": {
          "enum": [
            false
          ],
          "options": {
            "hidden": true
          },
          "type": "boolean"
        }
      },
      "required": [
        "is_tracked_changes"
      ],
      "title": "Untracked Field",
      "type": "object"
    }
  },
  "headerTemplate": "Dynamic Conversation Type - {{ self.key }}",
  "properties": {
    "display_key": {
      "description": "List of field keys that determines the order in descending priority, which field is displayed in the conversation list.",
      "format": "table",
      "items": {
        "minLength": 1,
        "type": "string"
      },
      "minItems": 1,
      "propertyOrder": 15,
      "title": "Conversation List",
      "type": "array",
      "uniqueItems": true
    },
    "fields": {
      "format": "tabs",
      "items": {
        "$ref": "#/definitions/dynamicConversationField"
      },
      "propertyOrder": 12,
      "title": "Configured Fields for this Conversation",
      "type": "array"
    },
    "key": {
      "minLength": 1,
      "options": {
        "hidden": true
      },
      "propertyOrder": 7,
      "title": "Key",
      "type": "string"
    },
    "name": {
      "allOf": [
        {
          "propertyOrder": 10,
          "title": "Displayed Name of Conversation Type"
        },
        {
          "$ref": "#/definitions/translatedField"
        }
      ]
    },
    "show_resolved": {
      "default": true,
      "format": "checkbox",
      "propertyOrder": 16,
      "title": "Show Resolved Button",
      "type": "boolean"
    }
  },
  "required": [
    "display_key",
    "fields",
    "key",
    "name",
    "show_resolved"
  ],
  "type": "object"
}