From: Anton Khorev Date: Fri, 1 Mar 2024 12:58:48 +0000 (+0300) Subject: Refactor common element version view code X-Git-Tag: live~747^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/642070f1e5dee82077676aa300ff47fbac11c506?ds=sidebyside;hp=-c Refactor common element version view code --- 642070f1e5dee82077676aa300ff47fbac11c506 diff --git a/app/views/browse/_version_actions.erb b/app/views/browse/_version_actions.erb new file mode 100644 index 000000000..46bfd0dc2 --- /dev/null +++ b/app/views/browse/_version_actions.erb @@ -0,0 +1,32 @@ +
+ <%= link_to t("browse.view_details"), :controller => :browse, :action => @type %> + <% if !@feature.redacted? %> + · + <%= link_to t("browse.download_xml"), :controller => "api/old_#{@type.pluralize}", :action => :version %> + <% elsif current_user&.moderator? %> + · + <% if !params[:show_redactions] %> + <%= link_to t("browse.view_redacted_data"), :params => { :show_redactions => true } %> + <% else %> + <%= link_to t("browse.view_redaction_message") %> + <% end %> + <% end %> +
+ +
+ <% if @feature.version > 1 %> + <%= link_to({ :version => @feature.version - 1 }, { :class => "icon-link" }) do %> + <%= previous_page_svg_tag :height => 11 %> + <%= "#{t('browse.version')} ##{@feature.version - 1}" %> + <% end %> + · + <% end %> + <%= link_to t("browse.view_history"), :controller => :browse, :action => "#{@type}_history" %> + <% unless @feature.latest_version? %> + · + <%= link_to({ :version => @feature.version + 1 }, { :class => "icon-link" }) do %> + <%= "#{t('browse.version')} ##{@feature.version + 1}" %> + <%= next_page_svg_tag :height => 11 %> + <% end %> + <% end %> +
diff --git a/app/views/old_nodes/show.html.erb b/app/views/old_nodes/show.html.erb index 3cf9828d8..093a3e7c1 100644 --- a/app/views/old_nodes/show.html.erb +++ b/app/views/old_nodes/show.html.erb @@ -4,35 +4,4 @@ <%= render :partial => "browse/node", :object => @feature %> -
- <%= link_to t("browse.view_details"), node_path(@feature.node_id) %> - <% if !@feature.redacted? %> - · - <%= link_to t("browse.download_xml"), node_version_path(*@feature.id) %> - <% elsif current_user&.moderator? %> - · - <% if !params[:show_redactions] %> - <%= link_to t("browse.view_redacted_data"), old_node_path(*@feature.id, :params => { :show_redactions => true }) %> - <% else %> - <%= link_to t("browse.view_redaction_message"), old_node_path(*@feature.id) %> - <% end %> - <% end %> -
- -
- <% if @feature.version > 1 %> - <%= link_to old_node_path(@feature.node_id, @feature.version - 1), :class => "icon-link" do %> - <%= previous_page_svg_tag :height => 11 %> - <%= "#{t('browse.version')} ##{@feature.version - 1}" %> - <% end %> - · - <% end %> - <%= link_to t("browse.view_history"), node_history_path(@feature.node_id) %> - <% if @feature.version < @feature.current_node.version %> - · - <%= link_to old_node_path(@feature.node_id, @feature.version + 1), :class => "icon-link" do %> - <%= "#{t('browse.version')} ##{@feature.version + 1}" %> - <%= next_page_svg_tag :height => 11 %> - <% end %> - <% end %> -
+<%= render :partial => "browse/version_actions" %> diff --git a/app/views/old_relations/show.html.erb b/app/views/old_relations/show.html.erb index a0dfae250..94e3674d8 100644 --- a/app/views/old_relations/show.html.erb +++ b/app/views/old_relations/show.html.erb @@ -4,35 +4,4 @@ <%= render :partial => "browse/relation", :object => @feature %> -
- <%= link_to t("browse.view_details"), relation_path(@feature.relation_id) %> - <% if !@feature.redacted? %> - · - <%= link_to t("browse.download_xml"), relation_version_path(*@feature.id) %> - <% elsif current_user&.moderator? %> - · - <% if !params[:show_redactions] %> - <%= link_to t("browse.view_redacted_data"), old_relation_path(*@feature.id, :params => { :show_redactions => true }) %> - <% else %> - <%= link_to t("browse.view_redaction_message"), old_relation_path(*@feature.id) %> - <% end %> - <% end %> -
- -
- <% if @feature.version > 1 %> - <%= link_to old_relation_path(@feature.relation_id, @feature.version - 1), :class => "icon-link" do %> - <%= previous_page_svg_tag :height => 11 %> - <%= "#{t('browse.version')} ##{@feature.version - 1}" %> - <% end %> - · - <% end %> - <%= link_to t("browse.view_history"), relation_history_path(@feature.relation_id) %> - <% if @feature.version < @feature.current_relation.version %> - · - <%= link_to old_relation_path(@feature.relation_id, @feature.version + 1), :class => "icon-link" do %> - <%= "#{t('browse.version')} ##{@feature.version + 1}" %> - <%= next_page_svg_tag :height => 11 %> - <% end %> - <% end %> -
+<%= render :partial => "browse/version_actions" %> diff --git a/app/views/old_ways/show.html.erb b/app/views/old_ways/show.html.erb index ecbc62469..1e4d14c80 100644 --- a/app/views/old_ways/show.html.erb +++ b/app/views/old_ways/show.html.erb @@ -4,35 +4,4 @@ <%= render :partial => "browse/way", :object => @feature %> -
- <%= link_to t("browse.view_details"), way_path(@feature.way_id) %> - <% if !@feature.redacted? %> - · - <%= link_to t("browse.download_xml"), way_version_path(*@feature.id) %> - <% elsif current_user&.moderator? %> - · - <% if !params[:show_redactions] %> - <%= link_to t("browse.view_redacted_data"), old_way_path(*@feature.id, :params => { :show_redactions => true }) %> - <% else %> - <%= link_to t("browse.view_redaction_message"), old_way_path(*@feature.id) %> - <% end %> - <% end %> -
- -
- <% if @feature.version > 1 %> - <%= link_to old_way_path(@feature.way_id, @feature.version - 1), :class => "icon-link" do %> - <%= previous_page_svg_tag :height => 11 %> - <%= "#{t('browse.version')} ##{@feature.version - 1}" %> - <% end %> - · - <% end %> - <%= link_to t("browse.view_history"), way_history_path(@feature.way_id) %> - <% if @feature.version < @feature.current_way.version %> - · - <%= link_to old_way_path(@feature.way_id, @feature.version + 1), :class => "icon-link" do %> - <%= "#{t('browse.version')} ##{@feature.version + 1}" %> - <%= next_page_svg_tag :height => 11 %> - <% end %> - <% end %> -
+<%= render :partial => "browse/version_actions" %>