|
69 | 69 | <%= @post.comments.count %> <%= Comment.model_name.human(count: @post.comments.count) %>
|
70 | 70 | </div>
|
71 | 71 | <% @post.comments.each do |comment| %>
|
72 |
| - <div class="card-body" id="<%= dom_id(comment) %>"> |
73 |
| - <footer> |
74 |
| - <h5> |
75 |
| - <% if comment.user.profile.photo.present? %> |
76 |
| - <%= image_tag comment.user.profile.photo, alt: 'Foto de perfil', width: '35rem', class: 'rounded-circle mx-3' %> |
77 |
| - <% else %> |
78 |
| - <%= image_tag 'default_portfoliorrr_photo.png', alt: 'Foto de perfil', width: '35rem', class: 'rounded-circle mx-3' %> |
79 |
| - <% end %> |
80 |
| - <%= link_to comment.user.full_name, comment.user.profile %> <%= '(autor)' if comment.user == @post.user %> |
81 |
| - </h5> |
82 |
| - <p class="comment-message"><%= comment.message %></p> |
83 |
| - </footer> |
84 |
| - <% if comment.user.deleted_at.nil? %> |
85 |
| - <div class="btn-group flex-column"> |
86 |
| - <div> |
87 |
| - <div class="mt-2 me-2"> |
88 |
| - <div class="d-flex align-items-center comment-actions"> |
89 |
| - <% if user_signed_in? && comment.likes.where(user_id: current_user.id).any? %> |
90 |
| - <% like = comment.likes.find_by(user_id: current_user.id) %> |
91 |
| - <%= button_to comment_like_path(comment, like), method: :delete, class: 'btn btn-sm', id: 'unlike' do %> |
92 |
| - <%= image_tag 'thumbs-up-solid', width: '20rem', class: 'mb-2' %> |
| 72 | + <% if comment.removed?%> |
| 73 | + <p><%= t('comments.removed_content') %> </p> |
| 74 | + <% else %> |
| 75 | + <div class="card-body" id="<%= dom_id(comment) %>"> |
| 76 | + <footer> |
| 77 | + <h5> |
| 78 | + <% if comment.user.profile.photo.present? %> |
| 79 | + <%= image_tag comment.user.profile.photo, alt: 'Foto de perfil', width: '35rem', class: 'rounded-circle mx-3' %> |
| 80 | + <% else %> |
| 81 | + <%= image_tag 'default_portfoliorrr_photo.png', alt: 'Foto de perfil', width: '35rem', class: 'rounded-circle mx-3' %> |
| 82 | + <% end %> |
| 83 | + <%= link_to comment.user.full_name, comment.user.profile %> <%= '(autor)' if comment.user == @post.user %> |
| 84 | + </h5> |
| 85 | + <p class="comment-message"><%= comment.message %></p> |
| 86 | + </footer> |
| 87 | + <% if comment.user.deleted_at.nil? %> |
| 88 | + <div class="btn-group flex-column"> |
| 89 | + <div> |
| 90 | + <div class="mt-2 me-2"> |
| 91 | + <div class="d-flex align-items-center comment-actions"> |
| 92 | + <% if user_signed_in? && comment.likes.where(user_id: current_user.id).any? %> |
| 93 | + <% like = comment.likes.find_by(user_id: current_user.id) %> |
| 94 | + <%= button_to comment_like_path(comment, like), method: :delete, class: 'btn btn-sm', id: 'unlike' do %> |
| 95 | + <%= image_tag 'thumbs-up-solid', width: '20rem', class: 'mb-2' %> |
| 96 | + <% end %> |
| 97 | + <% else %> |
| 98 | + <%= button_to comment_likes_path(comment), method: :post, class: 'btn btn-sm', id: 'like' do %> |
| 99 | + <%= image_tag 'thumbs-up-regular', width: '20rem', class: 'mb-2' %> |
| 100 | + <% end %> |
93 | 101 | <% end %>
|
94 |
| - <% else %> |
95 |
| - <%= button_to comment_likes_path(comment), method: :post, class: 'btn btn-sm', id: 'like' do %> |
96 |
| - <%= image_tag 'thumbs-up-regular', width: '20rem', class: 'mb-2' %> |
| 102 | + <span><%= comment.likes.count %> <%= Like.model_name.human(count: comment.likes.count) %></span> |
| 103 | + <button onClick="showForm(<%= comment.id %>)" class="btn btn-outline-primary rounded-5 border-0 mx-2"><%= t('reply')%></button> |
| 104 | + <% if current_user != comment.user %> |
| 105 | + <div class="report-link-wrapper mt-3"> |
| 106 | + <p><%= link_to t('reports.report_btn'), new_report_path(reportable: comment, reportable_type: comment.class), class: 'btn btn-secondary btn-sm' %></p> |
| 107 | + </div> |
97 | 108 | <% end %>
|
98 |
| - <% end %> |
99 |
| - <span><%= comment.likes.count %> <%= Like.model_name.human(count: comment.likes.count) %></span> |
100 |
| - <button onClick="showForm(<%= comment.id %>)" class="btn btn-outline-primary rounded-5 border-0 mx-2"><%= t('reply')%></button> |
101 |
| - <% if current_user != comment.user %> |
102 |
| - <div class="report-link-wrapper mt-3"> |
103 |
| - <p><%= link_to t('reports.report_btn'), new_report_path(reportable: comment, reportable_type: comment.class), class: 'btn btn-secondary btn-sm' %></p> |
104 |
| - </div> |
105 |
| - <% end %> |
106 |
| - </div> |
107 |
| - <div class="reply-form"> |
108 |
| - <%= form_with model: [comment, @reply], method: :post, class:'d-none row align-items-center mt-3', id:"comment-#{comment.id}" do |form| %> |
109 |
| - <div class="col-md-12"> |
110 |
| - <%= form.label :message, class: 'd-none' %> |
111 |
| - <%= form.text_area :message, placeholder: 'Adicione uma resposta...', class: 'form-control' %> |
112 |
| - </div> |
113 |
| - <div class="col-md-6 mt-2"> |
114 |
| - <%= form.submit t('replies.send'), class: 'btn btn-primary' %> |
115 |
| - </div> |
116 |
| - <% end %> |
117 |
| - </div> |
118 |
| - <% if comment.replies.any? %> |
119 |
| - <button class="btn btn-outline-info border-0 rounded-5 mt-2 dropdown-toggle reply-collapser" |
120 |
| - type="button" |
121 |
| - data-bs-toggle="collapse" |
122 |
| - data-bs-target="#collapseReplies<%= comment.id %>" |
123 |
| - aria-expanded="false" |
124 |
| - aria-controls="collapseReplies<%= comment.id %>"> |
125 |
| - <%= comment.replies.count %> <%= Reply.model_name.human(count: comment.replies.count) %> |
126 |
| - </button> |
127 |
| - <div class="collapse mx-5 mt-3 reply-content" id="collapseReplies<%= comment.id %>"> |
128 |
| - <% comment.replies.each do |reply| %> |
129 |
| - <h6 class="mt-2"> |
130 |
| - <% if reply.user.profile.photo.present? %> |
131 |
| - <%= image_tag reply.user.profile.photo, alt: 'Foto de perfil', width: '30rem', class: 'rounded-circle mx-3' %> |
132 |
| - <% else %> |
133 |
| - <%= image_tag 'default_portfoliorrr_photo.png', alt: 'Foto de perfil', width: '30rem', class: 'rounded-circle mx-3' %> |
134 |
| - <% end %> |
135 |
| - <%= link_to reply.user.full_name, reply.user.profile %> <%= '(autor)' if reply.user == @post.user %> |
136 |
| - <small datetime="<%= reply.created_at.to_datetime %>"> |
137 |
| - há <%= distance_of_time_in_words(Time.now, reply.created_at) %> |
138 |
| - </small> |
139 |
| - </h6> |
140 |
| - <div class="reply-content text-dark"> |
141 |
| - <p class="mx-2"><%= reply.message %></p> |
142 |
| - <div class="btn-group d-flex align-items-center mt-4"> |
143 |
| - <% if user_signed_in? && reply.likes.where(user_id: current_user.id).any? %> |
144 |
| - <% like = reply.likes.find_by(user_id: current_user.id) %> |
145 |
| - <%= button_to reply_like_path(reply, like), method: :delete, class: 'btn btn-sm', id: 'unlike' do %> |
146 |
| - <%= image_tag 'thumbs-up-solid', width: '20rem' %> |
147 |
| - <% end %> |
| 109 | + </div> |
| 110 | + <div class="reply-form"> |
| 111 | + <%= form_with model: [comment, @reply], method: :post, class:'d-none row align-items-center mt-3', id:"comment-#{comment.id}" do |form| %> |
| 112 | + <div class="col-md-12"> |
| 113 | + <%= form.label :message, class: 'd-none' %> |
| 114 | + <%= form.text_area :message, placeholder: 'Adicione uma resposta...', class: 'form-control' %> |
| 115 | + </div> |
| 116 | + <div class="col-md-6 mt-2"> |
| 117 | + <%= form.submit t('replies.send'), class: 'btn btn-primary' %> |
| 118 | + </div> |
| 119 | + <% end %> |
| 120 | + </div> |
| 121 | + <% if comment.replies.any? %> |
| 122 | + <button class="btn btn-outline-info border-0 rounded-5 mt-2 dropdown-toggle reply-collapser" |
| 123 | + type="button" |
| 124 | + data-bs-toggle="collapse" |
| 125 | + data-bs-target="#collapseReplies<%= comment.id %>" |
| 126 | + aria-expanded="false" |
| 127 | + aria-controls="collapseReplies<%= comment.id %>"> |
| 128 | + <%= comment.replies.count %> <%= Reply.model_name.human(count: comment.replies.count) %> |
| 129 | + </button> |
| 130 | + <div class="collapse mx-5 mt-3 reply-content" id="collapseReplies<%= comment.id %>"> |
| 131 | + <% comment.replies.each do |reply| %> |
| 132 | + <h6 class="mt-2"> |
| 133 | + <% if reply.user.profile.photo.present? %> |
| 134 | + <%= image_tag reply.user.profile.photo, alt: 'Foto de perfil', width: '30rem', class: 'rounded-circle mx-3' %> |
148 | 135 | <% else %>
|
149 |
| - <%= button_to reply_likes_path(reply), method: :post, class: 'btn btn-sm', id: 'like' do %> |
150 |
| - <%= image_tag 'thumbs-up-regular', width: '20rem' %> |
151 |
| - <% end %> |
| 136 | + <%= image_tag 'default_portfoliorrr_photo.png', alt: 'Foto de perfil', width: '30rem', class: 'rounded-circle mx-3' %> |
152 | 137 | <% end %>
|
153 |
| - <div class="me-2 mt-2"> |
154 |
| - <%= reply.likes.count %> <%= Like.model_name.human(count: reply.likes.count) %> |
155 |
| - </div> |
156 |
| - <% if current_user != reply.user %> |
157 |
| - <div class="report-link-wrapper mt-3"> |
158 |
| - <p><%= link_to t('reports.report_btn'), new_report_path(reportable: reply, reportable_type: reply.class), class: 'btn btn-secondary btn-sm' %></p> |
| 138 | + <%= link_to reply.user.full_name, reply.user.profile %> <%= '(autor)' if reply.user == @post.user %> |
| 139 | + <small datetime="<%= reply.created_at.to_datetime %>"> |
| 140 | + há <%= distance_of_time_in_words(Time.now, reply.created_at) %> |
| 141 | + </small> |
| 142 | + </h6> |
| 143 | + <div class="reply-content text-dark"> |
| 144 | + <p class="mx-2"><%= reply.message %></p> |
| 145 | + <div class="btn-group d-flex align-items-center mt-4"> |
| 146 | + <% if user_signed_in? && reply.likes.where(user_id: current_user.id).any? %> |
| 147 | + <% like = reply.likes.find_by(user_id: current_user.id) %> |
| 148 | + <%= button_to reply_like_path(reply, like), method: :delete, class: 'btn btn-sm', id: 'unlike' do %> |
| 149 | + <%= image_tag 'thumbs-up-solid', width: '20rem' %> |
| 150 | + <% end %> |
| 151 | + <% else %> |
| 152 | + <%= button_to reply_likes_path(reply), method: :post, class: 'btn btn-sm', id: 'like' do %> |
| 153 | + <%= image_tag 'thumbs-up-regular', width: '20rem' %> |
| 154 | + <% end %> |
| 155 | + <% end %> |
| 156 | + <div class="me-2 mt-2"> |
| 157 | + <%= reply.likes.count %> <%= Like.model_name.human(count: reply.likes.count) %> |
159 | 158 | </div>
|
160 |
| - <% end %> |
| 159 | + <% if current_user != reply.user %> |
| 160 | + <div class="report-link-wrapper mt-3"> |
| 161 | + <p><%= link_to t('reports.report_btn'), new_report_path(reportable: reply, reportable_type: reply.class), class: 'btn btn-secondary btn-sm' %></p> |
| 162 | + </div> |
| 163 | + <% end %> |
| 164 | + </div> |
161 | 165 | </div>
|
162 |
| - </div> |
163 |
| - <% end %> |
164 |
| - </div> |
165 |
| - <%end%> |
| 166 | + <% end %> |
| 167 | + </div> |
| 168 | + <%end%> |
| 169 | + </div> |
166 | 170 | </div>
|
167 | 171 | </div>
|
168 |
| - </div> |
169 |
| - <% end %> |
170 |
| - </div> |
| 172 | + <% end %> |
| 173 | + </div> |
| 174 | + <% end %> |
171 | 175 | <% end %>
|
172 | 176 | </div>
|
173 | 177 |
|
|
0 commit comments