########################################################################
# Navigation collection — header and footer navigation entries
########################################################################

name: navigation
meta:
  label: { de: "Navigation", en: "Navigation" }
  muiIcon: menu
  group: structure
  viewHint:
    navigation:
      nodesField: elements
      preview:
        label: name
        secondary:
          eval: "$this.external && $this.externalUrl ? $this.externalUrl : ($this._lookup?.page ? $this._lookup.page.name + ' (' + $this._lookup.page.path + ')' : '')"
        select: [external, externalUrl, page]
      declaredTrees:
        - label: { de: "Header DE", en: "Header DE" }
          singleton:
            type: header
            language: de
          maxLevel: 2
        - label: { de: "Header EN", en: "Header EN" }
          singleton:
            type: header
            language: en
          maxLevel: 2
        - label: { de: "Footer DE", en: "Footer DE" }
          singleton:
            type: footer
            language: de
          maxLevel: 1
        - label: { de: "Footer EN", en: "Footer EN" }
          singleton:
            type: footer
            language: en
          maxLevel: 1
  preview:
    label: type
    secondary: language
    table:
      - type
      - language
  sidebar:
    - group: settings
      label: { de: "Einstellungen", en: "Settings" }

permissions:
  public:
    methods:
      get: true
  user:
    methods:
      get: true
      post: true
      put: true
      delete: true

fields:
  - name: language
    type: string
    validator:
      in: ["de", "en"]
      required: true
    meta:
      label: { de: "Sprache", en: "Language" }
      position: sidebar:settings
      widget: select
      choices:
        - id: de
          name: { de: "Deutsch", en: "German" }
        - id: en
          name: { de: "Englisch", en: "English" }
  - name: type
    type: string
    validator:
      in: ["header", "footer"]
      required: true
    meta:
      label: { de: "Typ", en: "Type" }
      helperText: { de: "header oder footer", en: "header or footer" }
      position: sidebar:settings
      widget: select
      choices:
        - id: header
          name: { de: "Header", en: "Header" }
        - id: footer
          name: { de: "Footer", en: "Footer" }
  - name: elements
    type: object[]
    meta:
      label: { de: "Elemente", en: "Elements" }
      preview: name
    subFields:
      - name: name
        type: string
        validator:
          required: true
          maxLength: 100
        meta:
          label: { de: "Bezeichnung", en: "Label" }
      - name: page
        type: string
        meta:
          label: { de: "Seite", en: "Page" }
          widget: foreignKey
          foreign:
            collection: content
            id: id
      - name: external
        type: boolean
        meta:
          label: { de: "Externer Link", en: "External Link" }
      - name: externalUrl
        type: string
        validator:
          maxLength: 1024
        meta:
          label: { de: "Externe URL", en: "External URL" }
      - name: hash
        type: string
        validator:
          pattern: ^[a-zA-Z0-9_-]+$
        meta:
          label: { de: "Anker", en: "Anchor" }
      - name: elements
        type: object[]
        meta:
          label: { de: "Unterpunkte", en: "Child Items" }
  - name: _testdata
    type: boolean
    meta:
      hide: true
