title: Banner
fields:
  -
    import: background_color
  -
    handle: banner_set_type
    field:
      options:
        text: Text
        image: Image
        donate: Donate
      type: select
      display: 'Banner type'
      localizable: true
      validate:
        - required
      placeholder: 'Select an option'
  -
    handle: donate_widget
    field:
      max_items: 1
      create: false
      collections:
        - donate_widgets
      type: entries
      display: 'Donate widget'
      localizable: true
      validate:
        - sometimes
        - required
      if:
        banner_set_type: 'equals donate'
      listable: false
  -
    handle: banner_image
    field:
      max_files: 1
      container: assets
      type: assets
      display: Image
      localizable: true
      validate:
        - required
        - sometimes
      show_set_alt: false
      if:
        banner_set_type: 'equals image'
      listable: false
  -
    handle: banner_heading
    field:
      type: text
      display: Heading
      localizable: true
      validate:
        - required
        - sometimes
      if:
        banner_set_type: 'contains_any text, image'
      listable: false
  -
    handle: banner_description
    field:
      type: textarea
      display: Description
      localizable: true
      listable: false
      if:
        banner_set_type: 'contains_any text, image'
  -
    handle: banner_primary_button
    field:
      type: toggle
      display: 'Primary button'
      localizable: true
      if:
        banner_set_type: 'contains_any text, image'
      listable: false
  -
    handle: banner_primary_button_text
    field:
      type: text
      display: 'Primary button text'
      localizable: true
      validate:
        - sometimes
        - 'required_with:banner_primary_button'
      if:
        banner_set_type: 'contains_any text, image'
        banner_primary_button: 'equals true'
      listable: false
  -
    handle: banner_primary_button_link_type
    field:
      options:
        -
          key: url
          value: URL
        -
          key: collection
          value: Page/Story
        -
          key: download
          value: Download
      placeholder: 'Please select'
      type: select
      display: 'Primary button link type'
      localizable: true
      validate:
        - required
        - sometimes
      listable: false
      sortable: false
      if:
        banner_set_type: 'contains_any text, image'
        banner_primary_button: 'equals true'
      width: 50
      searchable: false
      default: url
  -
    handle: banner_primary_button_target
    field:
      options:
        -
          key: _self
          value: 'Current tab / window'
        -
          key: _blank
          value: 'New tab / window'
      searchable: false
      default: _self
      type: select
      display: 'Primary button link target'
      localizable: true
      validate:
        - required
        - sometimes
      width: 50
      if:
        banner_set_type: 'contains_any text, image'
        banner_primary_button: 'equals true'
  -
    handle: banner_primary_button_link
    field:
      type: text
      display: 'Primary button link'
      localizable: true
      validate:
        - sometimes
        - required
      if:
        banner_set_type: 'contains_any text, image'
        banner_primary_button: 'equals true'
        banner_primary_button_link_type: 'equals url'
      listable: false
  -
    handle: banner_primary_button_download
    field:
      max_files: 1
      container: assets
      type: assets
      display: 'Primary button download'
      localizable: true
      validate:
        - sometimes
        - required
      listable: false
      sortable: false
      if:
        banner_set_type: 'contains_any text, image'
        banner_primary_button: 'equals true'
        banner_primary_button_link_type: 'equals download'
  -
    handle: banner_primary_button_page_story
    field:
      max_items: 1
      type: entries
      display: 'Primary button page/story'
      localizable: true
      validate:
        - sometimes
        - required
      listable: false
      sortable: false
      collections:
        - pages
        - stories
      if:
        banner_set_type: 'contains_any text, image'
        banner_primary_button: 'equals true'
        banner_primary_button_link_type: 'equals collection'
  -
    handle: banner_secondary_button
    field:
      type: toggle
      display: 'Secondary button'
      localizable: true
      if:
        banner_set_type: 'contains_any text, image'
      listable: false
  -
    handle: banner_secondary_button_text
    field:
      type: text
      display: 'Secondary button text'
      localizable: true
      validate:
        - sometimes
        - 'required_with:banner_secondary_button'
      if:
        banner_set_type: 'contains_any text, image'
        banner_secondary_button: 'equals true'
      listable: false
  -
    handle: banner_secondary_button_link_type
    field:
      options:
        -
          key: url
          value: URL
        -
          key: collection
          value: Page/Story
        -
          key: download
          value: Download
      placeholder: 'Please select'
      type: select
      display: 'Secondary button link type'
      localizable: true
      validate:
        - required
        - sometimes
      listable: false
      sortable: false
      if:
        banner_set_type: 'contains_any text, image'
        banner_secondary_button: 'equals true'
      width: 50
      searchable: false
      default: url
  -
    handle: banner_secondary_button_target
    field:
      options:
        -
          key: _self
          value: 'Current tab / window'
        -
          key: _blank
          value: 'New tab / window'
      searchable: false
      default: _self
      type: select
      display: 'Secondary button link target'
      localizable: true
      validate:
        - required
        - sometimes
      width: 50
      if:
        banner_set_type: 'contains_any text, image'
        banner_secondary_button: 'equals true'
  -
    handle: banner_secondary_button_link
    field:
      type: text
      display: 'Secondary button link'
      localizable: true
      validate:
        - sometimes
        - required
      if:
        banner_set_type: 'contains_any text, image'
        banner_secondary_button: 'equals true'
        banner_secondary_button_link_type: 'equals url'
      listable: false
  -
    handle: banner_secondary_button_download
    field:
      max_files: 1
      container: assets
      type: assets
      display: 'Secondary button download'
      localizable: true
      validate:
        - sometimes
        - required
      listable: false
      sortable: false
      if:
        banner_set_type: 'contains_any text, image'
        banner_secondary_button: 'equals true'
        banner_secondary_button_link_type: 'equals download'
  -
    handle: banner_secondary_button_page_story
    field:
      max_items: 1
      type: entries
      display: 'Secondary button page/story'
      localizable: true
      validate:
        - sometimes
        - required
      listable: false
      sortable: false
      collections:
        - pages
        - stories
      if:
        banner_set_type: 'contains_any text, image'
        banner_secondary_button: 'equals true'
        banner_secondary_button_link_type: 'equals collection'
  -
    handle: banner_caption
    field:
      type: toggle
      display: 'Banner image caption'
      localizable: true
      width: 33
      if:
        banner_set_type: 'equals image'
      listable: false
  -
    handle: banner_caption_text
    field:
      type: text
      display: 'Caption text'
      localizable: true
      width: 66
      validate:
        - sometimes
        - 'required_with:banner_caption'
      if:
        banner_set_type: 'equals image'
        banner_caption: 'equals true'
      listable: false
