notebook/app/views/content/form/_groupship_fields.html.erb
2016-08-05 22:10:32 -05:00

34 lines
1.0 KiB
Plaintext

<div class="nested-fields">
<% if f.object && f.object.send(attribute) %>
<% klass = f.object.send(attribute).class %>
<div class="chip">
<%= link_to f.object.send(attribute) do %>
<span class="<%= klass.color %>-text">
<i class="material-icons left"><%= klass.icon %></i>
</span>
<%= f.object.send(attribute).name %>
<% end %>
</div>
<%= link_to_remove_association 'remove', f %>
<% else %>
<% uuid = SecureRandom.uuid %>
<% klass = parent.send(attribute.pluralize).build.class.name.downcase %>
<div class="input-field">
<%= f.label attribute %>
<%# todo scope to universe %>
<%= f.select "#{attribute}_id", current_user.send(klass.pluralize).sort_by(&:name).map { |c| [c.name, c.id] }.compact, include_blank: true %>
<%= link_to_remove_association 'remove', f %>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('select').material_select();
});
</script>
<% end %>
</div>