notebook/app/views/content/_form.html.erb

66 lines
2.9 KiB
Plaintext

<%= render 'content/form/errors', content: content %>
<div class="row">
<div class="col s12">
<div class="card hoverable">
<div class="card-content">
<div class="card-title center">
<span class="right">
<i class="material-icons red-text"><%= content.class.icon %></i>
<%= render 'content/form/actions_dropdown', content: content %>
</span>
<%= render 'content/form/title', content: content %>
</div>
<%# Tabs %>
<ul class="hoverable tabs">
<% content.class.attribute_categories.each do |category, data| %>
<li class="tab col s12">
<a href="#<%= category %>">
<i class="material-icons hide-on-med-and-down" style="font-size: 18px;"><%= data[:icon] %></i>
<%= category.to_s.humanize %>
</a>
</li>
<% end %>
</ul>
<br />
<%# Content panels %>
<% content.class.attribute_categories.each do |category, data| %>
<div id="<%= category %>" class="row">
<% data[:attributes].each do |attribute| %>
<div class="col s10 m8 l4">
<% value = content.send(attribute) %>
<% if value.is_a?(ActiveRecord::Associations::CollectionProxy) %>
<% through_class = content.class.reflect_on_association(attribute).options[:through].to_s %>
<%= render 'content/form/relation_input', f: f, attribute: attribute, relation: through_class %>
<% elsif attribute == 'universe_id' %>
<div class="input-field">
<%= f.label attribute %><br />
<%= f.select attribute, current_user.universes.sort_by(&:name).map { |u| [u.name, u.id] }.compact, include_blank: true, selected: (f.object.persisted? ? f.object.universe_id : session[:universe_id]) %>
</div>
<% elsif attribute == 'privacy' %>
<div class="input-field">
<%= f.label attribute %><br />
<%= f.select attribute, [['Only visible to you', 'private'], ['Visible to anyone with the URL', 'public']] %>
<div class="help-text">
This setting applies to this universe and everything within it. If this universe is visible to others by URL, they will be able to click through and see the
characters, locations, and items within this universe also.
</div>
</div>
<% else %>
<%= render 'content/form/text_input', f: f, attribute: attribute %>
<% end %>
</div>
<% end %>
</div>
<% end %>
</div>
<div class="card-action center">
<%= f.submit nil, class: 'btn' %>
</div>
</div>
</div>
</div>