/wiki_page_versions: merge page and global listings.

This commit is contained in:
evazion
2020-01-12 15:48:28 -06:00
parent 90b94adee8
commit ed5caba71c
4 changed files with 20 additions and 43 deletions

View File

@@ -1,4 +1,8 @@
module WikiPageVersionsHelper
def wiki_page_versions_listing_type
params.dig(:search, :wiki_page_id).present? ? :page : :global
end
def wiki_page_version_status_diff(wiki_page_version)
cur = wiki_page_version
prev = wiki_page_version.previous

View File

@@ -1,25 +0,0 @@
<div id="p-global-listing">
<%= table_for @wiki_page_versions, width: "100%" do |t| %>
<% t.column width: "3%" do |wiki_page_version| %>
<%= link_to_if wiki_page_version.previous.present?, "diff", diff_wiki_page_versions_path(otherpage: wiki_page_version.previous.try(:id), thispage: wiki_page_version.id) %>
<% end %>
<% t.column "Title" do |wiki_page_version| %>
<span class="category-<%= wiki_page_version.category_name %>">
<%= link_to "?", wiki_page_path(wiki_page_version.wiki_page_id) %>
<%= link_to wiki_page_version.title, wiki_page_version %>
<%= link_to "»", wiki_page_versions_path(search: { wiki_page_id: wiki_page_version.wiki_page_id }) %>
</span>
<% end %>
<% t.column "Status", {width: "5%"} do |wiki_page_version| %>
<%= wiki_page_version_status_diff(wiki_page_version) %>
<% end %>
<% t.column "Last edited", {width: "26%"} do |wiki_page_version| %>
<%= compact_time(wiki_page_version.updated_at) %>
by
<%= link_to_user wiki_page_version.updater %>
<%= link_to "»", wiki_page_versions_path(search: { updater_id: wiki_page_version.updater.id }) %>
<% end %>
<% end %>
</div>

View File

@@ -1,24 +1,24 @@
<div id="p-page-listing">
<div id="p-<%= wiki_page_versions_listing_type %>-listing">
<%= form_tag(diff_wiki_page_versions_path, :method => :get) do %>
<%= table_for @wiki_page_versions, width: "100%" do |t| %>
<% t.column width: "3%" do |wiki_page_version, i| %>
<% 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
<%= link_to_if wiki_page_version.previous.present?, "diff", diff_wiki_page_versions_path(otherpage: wiki_page_version.previous.try(:id), thispage: wiki_page_version.id) %>
<% end %>
<% if wiki_page_versions_listing_type == :page %>
<% t.column width: "2%" do |wiki_page_version, i| %>
<%= radio_button_tag "thispage", wiki_page_version.id, (i == 1) %>
<% end %>
<% t.column width: "2%" do |wiki_page_version, i| %>
<%= radio_button_tag "otherpage", wiki_page_version.id, (i == 0) %>
<% end %>
<% end %>
<% t.column width: "2%" do |wiki_page_version, i| %>
<%= radio_button_tag "thispage", wiki_page_version.id, (i == 1) %>
<% end %>
<% t.column width: "2%" do |wiki_page_version, i| %>
<%= radio_button_tag "otherpage", wiki_page_version.id, (i == 0) %>
<% end %>
<% t.column "Title" do |wiki_page_version| %>
<span class="category-<%= wiki_page_version.category_name %>">
<%= link_to "?", wiki_page_path(wiki_page_version.wiki_page_id) %>
<%= link_to wiki_page_version.title, wiki_page_version %>
<%= link_to "»", wiki_page_versions_path(search: { wiki_page_id: wiki_page_version.wiki_page_id }) %>
</span>
<% end %>
<% t.column "Status", {width: "5%"} do |wiki_page_version| %>
@@ -32,6 +32,8 @@
<% end %>
<% end %>
<%= submit_tag "Diff" %>
<% if wiki_page_versions_listing_type == :page %>
<%= submit_tag "Diff" %>
<% end %>
<% end %>
</div>

View File

@@ -3,11 +3,7 @@
<% content_for(:content) do %>
<h1>Wiki Page History</h1>
<% if params.dig(:search, :wiki_page_id).present? %>
<%= render "page_listing" %>
<% else %>
<%= render "global_listing" %>
<% end %>
<%= render "listing" %>
<%= numbered_paginator(@wiki_page_versions) %>
<% end %>