move helpers to shops.ex, update controller

controller now uses helpers from shops.ex (same as live),
and no longer has edit/delete/create functionality
This commit is contained in:
2021-10-07 17:26:45 +02:00
parent 9e1118868a
commit c30f6068db
7 changed files with 84 additions and 132 deletions
@@ -1,5 +0,0 @@
<h1>Edit Clothes</h1>
<%= render "form.html", Map.put(assigns, :action, Routes.clothes_path(@conn, :update, @clothes)) %>
<span><%= link "Back", to: Routes.clothes_path(@conn, :index) %></span>
@@ -1,29 +1,32 @@
<h1>Listing Clothes</h1>
<%= for {shop, list_of_clothes} <- @clothes_map do %>
<%= for {shop, map_of_clothes_by_type} <- @clothes_map do %>
<h2> <%= shop %></h2>
<table>
<thead>
<tr>
<th>Name</th>
<th>Color</th>
<th>Game</th>
<th></th>
</tr>
</thead>
<tbody>
<%= for clothes <- list_of_clothes do %>
<tr>
<td><%= clothes.name %></td>
<td><%= clothes.color %></td>
<td><%= clothes.game %></td>
<%= for {type, map_of_clothes_by_name} <- map_of_clothes_by_type do %>
<h3> <%= type %></h3>
<table>
<thead>
<tr>
<th>Name</th>
<th>Color</th>
<th>Game</th>
<th></th>
</tr>
</thead>
<tbody>
<%= for {_name, list_of_clothes} <- map_of_clothes_by_name do %>
<%= for clothes <- list_of_clothes do %>
<tr>
<td><%= clothes.name %></td>
<td><%= clothes.color %></td>
<td><%= clothes.game %></td>
<td>
<span><%= link "Show", to: Routes.clothes_path(@conn, :show, clothes) %></span>
<span><%= link "Edit", to: Routes.clothes_path(@conn, :edit, clothes) %></span>
<span><%= link "Delete", to: Routes.clothes_path(@conn, :delete, clothes), method: :delete, data: [confirm: "Are you sure?"] %></span>
</td>
</tr>
<td>
<span><%= link "Show", to: Routes.clothes_path(@conn, :show, clothes) %></span>
</td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
<% end %>
</tbody>
</table>
<% end %>
@@ -1,5 +0,0 @@
<h1>New Clothes</h1>
<%= render "form.html", Map.put(assigns, :action, Routes.clothes_path(@conn, :create)) %>
<span><%= link "Back", to: Routes.clothes_path(@conn, :index) %></span>
@@ -7,12 +7,15 @@
<%= @clothes.name %>
</li>
<li>
<strong>Color:</strong>
<%= @clothes.color %>
</li>
<li>
<strong>Type:</strong>
<%= @clothes.type %>
</li>
<li>
<strong>Location:</strong>
@@ -25,6 +28,4 @@
</li>
</ul>
<span><%= link "Edit", to: Routes.clothes_path(@conn, :edit, @clothes) %></span>
<span><%= link "Back", to: Routes.clothes_path(@conn, :index) %></span>