]> git.openstreetmap.org Git - rails.git/blob - app/views/changesets/show.html.erb
Merge remote-tracking branch 'upstream/pull/5756'
[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 => "POST",
27                                     :url => api_changeset_unsubscribe_url(@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_subscribe_url(@changeset) } %>
34         <% end %>
35       </div>
36     <% end %>
37   </div>
38
39   <% if @comments.length > 0 %>
40     <ul class="list-unstyled">
41       <% @comments.each do |comment| %>
42         <% next unless comment.visible || current_user&.moderator? %>
43         <li id="c<%= comment.id %>">
44           <small class='text-body-secondary'>
45             <%= comment_by_options = { :time_ago => friendly_date_ago(comment.created_at),
46                                        :user => link_to(comment.author.display_name, comment.author) }
47                 comment.visible ? t(".comment_by_html", **comment_by_options) : t(".hidden_comment_by_html", **comment_by_options) %>
48             <% if current_user&.moderator? %>
49               —
50               <%= tag.button t(".#{comment.visible ? 'hide' : 'unhide'}_comment"),
51                              :class => "btn btn-sm small btn-link link-secondary p-0 align-baseline",
52                              :data => { :method => comment.visible ? "DELETE" : "POST",
53                                         :url => api_changeset_comment_visibility_path(comment) } %>
54             <% end %>
55             <a href="#c<%= comment.id %>">
56               <svg width="16" height="16" fill="currentColor">
57                 <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" />
58                 <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" />
59               </svg>
60             </a>
61           </small>
62           <div class="mx-2">
63             <%= comment.body.to_html %>
64           </div>
65         </li>
66       <% end %>
67     </ul>
68   <% end %>
69
70   <% unless current_user %>
71     <p>
72       <%= link_to(t(".join_discussion"), login_path(:referer => request.fullpath)) %>
73     </p>
74   <% end %>
75
76   <% if current_user %>
77     <% unless @changeset.open? %>
78       <form action="#" class="mb-3">
79         <div class="mb-3">
80           <textarea class="form-control" name="text" cols="40" rows="5"></textarea>
81         </div>
82         <div id="comment-error" class="alert alert-danger p-2 mb-3" hidden>
83         </div>
84         <div>
85           <%= tag.button t(".comment"),
86                          :class => "btn btn-primary",
87                          :name => "comment",
88                          :disabled => true,
89                          :data => { :method => "POST",
90                                     :url => api_changeset_changeset_comments_path(@changeset) } %>
91         </div>
92       </form>
93     <% else %>
94       <p>
95         <%= t(".still_open") %>
96       </p>
97     <% end %>
98   <% end %>
99
100   <% unless @ways.empty? %>
101     <%= render :partial => "elements", :locals => { :type => "way", :elements => @ways, :pages => @way_pages } %>
102   <% end %>
103
104   <% unless @relations.empty? %>
105     <%= render :partial => "elements", :locals => { :type => "relation", :elements => @relations, :pages => @relation_pages } %>
106   <% end %>
107
108   <% unless @nodes.empty? %>
109     <%= render :partial => "elements", :locals => { :type => "node", :elements => @nodes, :pages => @node_pages } %>
110   <% end %>
111 </div>
112
113 <div class='secondary-actions'>
114   <%= link_to t(".changesetxml"), api_changeset_path(@changeset) %>
115   &middot;
116   <%= link_to t(".osmchangexml"), api_changeset_download_path(@changeset) %>
117 </div>
118
119 <% if @next_by_user || @prev_by_user %>
120   <div class='secondary-actions'>
121     <% if @prev_by_user %>
122       <%= link_to @prev_by_user, :class => "icon-link" do %>
123         <%= previous_page_svg_tag :height => 11 %>
124         <%= @prev_by_user.id %>
125       <% end %>
126       &middot;
127     <% end %>
128     <%= user = (@prev_by_user || @next_by_user).user.display_name
129         link_to tag.bdi(user), :controller => "changesets", :action => "index", :display_name => user %>
130     <% if @next_by_user %>
131       &middot;
132       <%= link_to @next_by_user, :class => "icon-link" do %>
133         <%= @next_by_user.id %>
134         <%= next_page_svg_tag :height => 11 %>
135       <% end %>
136     <% end %>
137   </div>
138 <% end %>