]> git.openstreetmap.org Git - rails.git/blob - app/views/notes/show.html.erb
Move directions route output to its own module
[rails.git] / app / views / notes / show.html.erb
1 <% set_title(t(".title", :id => @note.id)) %>
2
3 <%= render "sidebar_header", :title => t(".#{@note.status}_title", :note_name => @note.id) %>
4
5 <div>
6   <h4><%= t(".description") %></h4>
7   <div class="overflow-hidden ms-2">
8     <%= note_description(@note.author, @note.description, current_user&.moderator? ? @note.comments.unscope(:where => :visible).first : @note.comments.first).to_html %>
9   </div>
10
11   <div class="details" data-coordinates="<%= @note.lat %>,<%= @note.lon %>" data-status="<%= @note.status %>">
12     <p class="mb-2"><%= note_event("opened", @note.created_at, @note.author) %></p>
13     <% if @note.status == "closed" %>
14       <p class="mb-2"><%= note_event(@note.status, @note.closed_at, @note.all_comments.last.author) %></p>
15     <% end %>
16     <p>
17       <%= t "browse.location" %>
18       <%= link_to t(".coordinates_html",
19                     :latitude => tag.span(number_with_delimiter(@note.lat), :class => "latitude"),
20                     :longitude => tag.span(number_with_delimiter(@note.lon), :class => "longitude")),
21                   root_path(:anchor => "map=18/#{@note.lat}/#{@note.lon}") %>
22     </p>
23   </div>
24
25   <% if @note_includes_anonymous -%>
26     <p class='alert alert-warning'><%= t ".anonymous_warning" %></p>
27   <% end -%>
28
29   <div class="row">
30     <div class="col">
31       <h4><%= t(".discussion") %></h4>
32     </div>
33
34     <% if current_user %>
35       <div class="col-auto">
36         <% if @note.subscribers.exists?(current_user.id) %>
37           <%= tag.button t(".unsubscribe"),
38                          :type => "button",
39                          :class => "btn btn-sm btn-primary",
40                          :name => "unsubscribe",
41                          :data => { :method => "DELETE",
42                                     :url => api_note_subscription_path(@note) } %>
43         <% else %>
44           <%= tag.button t(".subscribe"),
45                          :type => "button",
46                          :class => "btn btn-sm btn-primary",
47                          :name => "subscribe",
48                          :data => { :method => "POST",
49                                     :url => api_note_subscription_path(@note) } %>
50         <% end %>
51       </div>
52     <% end %>
53   </div>
54
55   <% @note_comments.each do |comment| %>
56     <article id="c<%= comment.id %>">
57       <small class='text-body-secondary'><%= note_event(comment.event, comment.created_at, comment.author) %></small>
58       <div class="mx-2">
59         <%= comment.body.to_html %>
60       </div>
61     </article>
62   <% end %>
63
64   <% if @note.status == "open" %>
65     <% if current_user -%>
66       <form class="mb-3" action="#">
67         <div class="mb-3">
68           <textarea class="form-control" name="text" cols="40" rows="5" maxlength="2000"></textarea>
69         </div>
70         <div id="comment-error" class="alert alert-danger p-2 mb-3" hidden>
71         </div>
72         <div class="d-flex flex-wrap gap-1">
73           <% if current_user.moderator? -%>
74             <%= button_tag t(".hide"), :name => "hide", :class => "btn btn-light",
75                                        :data => { :method => "DELETE",
76                                                   :url => api_note_url(@note, "json") } %>
77           <% end -%>
78           <%= button_tag t(".resolve"), :name => "close", :class => "btn btn-primary",
79                                         :data => { :method => "POST",
80                                                    :url => close_api_note_url(@note, "json"),
81                                                    :default_action_text => t(".resolve"),
82                                                    :comment_action_text => t(".comment_and_resolve") } %>
83           <%= button_tag t(".comment"), :name => "comment", :class => "btn btn-primary", :disabled => true,
84                                         :data => { :method => "POST",
85                                                    :url => comment_api_note_url(@note, "json") } %>
86         </div>
87       </form>
88     <% else -%>
89       <p>
90         <%= link_to t(".log_in_to_comment"), login_path(:referer => request.fullpath) %>
91       </p>
92     <% end -%>
93   <% else %>
94     <form class="mb-3" action="#">
95       <input type="hidden" name="text" value="" autocomplete="off">
96       <div id="comment-error" class="alert alert-danger p-2 mb-3" hidden>
97       </div>
98       <div class="d-flex flex-wrap gap-1">
99         <% if @note.status != "hidden" and current_user and current_user.moderator? -%>
100           <%= button_tag t(".hide"), :name => "hide", :class => "btn btn-light",
101                                      :data => { :method => "DELETE",
102                                                 :url => api_note_url(@note, "json") } %>
103         <% end -%>
104         <% if current_user -%>
105           <%= button_tag t(".reactivate"), :name => "reopen", :class => "btn btn-primary",
106                                            :data => { :method => "POST",
107                                                       :url => reopen_api_note_url(@note, "json") } %>
108         <% end -%>
109       </div>
110     </form>
111   <% end %>
112
113   <% if current_user && current_user != @note.author %>
114     <p>
115       <small class="text-body-secondary">
116         <%= t ".report_link_html", :link => report_link(t(".report"), @note) %>
117         <% if @note.status == "open" %>
118           <%= t ".other_problems_resolve", :link => report_link(t(".report"), @note) %>
119         <% elsif @note.status == "closed" %>
120           <%= t ".other_problems_resolved" %>
121         <% end %>
122       </small>
123     </p>
124   <% end %>
125
126   <% if @note.freshly_closed? %>
127     <small class="text-body-secondary">
128       <%= t ".disappear_date_html", :disappear_in => friendly_date(@note.freshly_closed_until) %>
129     </small>
130   <% end %>
131 </div>