title: Contacts
description: Simple contact directory with tags.
type: flex-objects

# Flex Configuration
config:
  # Administration Configuration
  admin:
    # Admin router (optional)
    router:
      path: '/contacts'

    # Admin menu (optional)
    menu:
      list:
        route: '/contacts'
        title: Contacts
        icon: fa-address-card-o
        # Authorization to collection admin
        authorize: ['admin.contacts.list', 'admin.super']
        # Priority -10 .. 10 (highest goes up)
        priority: 2

    # Admin template type / folder
    template: default

    # Permissions
    permissions:
      # Primary permissions
      admin.contacts:
        type: crudpl
        label: Contacts

    # List view
    list:
      title: name
      fields:
        published:
          field:
            type: toggle
            label: Publ
          width: 8
        last_name:
          link: edit
        first_name:
          link: edit
        email:
        website:
        tags:

    # Edit View
    edit:
      title:
        template: '{{ object.last_name ?? ''Last'' }}, {{ object.first_name ?? ''First Name'' }}'

    # Preview View
    preview:
      enabled: false
      route:
        #template: '/plugins/flex-objects/directory:contacts'

    # Data Export
    export:
      enabled: true
      method: 'jsonSerialize'
      formatter:
        class: 'Grav\Framework\File\Formatter\YamlFormatter'
      filename: 'contacts'

  # Site Configuration
  site:
    templates:
      collection:
        # Lookup for the template layout files for collections of objects
        paths:
          - 'flex/{TYPE}/collection/{LAYOUT}{EXT}'
      object:
        # Lookup for the template layout files for objects
        paths:
          - 'flex/{TYPE}/object/{LAYOUT}{EXT}'
      defaults:
        # Default template {TYPE}; overridden by filename of this blueprint if template folder exists
        type: contacts
        # Default template {LAYOUT}; can be overridden in render calls (usually Twig in templates)
        layout: default

  # Data Configuration
  data:
    # Object class to be used, allowing custom methods for the object
    object: 'Grav\Common\Flex\Types\Generic\GenericObject'
    # Collection class to be used, allowing custom methods for the collections
    collection: 'Grav\Common\Flex\Types\Generic\GenericCollection'
    # Index class to be used, works as a quick database-like lookup index
    index: 'Grav\Common\Flex\Types\Generic\GenericIndex'
    storage:
      # Storage class, use single file storage (does not support images and assets)
      class: 'Grav\Framework\Flex\Storage\SimpleStorage'
      options:
        formatter:
          # File formatter class, in this case the file is stored in markdown
          class: 'Grav\Framework\File\Formatter\JsonFormatter'
        # JSON file where all the objects will be stored
        folder: user-data://flex-objects/contacts.json
    search:
      # Search options
      options:
        contains: 1
      # Fields to be searched
      fields:
        - last_name
        - first_name
        - email

form:
  validation: loose

  fields:
    published:
      type: toggle
      label: Published
      highlight: 1
      default: 1
      options:
        1: PLUGIN_ADMIN.YES
        0: PLUGIN_ADMIN.NO
      validate:
        type: bool
        required: true

    last_name:
      type: text
      label: Last Name
      validate:
        required: true

    first_name:
      type: text
      label: First Name
      validate:
        required: true

    email:
      type: email
      label: Email Address
      validate:
        required: true

    website:
      type: url
      label: Website URL

    tags:
      type: selectize
      size: large
      label: Tags
      classes: fancy
      validate:
        type: commalist
