|
6 | 6 | <li>Edit Module</li> |
7 | 7 | </ul> |
8 | 8 | </nav> |
| 9 | +<!--TODO: Add better styling for alerts/notices --> |
| 10 | +<p style="color: green"><%= notice %></p> |
| 11 | +<p style="color: red"><%= alert %></p> |
9 | 12 | <section class="py-10 flex justify-center"> |
10 | 13 | <div class="flex flex-col gap-6 w-full max-w-lg"> |
11 | 14 | <div class="card card-border bg-base-100 shadow-md"> |
|
17 | 20 |
|
18 | 21 | <div class="card card-border bg-base-100 shadow-md"> |
19 | 22 | <div class="card-body"> |
20 | | - <div class="flex justify-between items-center mb-2"> |
21 | | - <h2 class="card-title text-lg">Links</h2> |
22 | | - <%= link_to "Add link", new_admin_content_module_link_path(@content_module), class: "btn btn-sm btn-primary" %> |
| 23 | + <div class="flex justify-between items-center mb-2 gap-2 flex-wrap"> |
| 24 | + <h2 class="card-title text-lg">Contents</h2> |
| 25 | + <div class="flex items-center gap-2"> |
| 26 | + <%= link_to "Add link", new_admin_content_module_link_path(@content_module), class: "btn btn-sm btn-primary" %> |
| 27 | + </div> |
23 | 28 | </div> |
24 | | - <% if @content_module.links.any? %> |
| 29 | + <% if @contents.any? %> |
25 | 30 | <table class="table"> |
26 | 31 | <thead> |
27 | 32 | <tr> |
|
31 | 36 | </tr> |
32 | 37 | </thead> |
33 | 38 | <tbody> |
34 | | - <% @content_module.links.each do |link| %> |
35 | | - <tr> |
36 | | - <td><a href="<%= safe_external_url(link.url) %>" target="_blank" class="link inline-flex items-center gap-1"><%= link.title %> ↗</a></td> |
37 | | - <td><%= link.link_type.humanize %></td> |
38 | | - <td> |
39 | | - <div class="flex gap-2"> |
40 | | - <%= link_to "Edit", edit_admin_link_path(link), class: "btn btn-xs btn-primary" %> |
41 | | - <%= button_to "Delete", admin_link_path(link), method: :delete, |
42 | | - data: { "turbo-confirm": "Delete this link?" }, |
43 | | - class: "btn btn-xs btn-error" %> |
44 | | - </div> |
45 | | - </td> |
46 | | - </tr> |
47 | | - <% end %> |
| 39 | + <%= render @contents %> |
48 | 40 | </tbody> |
49 | 41 | </table> |
50 | 42 | <% else %> |
51 | | - <p class="text-sm opacity-60">No links yet.</p> |
52 | | - <% end %> |
53 | | - </div> |
54 | | - </div> |
55 | | - |
56 | | - <div class="card card-border bg-base-100 shadow-md"> |
57 | | - <div class="card-body"> |
58 | | - <div class="flex justify-between items-center mb-2"> |
59 | | - <h2 class="card-title text-lg">Games</h2> |
60 | | - </div> |
61 | | - <% if @content_module.games.any? %> |
62 | | - <table class="table"> |
63 | | - <thead> |
64 | | - <tr> |
65 | | - <th>Title</th> |
66 | | - <th>Actions</th> <!-- TODO: Flex this to the end of the full width of the table --> |
67 | | - </tr> |
68 | | - </thead> |
69 | | - <tbody> |
70 | | - <% @content_module.games.each do |game| %> |
71 | | - <tr> |
72 | | - <td><%= game.title %></td> |
73 | | - <td> |
74 | | - <div class="flex gap-2"> |
75 | | - <%= link_to "Edit", edit_admin_game_path(game), class: "btn btn-xs btn-primary" %> <!-- TODO: Flex this to the end of the full width of the table --> |
76 | | - <%= button_to "Delete", admin_game_path(game), method: :delete, |
77 | | - data: { "turbo-confirm": "Delete this game?" }, |
78 | | - class: "btn btn-xs btn-error" %> |
79 | | - </div> |
80 | | - </td> |
81 | | - </tr> |
82 | | - <% end %> |
83 | | - </tbody> |
84 | | - </table> |
85 | | - <% else %> |
86 | | - <p class="text-sm opacity-60">No games yet.</p> |
| 43 | + <p class="text-sm opacity-60">No contents yet.</p> |
87 | 44 | <% end %> |
88 | 45 | </div> |
89 | 46 | </div> |
|
0 commit comments