{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "Admin Navigation",
    "name": "SideNav",
    "description": "Definition of side navigation menu items",
    "type": "object",
    "properties": {
        "SideNav": {
            "type": "object",
            "properties": {
                "structure": {
                    "type": "object",
                    "properties": {
                        "groups": {
                            "type": "object",
                            "properties": {
                                "home": {
                                    "$ref": "#/definitions/navGroup"
                                },
                                "business": {
                                    "$ref": "#/definitions/navGroup"
                                },
                                "customise": {
                                    "$ref": "#/definitions/navGroup"
                                },
                                "settings": {
                                    "$ref": "#/definitions/navGroup"
                                }
                            }
                        },
                        "availableItems": {
                            "type": "object",
                            "description": "A definition of all the navigation items that can be used in a role menu"
                        }
                    }
                },
                "showFeedbackLink": {
                    "type": "boolean",
                    "description": "Whether to show or hide the feedback link in the side navigation"
                },
                "feedbackEmail": {
                    "type": "string",
                    "description": "The email to send feedback to"
                },
                "prefillFeedbackSubject": {
                    "type": "boolean",
                    "description": "Whether to pre-populate the subject field in the email with text. The text for this can be modified using the following translation key: ADMIN_DASHBOARD.GIVE_FEEDBACK_BTN.MAIL_SUBJECT"
                }
            },
            "required": [
                "structure"
            ]
        }
    },
    "required": [
        "SideNav"
    ],
    "definitions": {
        "navForRole": {
           "type": "array",
            "description": "The ordered collection of navigation items to put in the group. The names must be one of the properties of the 'available items'",
            "items": {
                "type": "string"
            }
        },
        "navGroup": {
            "type": "object",
            "description": "Collection of navigation links grouped under a heading with an icon.",
            "properties": {
                "label": {
                    "type": "string",
                    "description": "The label to use for the title of the group. Can be a translation key or simply a string."
                },
                "iconPath": {
                    "type": "string",
                    "description": "The path to an icon to use."
                },
                "navItems": {
                    "type": "object",
                    "properties": {
                        "owner": {
                            "$ref": "#/definitions/navForRole",
                            "description": "A list of navigation items for the 'owner' role"
                        },
                        "admin": {
                            "$ref": "#/definitions/navForRole",
                            "description": "A list of navigation items for the 'admin' role"
                        },
                        "user": {
                            "$ref": "#/definitions/navForRole",
                            "description": "A list of navigation items for the 'user' role"
                        },
                        "parent": {
                            "$ref": "#/definitions/navForRole",
                            "description": "A list of navigation items for the 'parent' role"
                        },
                        "personal": {
                            "$ref": "#/definitions/navForRole",
                            "description": "A list of navigation items for the 'personal' role"
                        }
                    }
                },
                "hide": {
                    "type": [
                        "string",
                        "boolean"
                    ],
                    "description": "An expression or a boolean that when true will hide the nav group"
                }
            },
            "required": [
                "label",
                "iconPath",
                "navItems"
            ]
        },
        "navItem": {
            "type": "object",
            "properties": {
                "label": {
                    "type": "string",
                    "description": "The label to use for the navigation link."
                },
                "sref": {
                    "type": "string",
                    "description": "The ui-router state path."
                },
                "params": {
                    "type": "object",
                    "description": "Any state params that are required by the ui router state"
                },
                "hide": {
                    "type": [
                        "string",
                        "boolean"
                    ],
                    "description": "An expression or a boolean that when true will hide the nav item"
                },
                "tag": {
                    "type": "object",
                    "description": "Adds a label tag beside the nav item",
                    "properties": {
                        "label": {
                            "type": "string"
                        },
                        "variant": {
                            "type": "string",
                            "optional": true,
                            "description": "Changes the style of the tag. This value adds a modifier suffix to the CSS class name"
                        },
                        "popover": {
                            "type": "object",
                            "description": "Tags can optionally have a popover providing more information",
                            "optional": true,
                            "properties": {
                                "title": {
                                    "type": "string",
                                    "optional": true
                                },
                                "content": {
                                    "type": "string",
                                    "description": "Text to display in the popover. Accepts basic HTML for formatting"
                                },
                                "placement": {
                                    "type": "string",
                                    "optional": true,
                                    "description": "Accepts uib-popover-placement attribute values. If not set, defaults to 'auto'"
                                },
                                "trigger": {
                                    "type": "string",
                                    "optional": true,
                                    "description": "Accepts uib-popover-trigger attribute values. If not set, defaults to 'outsideClick'"
                                }
                            }
                        }
                    },
                    "required": ["label"],
                    "example": {
                        "label": "beta",
                        "variant": "red",
                        "popover": {
                            "title": "More information",
                            "content": "<p>Popover body content</p>",
                            "placement": "bottom-left",
                            "trigger": "outsideClick"
                        }
                    }

                }
            },
            "required": [
                "label",
                "sref"
            ]
        }
    }
}
