diff options
| -rw-r--r-- | app/views/revisions/diff.html.erb | 17 | ||||
| -rw-r--r-- | public/stylesheets/admin.css | 1 | ||||
| -rw-r--r-- | test/controllers/revisions_controller_test.rb | 9 |
3 files changed, 26 insertions, 1 deletions
diff --git a/app/views/revisions/diff.html.erb b/app/views/revisions/diff.html.erb index 490cf17..d70503c 100644 --- a/app/views/revisions/diff.html.erb +++ b/app/views/revisions/diff.html.erb | |||
| @@ -9,13 +9,28 @@ | |||
| 9 | against <strong><%= describe_page_reference(params[:end_revision]) %></strong> | 9 | against <strong><%= describe_page_reference(params[:end_revision]) %></strong> |
| 10 | </p> | 10 | </p> |
| 11 | 11 | ||
| 12 | <p class="diff_view_toggle"> | ||
| 13 | View: | ||
| 14 | <% if @diff_view == :inline %> | ||
| 15 | <strong>Inline</strong> | ||
| 16 | <% else %> | ||
| 17 | <%= link_to 'Inline', diff_node_revisions_path(@node, start_revision: params[:start_revision], end_revision: params[:end_revision], view: 'inline') %> | ||
| 18 | <% end %> | ||
| 19 | · | ||
| 20 | <% if @diff_view == :side_by_side %> | ||
| 21 | <strong>Side by side</strong> | ||
| 22 | <% else %> | ||
| 23 | <%= link_to 'Side by side', diff_node_revisions_path(@node, start_revision: params[:start_revision], end_revision: params[:end_revision], view: 'side_by_side') %> | ||
| 24 | <% end %> | ||
| 25 | </p> | ||
| 26 | |||
| 12 | <% numeric_comparison = params[:start_revision].to_s =~ /\A\d+\z/ && params[:end_revision].to_s =~ /\A\d+\z/ %> | 27 | <% numeric_comparison = params[:start_revision].to_s =~ /\A\d+\z/ && params[:end_revision].to_s =~ /\A\d+\z/ %> |
| 13 | 28 | ||
| 14 | <% if numeric_comparison %> | 29 | <% if numeric_comparison %> |
| 15 | <%= form_tag diff_node_revisions_path do %> | 30 | <%= form_tag diff_node_revisions_path do %> |
| 16 | <%= select_tag :start_revision, options_for_select(@node.pages.map{|x| x.revision}, params[:start_revision].to_i) %> | 31 | <%= select_tag :start_revision, options_for_select(@node.pages.map{|x| x.revision}, params[:start_revision].to_i) %> |
| 17 | <%= select_tag :end_revision, options_for_select(@node.pages.map{|x| x.revision}, params[:end_revision].to_i) %> | 32 | <%= select_tag :end_revision, options_for_select(@node.pages.map{|x| x.revision}, params[:end_revision].to_i) %> |
| 18 | <%= select_tag :view, options_for_select([['Inline', 'inline'], ['Side by side', 'side_by_side']], @diff_view) %> | 33 | <%= hidden_field_tag :view, @diff_view %> |
| 19 | <%= submit_tag 'Diff' %> | 34 | <%= submit_tag 'Diff' %> |
| 20 | <% end %> | 35 | <% end %> |
| 21 | <% else %> | 36 | <% else %> |
diff --git a/public/stylesheets/admin.css b/public/stylesheets/admin.css index 56470bc..510e3cc 100644 --- a/public/stylesheets/admin.css +++ b/public/stylesheets/admin.css | |||
| @@ -32,6 +32,7 @@ table.user_table a, | |||
| 32 | table.revisions_table a, | 32 | table.revisions_table a, |
| 33 | .add_child_links a, | 33 | .add_child_links a, |
| 34 | .standalone_action_bar a, | 34 | .standalone_action_bar a, |
| 35 | .diff_view_toggle a, | ||
| 35 | div#draft_list table td.actions a { | 36 | div#draft_list table td.actions a { |
| 36 | text-decoration: underline; | 37 | text-decoration: underline; |
| 37 | -webkit-text-decoration-style: wavy; | 38 | -webkit-text-decoration-style: wavy; |
diff --git a/test/controllers/revisions_controller_test.rb b/test/controllers/revisions_controller_test.rb index 162e6f1..bf92c5b 100644 --- a/test/controllers/revisions_controller_test.rb +++ b/test/controllers/revisions_controller_test.rb | |||
| @@ -139,4 +139,13 @@ class RevisionsControllerTest < ActionController::TestCase | |||
| 139 | assert_select "form.computation input[type=hidden][name=start_revision]" | 139 | assert_select "form.computation input[type=hidden][name=start_revision]" |
| 140 | assert_select "form.computation input[type=hidden][name=end_revision]" | 140 | assert_select "form.computation input[type=hidden][name=end_revision]" |
| 141 | end | 141 | end |
| 142 | |||
| 143 | test "the view toggle is available even when comparing named layers" do | ||
| 144 | login_as :quentin | ||
| 145 | @node.find_or_create_draft(@user) | ||
| 146 | |||
| 147 | post(:diff, params: { :node_id => @node.id, :start_revision => "head", :end_revision => "draft" }) | ||
| 148 | assert_response :success | ||
| 149 | assert_select "a", "Side by side" | ||
| 150 | end | ||
| 142 | end | 151 | end |
