From bb4720f09b42749746151dae1d0348f062696574 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Sun, 5 Jan 2025 17:35:37 +0300 Subject: [PATCH] Move changeset data to a helper --- app/helpers/changesets_helper.rb | 16 ++++++++++++++++ app/views/changesets/_changeset.html.erb | 14 +------------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/helpers/changesets_helper.rb b/app/helpers/changesets_helper.rb index ae953c583..4605658f6 100644 --- a/app/helpers/changesets_helper.rb +++ b/app/helpers/changesets_helper.rb @@ -41,4 +41,20 @@ module ChangesetsHelper t "changesets.index.title" end end + + def changeset_data(changeset) + changeset_data = { :id => changeset.id } + + if changeset.bbox_valid? + bbox = changeset.bbox.to_unscaled + changeset_data[:bbox] = { + :minlon => bbox.min_lon, + :minlat => bbox.min_lat, + :maxlon => bbox.max_lon, + :maxlat => bbox.max_lat + } + end + + changeset_data + end end diff --git a/app/views/changesets/_changeset.html.erb b/app/views/changesets/_changeset.html.erb index 2a3f65859..e29cf01b0 100644 --- a/app/views/changesets/_changeset.html.erb +++ b/app/views/changesets/_changeset.html.erb @@ -1,16 +1,4 @@ -<% changeset_data = { :id => changeset.id } - - if changeset.bbox_valid? - bbox = changeset.bbox.to_unscaled - changeset_data[:bbox] = { - :minlon => bbox.min_lon, - :minlat => bbox.min_lat, - :maxlon => bbox.max_lon, - :maxlat => bbox.max_lat - } - end %> - -<%= tag.li :id => "changeset_#{changeset.id}", :data => { :changeset => changeset_data }, :class => "list-group-item list-group-item-action" do %> +<%= tag.li :id => "changeset_#{changeset.id}", :data => { :changeset => changeset_data(changeset) }, :class => "list-group-item list-group-item-action" do %>

<%= changeset.tags["comment"].to_s.presence || t("browse.no_comment") %> -- 2.39.5