{
  "$schema": "http://json-schema.org/draft-07/schema",
  "$id": "dynamic-tabs-schema-13.0",
  "type": "object",
  "title": "Schema for definition of steps and tabs",
  "description": "This object can contains \"tabs\" array with tabs specifications or \"steps\" array (categories) with tabs inside",
  "properties": {
    "name": {
      "type": "string",
      "title": "Just informative text to describe the configuration"
    },
    "layout": {
      "type": "string",
      "title": "DynamicTabs can have several types of layout. Default is \"stepper\" for config with steps and \"tabs\" for only tabs",
      "enum": ["auto", "stepper", "tabs", "menu", "wizard"]
    },
    "steps": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/step"
      }
    },
    "buttons": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/definitions/button"
      }
    },
    "tabs": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/tab"
      }
    },
    "parameters": {
      "type": "object",
      "properties": {
        "recordType": {
          "type": "string",
          "title": "What record types will be generated",
          "description": "If set conditionRecord system will generate Condition Records, if not set Price Records are generated by default",
          "examples": ["priceRecord", "conditionRecord"]
        },
        "recordCalculation": {
          "type": "string",
          "title": "When Condition records will be generated",
          "description": "If set scheduler system will generate Condition Records by Calculation page, if set approve Condition Records are generated by Workflow logic. if not set scheduler is default",
          "examples": ["approve", "scheduler"]
        }
      }
    }
  },
  "additionalProperties": false,
  "definitions": {
    "step": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "title": "Step unique name",
          "description": "It can be used in URL, so use URL-safe letters"
        },
        "labelTranslations": {
          "$ref": "#/definitions/labelTranslations",
          "title": "Object with custom translations with structure"
        },
        "translationKey": {
          "type": "string",
          "title": "Key used to find build-in translation for Step name",
          "description": "If such key exist, the translation will be used. Otherwise this string will show up on the screen.",
          "examples": ["common_dashboard", "My Dashboard"]
        },
        "userGroupViewDetails": {
          "type": "string",
          "title": "User group view permissions",
          "description": "List of user groups names (separated by comma), which can view the step",
          "examples": ["admins,sales_managers"]
        },
        "userGroupEdit": {
          "type": "string",
          "title": "User group edit permissions",
          "description": "List of user groups names (separated by comma), which can edit the step",
          "examples": ["admins,sales_managers"]
        },
        "disableCheck": {
          "$ref": "#/definitions/filter",
          "title": "Disable the step based on the data of the entity",
          "description": "Control for grey out the step by comparing the entity against this filter"
        },
        "hiddenCheck": {
          "$ref": "#/definitions/filter",
          "title": "Hide the step based on the data of the entity",
          "description": "Control for hiding the step by comparing the entity against this filter"
        },
        "icon": {
          "$ref": "#/definitions/icon",
          "title": "Icon name"
        },
        "tabs": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/tab"
          }
        }
      },
      "additionalProperties": false,
      "anyOf": [
        {
          "required": ["name", "translationKey"]
        },
        {
          "required": ["name", "labelTranslations"]
        }
      ]
    },
    "buttons": {
      "type": "object",
      "propertyNames": {
        "enum": [
          "addFolder",
          "addItems",
          "attachmentsButton",
          "browseItems",
          "browseRecommendedItems",
          "convertToDeal",
          "copyToClipboard",
          "creationWorkflowBack",
          "creationWorkflowSubmitAndNext",
          "deleteButton",
          "duplicateButton",
          "editButton",
          "editLabelButton",
          "emailCalculableButton",
          "exportDOCXButton",
          "exportPDFButton",
          "exportXLSXButton",
          "importExportButton",
          "importFromClipboard",
          "markAsLost",
          "recalculateButton",
          "recalculateChangesItemsButton",
          "recalculateChangesOutputsButton",
          "reconvertToDealButton",
          "revisionButton",
          "revokeButton",
          "saveButton",
          "submitButton",
          "withdrawButton",
          "cfoRecalculateButton",
          "reopenActionButton",
          "markDoneActionButton",
          "blockActionButton",
          "postponeActionButton",
          "rejectActionButton",
          "addActionButton",
          "editActionButton",
          "viewActionButton",
          "deleteActionButton",
          "downloadAttachmentsButton",
          "deleteAttachmentsButton",
          "deleteDocumentButton",
          "addDocumentButton",
          "workflowWithdrawButton",
          "workFlowAddApproverButton",
          "workflowAddWatcherButton",
          "workflowApproveButton",
          "workflowDenyButton"
        ]
      },
      "additionalProperties": {
        "$ref": "#/definitions/button"
      }
    },
    "button": {
      "anyOf": [{ "type": "boolean" }, { "$ref": "#/definitions/filter" }]
    },
    "tab": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "title": "Tab unique name",
          "description": "It can be used in URL, so use URL-safe letters"
        },
        "buttons": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/definitions/button"
          }
        },
        "labelTranslations": {
          "$ref": "#/definitions/labelTranslations",
          "title": "Object with custom translations with structure"
        },
        "translationKey": {
          "type": "string",
          "title": "Key used to find build-in translation for Tab name",
          "description": "If such key exist, the translation will be used. Otherwise this string will show up on the screen.",
          "examples": [
            "sfdc_quotes_tabs_header",
            "sfdc_quotes_tabs_items",
            "sfdc_quotes_tabs_attachments",
            "sfdc_quotes_tabs_workflow",
            "sfdc_quotes_tabs_workflowHistory",
            "sfdc_entity_tabs_messages"
          ]
        },
        "userGroupViewDetails": {
          "type": "string",
          "title": "User group view permissions",
          "description": "list of user groups which can view the tab",
          "examples": ["admins,sales_managers"]
        },
        "userGroupEdit": {
          "type": "string",
          "title": "User group edit permissions",
          "description": "list of user groups which can edit the tab",
          "examples": ["admins,sales_managers"]
        },
        "icon": {
          "$ref": "#/definitions/icon",
          "title": "Icon name"
        },
        "type": {
          "type": "string",
          "title": "Component specifier",
          "description": "Name of the widget you would like to see on the tab. In case of dashboard, if you can specify the dashboard name via typeReference attribute.",
          "enum": [
            "header",
            "items",
            "other-items",
            "attachments",
            "actions",
            "notes",
            "customForms",
            "workflow",
            "workflowHistory",
            "messages",
            "records",
            "dashboard",
            "details",
            "documents",
            "configurationWizards",
            "visualConfiguration",
            "externalApp"
          ]
        },
        "typeReference": {
          "type": "string",
          "title": "Unique identifier for dashboard or logic.",
          "description": "The value here depends on the widget used on the Tab."
        },
        "disableCheck": {
          "$ref": "#/definitions/filter",
          "title": "Disable the tab based on the data of the entity",
          "description": "Control for grey out the tab by comparing the entity against this filter"
        },
        "hiddenCheck": {
          "$ref": "#/definitions/filter",
          "title": "Hide the tab based on the data of the entity",
          "description": "Control for hiding the tab by comparing the entity against this filter"
        },
        "parameters": {
          "type": "object",
          "title": "Static parameters for the tab.",
          "description": "Will be passed to the tab logic (e.g. dashboard) without any changes. They can be extracted by DynamicTabs.getParameters(tab, entity) in TabComponent",
          "properties": {
            "hideSiderPanel": {
              "type": "boolean"
            },
            "flexibleLayout": {
              "type": "boolean"
            },
            "siderAlwaysWithTabs": {
              "type": "boolean"
            },
            "addFolderField": {
              "type": "string"
            },
            "addFolderTitle": {
              "type": "string"
            },
            "addFolderInside": {
              "type": "string"
            },
            "addToNewFolderTitle": {
              "type": "string"
            },
            "moveToFolderTitleSingle": {
              "type": "string"
            },
            "moveToFolderTitleMultiple": {
              "type": "string"
            },
            "showOutputsAfterRecalculation": {
              "type": "boolean"
            },
            "expandSiderAfterRecalculation": {
              "type": "boolean"
            }
          },
          "examples": [
            {
              "months": 3
            }
          ]
        },
        "parameterMapping": {
          "type": "object",
          "additionalProperties": {
            "type": "string",
            "title": "Dynamic parameters for the tab",
            "description": "Will be passed to the logic. Values will be obtained from the entity. Key value mapping of the entity fields to the dashboard logic inputs. The key is name of parameter for tab logic. The value is path to value in underlying entity."
          },
          "examples": [
            {
              "Customer": "customerId",
              "Year": "inputs.Year.value",
              "multiplier": "inputs.5.value"
            }
          ]
        }
      },
      "additionalProperties": false,
      "anyOf": [
        {
          "required": ["name", "translationKey", "type"]
        },
        {
          "required": ["name", "labelTranslations", "type"]
        }
      ]
    },
    "filter": {
      "title": "Filter can be a rule or a group of rules with a combining operator",
      "oneOf": [
        {
          "$ref": "#/definitions/group"
        },
        {
          "$ref": "#/definitions/rule"
        }
      ],
      "examples": [
        {
          "fieldName": "status",
          "operator": "equals",
          "value": "DRAFT"
        },
        {
          "criteria": [
            {
              "fieldName": "status",
              "operator": "equals",
              "value": "DRAFT"
            },
            {
              "fieldName": "status",
              "operator": "equals",
              "value": "SUBMITTED"
            }
          ],
          "operator": "or"
        }
      ]
    },
    "group": {
      "type": "object",
      "title": "Filter Group for hiding or disabling steps or tabs",
      "properties": {
        "criteria": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/filter"
          }
        },
        "operator": {
          "type": "string",
          "enum": ["and", "or", "not"]
        },
        "_constructor": {
          "type": "string",
          "enum": ["AdvancedCriteria"]
        }
      },
      "additionalProperties": false,
      "required": ["criteria", "operator"],
      "examples": [
        {
          "criteria": [
            {
              "fieldName": "status",
              "operator": "equals",
              "value": "DRAFT"
            },
            {
              "fieldName": "status",
              "operator": "equals",
              "value": "SUBMITTED"
            }
          ],
          "operator": "or"
        }
      ]
    },
    "rule": {
      "type": "object",
      "title": "Filter rule with actual condition",
      "properties": {
        "fieldName": {
          "type": "string",
          "title": "Entity property to check"
        },
        "operator": {
          "type": "string",
          "title": "Operator for comparing",
          "enum": [
            "equals",
            "notEqual",
            "iEquals",
            "iNotEqual",
            "greaterThan",
            "greaterOrEqual",
            "lessThan",
            "lessOrEqual",
            "isNull",
            "notNull",
            "between",
            "iBetween",
            "betweenInclusive",
            "iBetweenInclusive",
            "inSet",
            "notInSet",
            "contains",
            "notContains",
            "iContains",
            "iNotContains",
            "containsPattern",
            "iContainsPattern",
            "startsWith",
            "notStartsWith",
            "iStartsWith",
            "iNotStartsWith",
            "endsWith",
            "notEndsWith",
            "iEndsWith",
            "iNotEndsWith",
            "groupIncludes"
          ]
        },
        "value": true,
        "start": true,
        "end": true,
        "_constructor": {
          "type": "string",
          "enum": ["AdvancedCriteria"]
        }
      },
      "additionalProperties": false,
      "required": ["fieldName", "operator"],
      "examples": [
        {
          "fieldName": "status",
          "operator": "equals",
          "value": "DRAFT"
        }
      ]
    },
    "labelTranslations": {
      "type": "object",
      "title": "Object with custom translations with structure",
      "description": "It tries to pick label according your language, otherwise it pick label from \"\" key. After that translationKey is used.",
      "examples": [
        {
          "": "default label",
          "en": "English label",
          "fr": "French label"
        }
      ],
      "additionalProperties": {
        "type": "string"
      },
      "required": [""]
    },
    "icon": {
      "type": "string",
      "title": "Icon name",
      "description": "The icon is provided by DynamicIcon component, so the icon has to be defined there",
      "enum": [
        "angle-double-left",
        "angle-down",
        "angle-down-b",
        "angle-left-b",
        "angle-right",
        "angle-right-b",
        "arrow-down",
        "arrow-left",
        "arrow-right",
        "arrow-up",
        "bars",
        "bell",
        "blue",
        "brackets-curly",
        "browser",
        "calculator",
        "calculator-alt",
        "calendar-alt",
        "calender",
        "chart-growth",
        "chart-line",
        "check",
        "check-circle",
        "check-circle-solid",
        "circle",
        "clipboard-notes",
        "code-branch",
        "cog",
        "comment-alt-message",
        "comparison",
        "compress-arrows",
        "constructor",
        "copy",
        "corner-up-left",
        "corner-up-right",
        "critical",
        "crosshair",
        "crosshairs",
        "dashboard",
        "database",
        "download-alt",
        "ellipsis-h",
        "english-to-chinese",
        "enter",
        "equal-circle",
        "exclamation-circle",
        "exclamation-circle-solid",
        "exclamation-octagon",
        "exclamation-octagon-solid",
        "exclamation-triangle",
        "exclamation-triangle-solid",
        "expand-alt",
        "exposure-increase",
        "external-link-alt",
        "eye",
        "file",
        "file-check-alt",
        "file-copy-alt",
        "file-edit-alt",
        "file-info-alt",
        "file-plus-alt",
        "filter",
        "focus",
        "folder",
        "folder-medical",
        "folder-open",
        "fullscreen-exit",
        "gray",
        "green",
        "grip-horizontal-line",
        "import",
        "info-circle",
        "info-circle-solid",
        "key",
        "layer-group",
        "layer-group-slash",
        "link-broken",
        "link-h",
        "lock",
        "message",
        "minus",
        "minus-circle",
        "minus-square",
        "multiply",
        "notes",
        "pause",
        "pen",
        "percentage",
        "play",
        "plus",
        "plus-circle",
        "plus-square",
        "process",
        "puzzle-piece",
        "question",
        "question-circle",
        "red",
        "redo",
        "retweet",
        "save",
        "search",
        "search-minus",
        "server-connection",
        "setting",
        "sliders-v-alt",
        "sort-amount-down",
        "sort-amount-up",
        "sync",
        "thumbs-down",
        "thumbs-down-solid",
        "thumbs-up",
        "thumbs-up-solid",
        "times",
        "times-circle",
        "times-circle-solid",
        "trash-alt",
        "unlock",
        "upload",
        "upload-alt",
        "user",
        "wrench",
        "x-add",
        "yellow"
      ]
    }
  },
  "required": ["name"],
  "oneOf": [
    {
      "required": ["steps"],
      "properties": {
        "tabs": false
      }
    },
    {
      "required": ["tabs"],
      "properties": {
        "steps": false
      }
    }
  ]
}
