Přeskočit obsah

Spec File Format

Entity Definition

entities:
  EntityName:
    label: "Český název"
    labelPlural: "České množné číslo"
    type: "Base|BasePlus|Event|Person|Company"
    table: "snake_case_table_name"
    iconClass: "fas fa-icon"
    color: "#hexcolor"

    fields:
      fieldName:
        type: string          # Typ pole (viz níže)
        label: string         # Český label
        required: bool        # Povinné?
        default: any          # Výchozí hodnota
        readonly: bool        # Pouze pro čtení?
        # ... další atributy dle typu

    links:
      linkName:
        type: string          # hasMany|belongsTo|hasOne|etc
        entity: string        # Cílová entita
        foreign: string       # Pole v cílové entitě
        relationName: string  # Pro many-to-many

    layouts:
      detail: list            # Layout pro detail view
      list: dict              # Layout pro list view
      filters: list           # Filtry

    indexes: list             # Databázové indexy

Příklad kompletní entity

entities:
  ServiceRequest:
    # Základní metadata
    label: "Servisní zásah"
    labelPlural: "Servisní zásahy"
    type: "Base"
    table: "service_request"
    iconClass: "fas fa-wrench"
    color: "#e74c3c"

    # Definice polí
    fields:
      number:
        type: "autoincrement"
        pattern: "SRV-{YYYY}-{0000}"
        label: "Číslo zásahu"
        required: true
        readonly: true

      account:
        type: "link"
        entity: "Account"
        label: "Organizace"
        required: true
        audited: true

      priority:
        type: "enum"
        options:
          - value: "Critical"
            label: "Kritická"
            color: "#dc3545"
          - value: "High"
            label: "Vysoká"
            color: "#fd7e14"
          - value: "Normal"
            label: "Běžná"
            color: "#0d6efd"
          - value: "Low"
            label: "Nízká"
            color: "#6c757d"
        default: "Normal"
        required: true

    # Vztahy
    links:
      account:
        type: "belongsTo"
        entity: "Account"
        foreign: "serviceRequests"

      assignedUser:
        type: "belongsTo"
        entity: "User"
        foreign: "assignedServiceRequests"

    # Databázové indexy
    indexes:
      - fields: ["accountId", "status"]
      - fields: ["assignedUserId", "status"]
      - fields: ["createdAt"]

➡️ Pokračujte na Typy polí.