]> git.openstreetmap.org Git - rails.git/blob - app/views/changesets/show.html.erb
Simplify step mapping function
[rails.git] / app / views / changesets / show.html.erb
1 <% set_title(t(".title", :id => @changeset.id)) %>
2
3 <%= render "sidebar_header", :title => t(".title", :id => @changeset.id) %>
4
5 <div class="browse-section">
6   <p class="fs-6 overflow-x-auto">
7     <%= linkify(@changeset.tags["comment"].to_s.presence || t("browse.no_comment")) %>
8   </p>
9   <%= tag.p :class => "details", :data => { :changeset => changeset_data(@changeset) } do %>
10     <%= changeset_details(@changeset) %>
11   <% end %>
12
13   <%= render :partial => "browse/tag_details", :object => @changeset.tags.except("comment") %>
14
15   <div class="row">
16     <div class="col">
17       <h4><%= t(".discussion") %></h4>
18     </div>
19
20     <% if current_user %>
21       <div class="col-auto">
22         <% if @changeset.subscribers.exists?(current_user.id) %>
23           <%= tag.button t(".unsubscribe"),
24                          :class => "btn btn-sm btn-primary",
25                          :name => "unsubscribe",
26                          :data => { :method => "DELETE",
27                                     :url => api_changeset_subscription_path(@changeset) } %>
28         <% else %>
29           <%= tag.button t(".subscribe"),
30                          :class => "btn btn-sm btn-primary",
31                          :name => "subscribe",
32                          :data => { :method => "POST",
33                                     :url => api_changeset_subscription_path(@changeset) } %>
34         <% end %>
35       </div>
36     <% end %>
37   </div>
38
39   <% @comments.each do |comment| %>
40     <% next unless comment.visible || current_user&.moderator? %>
41     <article id="c<%= comment.id %>">
42       <small class='text-body-secondary'>
43         <%= comment_by_options = { :time_ago => friendly_date_ago(comment.created_at),
44                                    :user => link_to(comment.author.display_name, comment.author) }
45             comment.visible ? t(".comment_by_html", **comment_by_options) : t(".hidden_comment_by_html", **comment_by_options) %>
46         <% if current_user&.moderator? %>
47           —
48           <%= tag.button t(".#{comment.visible ? 'hide' : 'unhide'}_comment"),
49                          :class => "btn btn-sm small btn-link link-secondary p-0 align-baseline",
50                          :data => { :method => comment.visible ? "DELETE" : "POST",
51                                     :url => api_changeset_comment_visibility_path(comment) } %>
52         <% end %>
53         <a href="#c<%= comment.id %>">
54           <svg width="16" height="16" fill="currentColor">
55             <path d="M4.715 6.542 3.343 7.914a3 3 0 1 0 4.243 4.243l1.828-1.829A3 3 0 0 0 8.586 5.5L8 6.086a1 1 0 0 0-.154.199 2 2 0 0 1 .861 3.337L6.88 11.45a2 2 0 1 1-2.83-2.83l.793-.792a4 4 0 0 1-.128-1.287z" />
56             <path d="M6.586 4.672A3 3 0 0 0 7.414 9.5l.775-.776a2 2 0 0 1-.896-3.346L9.12 3.55a2 2 0 1 1 2.83 2.83l-.793.792c.112.42.155.855.128 1.287l1.372-1.372a3 3 0 1 0-4.243-4.243z" />
57           </svg>
58         </a>
59       </small>
60       <div class="mx-2">
61         <%= comment.body.to_html %>
62       </div>
63     </article>
64   <% end %>
65
66   <% unless current_user %>
67     <p>
68       <%= link_to(t(".join_discussion"), login_path(:referer => request.fullpath)) %>
69     </p>
70   <% end %>
71
72   <% if current_user %>
73     <% unless @changeset.open? %>
74       <form action="#" class="mb-3">
75         <div class="mb-3">
76           <textarea class="form-control" name="text" cols="40" rows="5"></textarea>
77         </div>
78         <div id="comment-error" class="alert alert-danger p-2 mb-3" hidden>
79         </div>
80         <div>
81           <%= tag.button t(".comment"),
82                          :class => "btn btn-primary",
83                          :name => "comment",
84                          :disabled => true,
85                          :data => { :method => "POST",
86                                     :url => api_changeset_changeset_comments_path(@changeset) } %>
87         </div>
88       </form>
89     <% else %>
90       <p>
91         <%= t(".still_open") %>
92       </p>
93     <% end %>
94   <% end %>
95
96   <% unless @ways.empty? %>
97     <%= render :partial => "elements", :locals => { :type => "way", :elements => @ways, :pages => @way_pages } %>
98   <% end %>
99
100   <% unless @relations.empty? %>
101     <%= render :partial => "elements", :locals => { :type => "relation", :elements => @relations, :pages => @relation_pages } %>
102   <% end %>
103
104   <% unless @nodes.empty? %>
105     <%= render :partial => "elements", :locals => { :type => "node", :elements => @nodes, :pages => @node_pages } %>
106   <% end %>
107 </div>
108
109 <div class='secondary-actions'>
110   <%= link_to t(".changesetxml"), api_changeset_path(@changeset) %>
111   &middot;
112   <%= link_to t(".osmchangexml"), api_changeset_download_path(@changeset) %>
113 </div>
114
115 <% if @next_by_user || @prev_by_user %>
116   <div class='secondary-actions'>
117     <% if @prev_by_user %>
118       <%= link_to @prev_by_user, :class => "icon-link" do %>
119         <%= previous_page_svg_tag :height => 11 %>
120         <%= @prev_by_user.id %>
121       <% end %>
122       &middot;
123     <% end %>
124     <%= user = (@prev_by_user || @next_by_user).user.display_name
125         link_to tag.bdi(user), :controller => "changesets", :action => "index", :display_name => user %>
126     <% if @next_by_user %>
127       &middot;
128       <%= link_to @next_by_user, :class => "icon-link" do %>
129         <%= @next_by_user.id %>
130         <%= next_page_svg_tag :height => 11 %>
131       <% end %>
132     <% end %>
133   </div>
134 <% end %>