/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:
38
app/views/wiki_page_versions/_global_listing.html.erb
Normal file
38
app/views/wiki_page_versions/_global_listing.html.erb
Normal 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>
|
||||||
56
app/views/wiki_page_versions/_page_listing.html.erb
Normal file
56
app/views/wiki_page_versions/_page_listing.html.erb
Normal 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>
|
||||||
@@ -5,73 +5,10 @@
|
|||||||
<section id="content">
|
<section id="content">
|
||||||
<h1>Wiki Pages</h1>
|
<h1>Wiki Pages</h1>
|
||||||
|
|
||||||
<%= form_tag(diff_wiki_page_versions_path, :method => :get) do %>
|
<% if params.dig(:search, :wiki_page_id).present? %>
|
||||||
<table width="100%" class="striped">
|
<%= render "page_listing" %>
|
||||||
<thead>
|
<% else %>
|
||||||
<tr>
|
<%= render "global_listing" %>
|
||||||
<% 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 %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= numbered_paginator(@wiki_page_versions) %>
|
<%= numbered_paginator(@wiki_page_versions) %>
|
||||||
|
|||||||
Reference in New Issue
Block a user