Current section
Files
Jump to
Current section
Files
priv/templates/mandarin.gen.html/table.html.eex
<table class="table">
<thead>
<tr>
<%= for {k, _} <- schema.attrs ++ [{:inserted_at, nil}, {:updated_at, nil}] do %> <th><%%= <%= context.basename %>_<%= schema.singular %>_sort_link(@conn, :<%= k %>, <%= k |> to_string() |> Mandarin.Naming.humanize() |> inspect() %>) %></th>
<% end %><%= for {k, _, _, _} <- schema.assocs do %> <th><%= k |> to_string() |> Mandarin.Naming.humanize() %></th>
<% end %>
<th></th>
</tr>
</thead>
<tbody>
<%%= for <%= schema.singular %> <- @<%= schema.plural %>.entries do %>
<tr>
<%= for {k, _} <- schema.attrs ++ [{:inserted_at, nil}, {:updated_at, nil}] do %> <td><%%= <%= schema.singular %>.<%= k %> %></td>
<% end %><%= for {k, _, full_module_name, _} <- schema.assocs do %><% module_alias = full_module_name |> String.split(".") |> Enum.at(-1) %> <td>
<a href="<%%= Routes.<%= context.basename %>_<%= k %>_path(@conn, :show, <%= schema.singular %>.<%= k %>.id) %>">
<%%= <%= schema.singular %>.<%= k %> && <%= module_alias %>.display(<%= schema.singular %>.<%= k %>) %>
</a>
</td>
<% end %>
<td>
<%%# Icon definitions %>
<%% show_icon = content_tag(:i, "", class: "fa fa-eye", title: "Show") %>
<%% edit_icon = content_tag(:i, "", class: "fa fa-edit", title: "Edit") %>
<%% delete_icon = content_tag(:i, "", class: "fa fa-trash", title: "Delete") %>
<%%# Links %>
<div class="pull-right">
<%%= link show_icon, to: Routes.<%= context.basename %>_<%= schema.route_helper %>_path(@conn, :show, <%= schema.singular %>) %>
<%%= link edit_icon, to: Routes.<%= context.basename %>_<%= schema.route_helper %>_path(@conn, :edit, <%= schema.singular %>) %>
<%%= link delete_icon, to: Routes.<%= context.basename %>_<%= schema.route_helper %>_path(@conn, :delete, <%= schema.singular %>, @conn.params), method: :delete, data: [confirm: "Are you sure?"], class: "text-danger" %>
</div>
</td>
</tr>
<%% end %>
</tbody>
</table>