{
  "$ref": {
    "calendarDataSchema": {
      "type": "object",
      "properties": {
        "_id": {
          "type": "string",
          "excludeFromSearch": true,
          "label": "ID",
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "startDate": {
          "type": "string",
          "format": "date-time",
          "excludeFromSearch": true,
          "label": {
            "it": "Inizio disponibilità",
            "en": "Availability start"
          },
          "dateOptions": {
            "displayFormat": "DD/MM/YYYY - HH:mm"
          },
          "formOptions": {
            "readOnlyOnUpdate": true
          }
        },
        "endDate": {
          "type": "string",
          "format": "date-time",
          "excludeFromSearch": true,
          "label": {
            "it": "Fine disponibilità",
            "en": "Availability end"
          },
          "dateOptions": {
            "displayFormat": "DD/MM/YYYY - HH:mm"
          },
          "formOptions": {
            "readOnly": true
          }
        },
        "slots": {
          "type": "array",
          "excludeFromSearch": true,
          "label": "Slots",
          "formOptions": {
            "hidden": true,
            "readOnly": true
          }
        },
        "slotDuration": {
          "type": "number",
          "excludeFromSearch": true,
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "doctor": {
          "type": "string",
          "excludeFromSearch": true,
          "label": "Dottore"
        },
        "title": {
          "type": "string",
          "excludeFromSearch": true,
          "label": "Titolo"
        },
        "eventType": {
          "type": "string",
          "excludeFromSearch": true,
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "resourceId": {
          "type": "number",
          "excludeFromSearch": true,
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "reason": {
          "type": "string",
          "excludeFromSearch": true,
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "creatorId": {
          "type": "string",
          "excludeFromSearch": true,
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "createdAt": {
          "type": "string",
          "excludeFromSearch": true,
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "updaterId": {
          "type": "string",
          "excludeFromSearch": true,
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "updatedAt": {
          "type": "string",
          "excludeFromSearch": true,
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "__STATE__": {
          "type": "string",
          "label": "Stato",
          "enum": ["PUBLIC", "DRAFT"],
          "visualizationOptions": {
            "iconMap": {
              "PUBLIC": {
                "shape": "roundedSquare",
                "color": "#52C41A"
              },
              "DRAFT": {
                "shape": "roundedSquare",
                "color": "#CDCDCE"
              }
            }
          },
          "formOptions": {
            "hidden": true
          }
        }
      },
      "formLinks": [],
      "required": ["startDate", "endDate"]
    },
    "availabilityDataSchema": {
      "type": "object",
      "properties": {
        "_id": {
          "type": "string",
          "excludeFromSearch": true,
          "label": "id",
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "startDate": {
          "type": "string",
          "format": "date",
          "dateOptions": {
            "displayFormat": "DD-MM-YYYY"
          },
          "excludeFromSearch": true,
          "label": {
            "it": "Inizio periodicità",
            "en": "Start Date"
          },
          "unique": false,
          "formOptions": {
            "readOnly": false
          }
        },
        "startTime": {
          "type": "string",
          "format": "time",
          "dateOptions": {
            "displayFormat": "HH:mm"
          },
          "excludeFromSearch": true,
          "label": {
            "it": "Orario di inizio",
            "en": "Start time"
          },
          "unique": false,
          "formOptions": {
            "readOnly": false
          }
        },
        "endTime": {
          "type": "string",
          "format": "time",
          "dateOptions": {
            "displayFormat": "HH:mm"
          },
          "excludeFromSearch": true,
          "label": {
            "it": "Orario di fine",
            "en": "End time"
          },
          "unique": false,
          "formOptions": {
            "readOnly": false
          }
        },
        "slotDuration": {
          "type": "number",
          "excludeFromSearch": true,
          "label": {
            "it": "Durata Slot [minuti]",
            "en": "Slot duration [minutes]"
          },
          "formOptions": {
            "hiddenOnUpdate": true
          },
          "filtersOptions": {
            "hidden": true
          },
          "min": 0
        },
        "contemporarySlots": {
          "type": "number",
          "label": {
            "it": "Slot contemporanei",
            "en": "Contemporary slots"
          },
          "unique": false,
          "formOptions": {
            "readOnly": true
          },
          "visualizationOptions": {
            "hidden": true
          }
        },
        "periodicity": {
          "type": "string",
          "enum": ["Nessuna", "Ogni giorno", "Ogni settimana", "Ogni mese"],
          "label": {
            "it": "Periodicità",
            "en": "Periodicity"
          },
          "unique": false,
          "formOptions": {
            "readOnly": false
          }
        },
        "periodicityDay": {
          "type": "array",
          "format": "multilookup",
          "label": {
            "it": "Giorni periodicità",
            "en": "Periodicity day"
          },
          "lookupOptions": {
            "lookupDataSource": "days",
            "lookupValue": "_id",
            "lookupFields": ["name"]
          },
          "unique": false,
          "formOptions": {
            "readOnly": false
          },
          "visualizationOptions": {
            "hidden": true
          }
        },
        "endDate": {
          "type": "string",
          "format": "date",
          "dateOptions": {
            "displayFormat": "DD-MM-YYYY"
          },
          "excludeFromSearch": true,
          "label": {
            "it": "Fine periodicità",
            "en": "End Date"
          },
          "unique": false,
          "formOptions": {
            "readOnly": false
          }
        },
        "description": {
          "type": "string",
          "format": "text-area",
          "label": {
            "it": "Descrizione",
            "en": "Description"
          },
          "unique": false,
          "formOptions": {
            "readOnly": false
          },
          "visualizationOptions": {
            "hidden": true
          }
        }
      },
      "formLinks": [],
      "required": [
        "site",
        "performance",
        "mode",
        "startDate",
        "startTime",
        "endTime",
        "slotDuration"
      ]
    }
  },
  "content": {
    "attributes": {
      "style": "height: calc(100vh - 64px);"
    },
    "type": "row",
    "content": [
      {
        "type": "row",
        "attributes": {
          "style": "flex-grow: 1; position:relative; bottom: 0;"
        },
        "content": [
          {
            "type": "column",
            "attributes": {
              "style": "justify-content: space-between; margin: 1vh 2vw; align-items: center;"
            },
            "content": [
              {
                "type": "column",
                "attributes": {
                  "style": "justify-content: space-between; align-items: center; width: 100%"
                },
                "content": [
                  {
                    "type": "element",
                    "tag": "bk-search-bar",
                    "properties": {
                      "searchDebounce": 1,
                      "placeholder": {
                        "en": "Search",
                        "it": "Cerca"
                      }
                    }
                  },
                  {
                    "type": "row",
                    "content": [
                      {
                        "type": "element",
                        "tag": "bk-generic-button",
                        "busDiscriminator": "newBus",
                        "attributes": {
                          "style": "margin: 0vh 1vw 0vh 0vw"
                        },
                        "properties": {
                          "content": {
                            "it": "Nuova disponibilità",
                            "en": "New availability"
                          },
                          "iconId": "PlusOutlined",
                          "clickConfig": {
                            "type": "event",
                            "actionConfig": {
                              "label": "add-new",
                              "payload": {
                                "doctorId": "{{pathnameParams.params.doctorId}}"
                              }
                            }
                          }
                        }
                      }, 
                      {
                        "type": "element",
                        "tag": "bk-filters-manager"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "row",
            "attributes": {
              "style": "background-color: #f0f2f5; padding: 1em 2em 0em 2em; flex-grow: 1; position:relative; overflow:hidden;"
            },
            "content": [
              {
                "type": "element",
                "attributes": {
                  "style": "background-color: white; padding:0 1em; border-radius: 8px; margin-bottom: 1em; display:flex; flex-direction: column; flex-grow: 1"
                },
                "tag": "am-calendar",
                "properties": {
                  "dataSchema": {
                    "$ref": "calendarDataSchema"
                  },
                  "view": "week",
                  "height": "75vh",
                  "colorProperty": "doctor",
                  "appointmentMode": false,
                  "slotConfig": {
                    "statusProperty": "status",
                    "titleProperty": ["client", "performance"],
                    "startTimeProperty": "startDate",
                    "endTimeProperty": "endDate"
                  },
                  "popoverConfig": {
                    "title": {
                      "property": "eventType",
                      "value": {
                        "AVAILABILITY": {
                          "it": "Disponibilità",
                          "en": "Availability"
                        },
                        "EXCEPTION": {
                          "it": "Eccezione",
                          "en": "Exceptions"
                        },
                        "APPOINTMENT": {
                          "it": "Appuntamento",
                          "en": "Appointment"
                        }
                      }
                    },
                    "details": [
                      {
                        "property": "slotDuration",
                        "label": {
                          "it": "Durata slot",
                          "en": "Slot duration"
                        }
                      }
                    ]
                  }
                }
              },
              {
                "type": "element",
                "tag": "bk-form-drawer",
                "busDiscriminator": "newBus",
                "properties": {
                  "allowNavigation": false,
                  "requireConfirm": true,
                  "width": "500",
                  "dataSchema": {
                    "$ref": "availabilityDataSchema"
                  },
                  "customLabels": {
                    "create": {
                      "title": {
                        "en": "New availability",
                        "it": "Nuova disponibilità"
                      },
                      "ctaLabel": {
                        "en": "Confirm",
                        "it": "Conferma"
                      }
                    },
                    "update": {
                      "title": {
                        "en": "Availability detail",
                        "it": "Dettaglio disponibilità"
                      },
                      "ctaLabel": {
                        "en": "Save",
                        "it": "Salva"
                      }
                    }
                  }
                }
              },
              {
                "type": "element",
                "tag": "bk-form-drawer",
                "properties": {
                  "allowNavigation": false,
                  "requireConfirm": true,
                  "readonlyOnView": true,
                  "width": "500",
                  "dataSchema": {
                    "$ref": "calendarDataSchema"
                  },
                  "customLabels": {
                    "update": {
                      "title": {
                        "en": "Availability detail",
                        "it": "Dettaglio disponibilità"
                      },
                      "ctaLabel": {
                        "en": "Close",
                        "it": "Chiudi"
                      }
                    }
                  }
                }
              },
              {
                "busDiscriminator": "newBus",
                "type": "element",
                "tag": "bk-confirmation-modal"
              }
            ]
          }
        ]
      },
      {
        "type": "element",
        "tag": "bk-crud-lookup-client",
        "properties": {
          "basePath": "/v2",
          "dataSchema": {
            "$ref": "availabilityDataSchema"
          }
        }
      },
      {
        "type": "element",
        "tag": "bk-crud-client",
        "properties": {
          "basePath": "/v2/availabilities",
          "dataSchema": {
            "$ref": "calendarDataSchema"
          }
        }
      }
    ]
  }
}


