-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_puzzles_table.html.erb
More file actions
51 lines (51 loc) · 2.31 KB
/
_puzzles_table.html.erb
File metadata and controls
51 lines (51 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<table>
<thead>
<tr>
<th>Question</th>
<th>Answer</th>
<th>Explanation</th>
<th>Link</th>
<% if actions == :archived %>
<th>Sent</th>
<% end %>
<th>Actions</th>
</tr>
</thead>
<tbody>
<% puzzles.each do |puzzle| %>
<tr id="<%= dom_id(puzzle) %>">
<td><%= simple_format(puzzle.question) %></td>
<td><%= puzzle.answer %></td>
<td><%= puzzle.explanation %></td>
<td>
<% if puzzle.link.present? %>
<%= link_to 'View', puzzle.link, target: '_blank' %>
<% end %>
</td>
<% if actions == :archived %>
<td><%= time_ago(puzzle.sent_at) %></td>
<% end %>
<td>
<% if actions == :pending %>
<%= button_to 'Approve', puzzle_state_path(puzzle, state: :approved), method: :patch, form_class: 'inline-form', class: 'btn approve-btn' %>
<%= button_to 'Reject', puzzle_state_path(puzzle, state: :rejected), method: :patch, form_class: 'inline-form', class: 'btn reject-btn' %>
<%= link_to "Edit",
edit_puzzle_path(puzzle),
data: { turbo_frame: "modal" },
class: "btn edit-btn" %>
<% elsif actions == :approved %>
<%= button_to 'Reject', puzzle_state_path(puzzle, state: :rejected), method: :patch, form_class: 'inline-form', class: 'btn reject-btn' %>
<%= button_to 'Pending', puzzle_state_path(puzzle, state: :pending), method: :patch, form_class: 'inline-form', class: 'btn pending-btn' %>
<% elsif actions == :rejected %>
<%= button_to 'Approve', puzzle_state_path(puzzle, state: :approved), method: :patch, form_class: 'inline-form', class: 'btn approve-btn' %>
<%= button_to 'Pending', puzzle_state_path(puzzle, state: :pending), method: :patch, form_class: 'inline-form', class: 'btn pending-btn' %>
<% elsif actions == :archived %>
<%= button_to 'Un-Archive', puzzle_state_path(puzzle, state: :pending), method: :patch, form_class: 'inline-form', class: 'btn pending-btn' %>
<%= button_to 'Clone', puzzle_clone_path(puzzle, state: :pending), method: :post, form_class: 'inline-form', class: 'btn pending-btn' %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>