name: comment
meta:
  label: { de: "Kommentare", en: "Comments" }
  muiIcon: chat
  group: community
  imageUrl: "https://images.unsplash.com/photo-1522096823084-2d1aa8411c13?auto=format&fit=crop&q=80&w=800"
  preview:
    label: author
    secondary: message
    tertiary: contentId

permissions:
  public:
    methods:
      get: true
  user:
    methods:
      get: true
      post: true
      put: true
      delete: true
  "token:${ADMIN_TOKEN}":
    methods:
      "get": true
      "post": true
      "put": true
      "delete": true

hooks:
  get:
    read:
      type: javascript
      file: hooks/filter_public.js

indexes:
  - name: content_active
    key:
      - contentId
      - active
    background: true

search:
  - name: default
    mode: regex
    fields: [author, message, contentId]

fields:
  - name: active
    type: boolean
    meta:
      label: { de: "Sichtbar", en: "Visible" }
      defaultValue: true

  - name: contentId
    type: string
    validator:
      required: true
    meta:
      label: { de: "Seite (Content)", en: "Page (Content)" }
      widget: foreignKey
      foreign:
        collection: content
      protected: true

  - name: author
    type: string
    validator:
      required: true
    meta:
      label: { de: "Autor", en: "Author" }
      protected: true

  - name: message
    type: string
    validator:
      required: true
    meta:
      label: { de: "Nachricht", en: "Message" }
      widget: textarea
      protected: true
