Packages

This is a CMS written in Elixir. Aims to be the great open-source ecommerce and/or startup solution for those who are searching for a performance and stability on top of modern technologies like React and Elixir.

Current section

Files

Jump to
lyn web templates admin index.html.eex
Raw

web/templates/admin/index.html.eex

<h2>Listing</h2>
<table class="table table-hover table-va table-scaffold table-sm">
<thead class="thead-default">
<tr>
<%
new_direction = case @direction do
"asc" ->
"desc"
_ ->
"asc"
end
%>
<%= for {id, column} <- @model.admin_fields do %>
<%= if column.type == :integer || column.type == :string || column.type == :boolean || column.type == :datetime do %>
<th>
<%
if id == @sort do
local_direction = new_direction
else
local_direction = @direction
end
%>
<a href="<%= admin_path(@conn, :index, @resource, sort: id, direction: local_direction) %>"
class="<%= if id == @sort do %><%= if @direction == "asc" do %>down<% else %>up<% end %><% end %>">
<%= column[:label] %>
</a>
</th>
<% end %>
<% end %>
<th></th>
</tr>
</thead>
<tbody>
<%= for entry <- @entries do %>
<tr>
<%= for {id, column} <- @model.admin_fields do %>
<%= if column.type == :integer || column.type == :string || column.type == :boolean || column.type == :datetime do %>
<td><%= Map.get(entry, id, nil) %></td>
<% end %>
<% end %>
<td class="text-right nowrap">
<%= link "Edit", to: admin_path(@conn, :edit, @resource, entry), class: "btn btn-default btn-xs" %>
<%= link "Delete", to: admin_path(@conn, :delete, @resource, entry), method: :delete, data: [confirm: "Are you sure?"], class: "btn btn-danger btn-xs" %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= link "New", to: admin_path(@conn, :new, @resource) %>