notebook/app/views/content/form/_groupship_fields.html.erb

44 lines
1.4 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 f do %>
<i class="material-icons red-text" style="position: relative; top: 8px; left: -3px;">close</i>
<% end %>
<% else %>
<% uuid = SecureRandom.uuid %>
<% klass = parent.send(attribute.pluralize).build.class.name.downcase %>
<div class="input-field">
<%= f.label attribute, class: 'active' %>
<div class="row">
<div class="col s10">
<%= f.select "#{attribute}_id", current_user.send(klass.pluralize).in_universe(@universe_scope).sort_by(&:name).map { |c| [c.name, c.id] }.compact, include_blank: true %>
</div>
<div class="col s2">
<%= link_to_remove_association f do %>
<i class="material-icons red-text" style="position: relative; top: 10px; left: -15px;">close</i>
<% end %>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('select').material_select();
});
</script>
<% end %>
</div>