Commit b6e13016 authored by David Lucadou's avatar David Lucadou

Improvements to the user messages view

I revised the conversation index to show last response date and who sent
it, and added a link to easily go back to it. I also added a box for
each message so you can easily view the Markdown source of each message.
parent 5d99c3d2
Pipeline #62719744 canceled with stage
in 10 seconds
......@@ -10,4 +10,8 @@ module MessagesHelper
"#{MessagesHelper.edit_window / 60} minutes, #{MessagesHelper.edit_window % 60} seconds"
end
end
def self.max_body_length
8192
end
end
......@@ -20,7 +20,7 @@
<%= f.fields_for :messages do |f2| %>
<%= f2.label :body, "Message", :for => :message_body %>
<%= f2.text_area :body, id: :message_body, :class => "form-control", :rows => "4" %>
<small id="message_bodyHelp" class="form-text text-muted">You can use <a href="https://www.markdownguide.org/basic-syntax">Markdown</a> in this field. Inlined HTML will be ignored; maximum 8192 characters.</small>
<small id="message_bodyHelp" class="form-text text-muted">You can use <%= link_to "Markdown", help_markdown_path%> in this field. Inlined HTML will be ignored; maximum <%= MessagesHelper.max_body_length %> characters.</small>
<% end %>
<br />
......
......@@ -26,11 +26,10 @@
<table class="table table-bordered table-striped">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Subject</th>
<th scope="col">Last Response</th>
<th scope="col">Unreads</th>
<th scope="col">Closed?</th>
<th scope="col" colspan="2">Closed?</th>
</tr>
</thead>
<tbody>
......@@ -39,11 +38,11 @@
<% else %>
<% @conversations.each do |conversation| %>
<tr class="<%= 'table-primary' if !params[:highlight].nil? && conversation.id == params[:highlight].to_i =%>">
<td><%= conversation.id %></td>
<td><%= conversation.subject %></td>
<td>N/A</td>
<td><%= datetime_with_offset(conversation.messages.last.created_at) %> by <%= conversation.messages.last.sender&.name %></td>
<td><%= conversation.messages.count %></td>
<td><%= conversation.locked %></td>
<td><%= conversation.locked.to_s.capitalize %></td>
<td><%= link_to "View", conversation %>
</tr>
<% end %>
<% end %>
......
......@@ -22,7 +22,7 @@
<noscript>
<style> .collapse:not(.show){ display:contents; } </style>
<!-- Auto-uncollapse items when JavaScript is disabled -->
<p class="card-text">To collapse message edit forms, you must enable JavaScript.</p>
<p class="card-text">To collapse message edit forms and raw markdown panels, you must enable JavaScript.</p>
</noscript>
<% @conversation.messages.where(user_visible: true).order(:created_at).each do |message| %>
......@@ -38,18 +38,24 @@
<div class="card-body">
<p><%= markdown(message.body) %></p>
<span class="float-right text-muted">
<a class="accordion-row-toggler" role="button" data-toggle="collapse" data-target="#source-collapse<%= message.user_relative_id %>" href="#source-collapse<%= message.user_relative_id %>" aria-expanded="false" aira-controls="source-collapse<%= message.user_relative_id %>">View Source <i class="fas fa-chevron-circle-down"></i></a>
<% if message.editable? %>
|
<a class="accordion-row-toggler" role="button" data-toggle="collapse" data-target="#edit-collapse<%= message.user_relative_id %>" href="#edit-collapse<%= message.user_relative_id %>" aira-expanded="false" aria-controls="edit-collapse<%= message.user_relative_id %>" title="Editable until <%= datetime_with_offset(message.edit_period_end) %>">
Edit <i class="fas fa-chevron-circle-down"></i>
</a>|
</a>
<% end %>
<% if current_user.role.to_sym == :admin %>
<%= link_to "Hide from User", conversation_hide_path(message.id, conversation_id: @conversation.id), method: :post, data: { message_id: message.id } %>
| <%= link_to "Hide from User", conversation_hide_path(message.id, conversation_id: @conversation.id), method: :post, data: { message_id: message.id } %>
<% end %>
<% if message.sender_id == current_user.id %>
| <%= link_to "Delete", conversation_message_path(message.id, conversation_id: @conversation.id), method: :delete, data: { message_id: message.id, confirm: 'Are you sure?' } %>
<% end %>
</span>
<span class="collapse" id="source-collapse<%= message.user_relative_id %>">
<label>Raw Markdown</label>
<pre class="codeblock-fenced"><%= message.body %></pre>
</span>
<% if message.editable? %>
<span class="collapse" id="edit-collapse<%= message.user_relative_id %>">
<%= render 'messages/user_edit_form', message: message %>
......
......@@ -15,7 +15,7 @@
<div class="field form-group">
<%= f.label :body, "Message", :for => :message_body %>
<%= f.text_area :body, id: :message_body, :class => "form-control", :rows => "4" %>
<small id="message_bodyHelp" class="form-text text-muted">You can use <%= link_to "Markdown", help_markdown_path%> in this field. Inlined HTML will be ignored; maximum 8192 characters.</small>
<small id="message_bodyHelp" class="form-text text-muted">You can use <%= link_to "Markdown", help_markdown_path%> in this field. Inlined HTML will be ignored; maximum <%= MessagesHelper.max_body_length %> characters.</small>
</div>
<div class="actions">
......
......@@ -309,13 +309,13 @@ puts "Hello, World!"
| aligned | | aligned |</pre>
<%= markdown("| Column A | Column B | Column C |\n| --------:|:---------- |:--------:|\n| This | This one | This one |\n| column | is left | is |\n| is right | aligned | center |\n| aligned | | aligned |") %>
</li>
<li>The most important thing to remember is that you only need 3 dashes separating each column, and the outer pipes are unnecessary. Other Markdown elements can be used, and you can make some syntactically-weird looking tables that render just fine:
<li>The most important thing to remember is that you only need 3 dashes separating each column, you can leave a cell empty, and the outer pipes are unnecessary. Other Markdown elements can be used, and you can make some weird looking but syntactically-valid tables that render just fine:
<pre class="codeblock-fenced">This | isn't very | pretty
--- | ---:| ---
but it *still* | gets the | job done
but it *still* | | gets the job done
and it _renders_ | `just fine` | and you can still use
column alignments | like this middle | column does</pre>
<%= markdown("This | isn't very | pretty\n--- | ---:| ---\nbut it *still* | gets the | job done\nand it _renders_ | `just fine` | and you can still use\ncolumn alignments | like this middle | column does") %>
<%= markdown("This | isn't very | pretty\n--- | ---:| ---\nbut it *still* | | gets the job done\nand it _renders_ | `just fine` | and you can still use\ncolumn alignments | like this middle | column does") %>
</li>
</ul>
<hr />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment