app/views/cards/serendipitous/_content_question.html.erb
<%
# 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.color %> white-text">
<i class="material-icons tooltipped" data-tooltip="Answer this randomly-generated question to have it automatically saved to your <%= content.name %> <%= content.page_type.downcase %> page.">help</i>
<%=
t(
"serendipitous_questions.attributes.#{content.page_type.downcase}.#{field.label.parameterize.underscore}",
name: content.name,
default: "What is #{content.name}'s #{field.label.downcase}?"
)
%>
</div>
<div class="collapsible-body">
<%= form_for content, url: FieldTypeService.form_path_from_attribute_field(field), method: :patch do |f| %>
<%= hidden_field(:override, :redirect_path, value: redirect_path) if defined?(redirect_path) %>
<%= hidden_field_tag "entity[entity_id]", content.id %>
<%= hidden_field_tag "entity[entity_type]", content.page_type %>
<%=
render 'content/form/text_input_for_content_page',
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.view_path, class: 'entity-trigger sidenav-trigger orange white-text btn tooltipped', data: { target: "quick-reference-#{content.page_type}-#{content.id}", tooltip: "View this #{content.page_type.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.view_path, class: "btn #{content.color} white-text tooltipped", target: '_new', data: { tooltip: "View this #{content.name.downcase} in a new tab" } do %>
<i class="material-icons left white-text"><%= content.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.webp',
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>