<%
  # Partial locals: `content` to ask a question about, and `field` for the field being questioned
  include_quick_reference = defined?(include_quick_reference) && !!include_quick_reference
%>

<% if defined?(field) && field.present? %>
  <ul class="hoverable collapsible white">
    <li class="<%= 'active' if defined?(expand_by_default) && !!expand_by_default %>">
      <div class="collapsible-header <%= content.class.color %> white-text">
        <i class="material-icons tooltipped" data-tooltip="Answer this randomly-generated question to have it automatically saved to your <%= content.name_field_value %> <%= content.class.name.downcase %> page.">help</i>
        <%=
          t(
            "serendipitous_questions.attributes.#{content.class.name.downcase}.#{field.label.downcase}",
            name:    content.name_field_value,
            default: "What is #{content.name_field_value}'s #{field.label.downcase}?"
          )
        %>
      </div>
      <div class="collapsible-body">
        <%= form_for content do |f| %>
          <%= hidden_field(:override, :redirect_path, value: redirect_path) if defined?(redirect_path) %>

          <%=
            render 'content/form/text_input',
              f: f,
              content: content,
              field: field
          %>

          <%= button_tag(type: 'submit', class: "js-content-question-submit waves-effect waves-light btn blue white-text right") do %>
            Save answer
          <% end %>

          <% if include_quick_reference %>
            <%= link_to content, class: 'entity-trigger sidenav-trigger orange white-text btn tooltipped', data: { target: "quick-reference-#{@content.class.name}-#{@content.id}", tooltip: "View this #{@content.class.name.downcase} without leaving this page" } do %>
              <i class="material-icons right">vertical_split</i>
              Quick-reference
            <% end %>
          <% end %>
          <% if !defined?(show_view_button) || !!show_view_button %>
            <%= link_to content, class: "btn #{content.class.color} white-text tooltipped", target: '_new', data: { tooltip: "View this #{@content.class.name.downcase} in a new tab" } do %>
              <i class="material-icons left white-text"><%= content.class.icon %></i>
              View
            <% end %>
          <% end %>
          <div style="clear: both;"></div>
        <% end %>
      </div>
    </li>
  </ul>

  <% if include_quick_reference %>
    <%= render partial: 'prompts/smart_sidebar', locals: { content: content } %>
  <% end %>

<% elsif defined?(show_empty_prompt) && show_empty_prompt %>
  <div class="row">
    <div class="col s12 m9">
      <h5>Hey! It looks like I don't have any more prompts for you right now. I'll get to work coming up with some!</h5>
      <p>In the meantime, I'll get a big boost of prompts if you create more pages I can think about! You can also check back later and I might have more prompts for your current pages.</p>
      <% new_content_types = (current_user.createable_content_types - [Universe]) %>
      <% new_content_types.each do |content_type| %>
        <%= link_to new_polymorphic_path(content_type), class: "btn #{content_type.color} black-text", style: 'margin: 14px;' do %>
          create
          <% if current_user.send(content_type.name.downcase.pluralize).any? %>
            another
          <% else %>
            <%= %w(a e i o).include?(content_type.name.downcase[0]) ? 'an' : 'a' %>
          <% end %>
          <%= content_type.name.downcase %>
        <% end %>
      <% end %>
    </div>
    <div class="col hide-on-small-only m3">
      <%= image_tag 'tristan/small.png',
        class: 'tooltipped tristan',
        data: {
          position: 'right',
          enterDelay: '500',
          tooltip: "Hey, I'm Tristan! I'm here to help you around the site!"
        } %>
    </div>
  </div>
<% end %>


<div class="clearfix"></div>