Commit e83bd31dbd74f0518a75e5af4916827b4f9a47f5
1 parent
62c67ea6
Exists in
colab
and in
4 other branches
Refactored readingGroup show
Splited Reading listing into two partials Signed off by: Guilherme Rojas V. de Lima <guilhermehrojas@gmail.com>
Showing
3 changed files
with
21 additions
and
20 deletions
Show diff stats
... | ... | @@ -0,0 +1,14 @@ |
1 | +<tr> | |
2 | + <td><%= reading.label %></td> | |
3 | + <td><%= reading.grade %></td> | |
4 | + <td style="background-color: #<%= reading.color %>; width: 20%;"> </td> | |
5 | + <% if reading_groups_owner? @reading_group.id %> | |
6 | + <td> | |
7 | + <%= link_to 'Edit', edit_reading_group_reading_path(@reading_group.id, reading.id), class: 'btn btn-info' %> | |
8 | + </td> | |
9 | + <td> | |
10 | + <%= link_to 'Destroy', reading_group_reading_path(@reading_group.id, reading.id), method: :delete, data: { confirm: 'Are you sure that you want to destroy this reading?' }, class: 'btn btn-danger' %> | |
11 | + </td> | |
12 | + </td> | |
13 | + <% end %> | |
14 | +</tr> | |
0 | 15 | \ No newline at end of file | ... | ... |
app/views/reading_groups/show.html.erb
... | ... | @@ -25,26 +25,9 @@ |
25 | 25 | <tbody> |
26 | 26 | <% reading_group_readings = @reading_group.readings %> |
27 | 27 | <% if reading_group_readings.size == 0 %> |
28 | - <tr> | |
29 | - <% col_number = reading_groups_owner?(@reading_group.id) ? 5 : 3 %> | |
30 | - <td colspan="<%= col_number %>">There are no readings yet!</td> | |
31 | - </tr> | |
32 | - <% end %> | |
33 | - <% reading_group_readings.each do |reading| %> | |
34 | - <tr> | |
35 | - <td><%= reading.label %></td> | |
36 | - <td><%= reading.grade %></td> | |
37 | - <td style="background-color: #<%= reading.color %>; width: 20%;"> </td> | |
38 | - <% if reading_groups_owner? @reading_group.id %> | |
39 | - <td> | |
40 | - <%= link_to 'Edit', edit_reading_group_reading_path(@reading_group.id, reading.id), class: 'btn btn-info' %> | |
41 | - </td> | |
42 | - <td> | |
43 | - <%= link_to 'Destroy', reading_group_reading_path(@reading_group.id, reading.id), method: :delete, data: { confirm: 'Are you sure that you want to destroy this reading?' }, class: 'btn btn-danger' %> | |
44 | - </td> | |
45 | - </td> | |
46 | - <% end %> | |
47 | - </tr> | |
28 | + <%= render partial: 'no_readings' %> | |
29 | + <% else %> | |
30 | + <%= render partial: 'reading', collection: reading_group_readings, as: :reading %> | |
48 | 31 | <% end %> |
49 | 32 | </tbody> |
50 | 33 | </table> | ... | ... |