from django.db import models

class SidebarMenuItem(models.Model):
    MENU_TYPES = [
        ("title", "Título de sección"),
        ("link", "Enlace simple"),
        ("submenu", "Submenú (con hijos)"),
    ]

    type = models.CharField(max_length=10, choices=MENU_TYPES)
    label = models.CharField(max_length=100)
    icon = models.CharField(max_length=100, blank=True, null=True)
    url = models.CharField(max_length=200, blank=True, null=True)
    badge = models.CharField(max_length=50, blank=True, null=True)
    parent = models.ForeignKey("self", null=True, blank=True, on_delete=models.CASCADE, related_name="children")
    order = models.PositiveIntegerField(default=0)
    open_in_new_tab = models.BooleanField(default=False)


    class Meta:
        ordering = ["order"]

    def __str__(self):
        return self.label
