/wiki_page_versions: add #p-global-listing, #p-page-listing ids.

Split the wiki page versions template into two partials,
_global_listing.html.erb and _page_listing.html.erb, to avoid the nested
conditionals that arise from combining these two pages into one template.

Add html IDs to distinguish between these two partials.
This commit is contained in:
evazion
2017-05-22 14:05:30 -05:00
parent 5ff4f12329
commit 9cf2c60c09
3 changed files with 98 additions and 67 deletions

View File

@@ -0,0 +1,38 @@
<div id="p-global-listing">
<table width="100%" class="striped">
<thead>
<tr>
<th>Title</th>
<th width="3%">Del</th>
<th width="5%"></th>
<% if CurrentUser.is_moderator? %>
<th width="10%">IP Address</th>
<% end %>
<th width="26%">Last edited</th>
</tr>
</thead>
<tbody>
<% @wiki_page_versions.each do |wiki_page_version| %>
<tr>
<td class="category-<%= wiki_page_version.category_name %>">
<%= link_to wiki_page_version.title, wiki_page_version_path(wiki_page_version) %>
</td>
<td><%= wiki_page_version.is_deleted? ? "Y" : "" %></td>
<td><%= link_to "wiki", wiki_page_path(wiki_page_version.wiki_page_id) %></td>
<% if CurrentUser.is_moderator? %>
<td>
<%= link_to_ip wiki_page_version.updater_ip_addr %>
</td>
<% end %>
<td>
<%= compact_time(wiki_page_version.updated_at) %>
<% if wiki_page_version.updater %>
by
<%= link_to_user wiki_page_version.updater %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>

View File

@@ -0,0 +1,56 @@
<div id="p-page-listing">
<%= form_tag(diff_wiki_page_versions_path, :method => :get) do %>
<table width="100%" class="striped">
<thead>
<tr>
<th width="3%"></th>
<th width="2%"></th>
<th width="2%"></th>
<th>Title</th>
<th width="3%">Del</th>
<th width="5%"></th>
<% if CurrentUser.is_moderator? %>
<th width="10%">IP Address</th>
<% end %>
<th width="26%">Last edited</th>
</tr>
</thead>
<tbody>
<% @wiki_page_versions.each_with_index do |wiki_page_version, i| %>
<tr>
<td>
<% if i < @wiki_page_versions.length - 1 %>
<%= link_to "diff", diff_wiki_page_versions_path(:otherpage => wiki_page_version.id, :thispage => @wiki_page_versions[i + 1].id) %>
<% else %>
diff
<% end %>
</td>
<td><%= radio_button_tag "thispage", wiki_page_version.id, (i == 1) %></td>
<td><%= radio_button_tag "otherpage", wiki_page_version.id, (i == 0) %></td>
<td class="category-<%= wiki_page_version.category_name %>">
<%= link_to wiki_page_version.title, wiki_page_version_path(wiki_page_version) %>
</td>
<td><%= wiki_page_version.is_deleted? ? "Y" : "" %></td>
<td><%= link_to "wiki", wiki_page_path(wiki_page_version.wiki_page_id) %></td>
<% if CurrentUser.is_moderator? %>
<td>
<%= link_to_ip wiki_page_version.updater_ip_addr %>
</td>
<% end %>
<td>
<%= compact_time(wiki_page_version.updated_at) %>
<% if wiki_page_version.updater %>
by
<%= link_to_user wiki_page_version.updater %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= submit_tag "Diff" %>
<% end %>
</div>

View File

@@ -5,73 +5,10 @@
<section id="content">
<h1>Wiki Pages</h1>
<%= form_tag(diff_wiki_page_versions_path, :method => :get) do %>
<table width="100%" class="striped">
<thead>
<tr>
<% if params[:search] && params[:search][:wiki_page_id] && @wiki_page_versions.length > 1 %>
<th width="3%"></th>
<th width="2%"></th>
<th width="2%"></th>
<% end %>
<th>Title</th>
<th width="3%">Del</th>
<th width="5%"></th>
<% if CurrentUser.is_moderator? %>
<th width="10%">IP Address</th>
<% end %>
<th width="26%">Last edited</th>
</tr>
</thead>
<tbody>
<% @wiki_page_versions.each_with_index do |wiki_page_version, i| %>
<tr>
<% if params[:search] && params[:search][:wiki_page_id] && @wiki_page_versions.length > 1 %>
<td>
<% if i < @wiki_page_versions.length - 1 %>
<%= link_to "diff", diff_wiki_page_versions_path(:otherpage => wiki_page_version.id, :thispage => @wiki_page_versions[i + 1].id) %>
<% else %>
diff
<% end %>
</td>
<td>
<% if i == 1 %>
<%= radio_button_tag "thispage", wiki_page_version.id, :checked => true %>
<% else %>
<%= radio_button_tag "thispage", wiki_page_version.id %>
<% end %>
</td>
<td>
<% if i == 0 %>
<%= radio_button_tag "otherpage", wiki_page_version.id, :checked => true %>
<% else %>
<%= radio_button_tag "otherpage", wiki_page_version.id %>
<% end %>
</td>
<% end %>
<td class="category-<%= wiki_page_version.category_name %>"><%= link_to wiki_page_version.title, wiki_page_version_path(wiki_page_version) %></td>
<td><%= wiki_page_version.is_deleted? ? "Y" : "" %></td>
<td><%= link_to "wiki", wiki_page_path(wiki_page_version.wiki_page_id) %></td>
<% if CurrentUser.is_moderator? %>
<td>
<%= link_to_ip wiki_page_version.updater_ip_addr %>
</td>
<% end %>
<td>
<%= compact_time(wiki_page_version.updated_at) %>
<% if wiki_page_version.updater %>
by
<%= link_to_user wiki_page_version.updater %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% if params[:search] && params[:search][:wiki_page_id] %>
<%= submit_tag "Diff" %>
<% end %>
<% if params.dig(:search, :wiki_page_id).present? %>
<%= render "page_listing" %>
<% else %>
<%= render "global_listing" %>
<% end %>
<%= numbered_paginator(@wiki_page_versions) %>