Extraction de partiels et activiation des turbo-frames sur la liste
This commit is contained in:
parent
e0912ee7af
commit
ef83920479
|
@ -18,6 +18,7 @@ class Email < ApplicationRecord
|
||||||
validates :from, presence: true
|
validates :from, presence: true
|
||||||
validates :headers, presence: true
|
validates :headers, presence: true
|
||||||
|
|
||||||
|
paginates_per 10
|
||||||
|
|
||||||
def postponed?
|
def postponed?
|
||||||
postponed_until.present? && postponed_until > DateTime.now
|
postponed_until.present? && postponed_until > DateTime.now
|
||||||
|
|
81
app/views/emails/_email.html.erb
Normal file
81
app/views/emails/_email.html.erb
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
<div id="<%= dom_id email %>" class="email_container">
|
||||||
|
<table class="email_content">
|
||||||
|
<thead class="email_main_headers">
|
||||||
|
<tr>
|
||||||
|
<th>Date</th>
|
||||||
|
<td><%= email.date %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>From</th>
|
||||||
|
<td><%= email.from.join(', ') %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>To</th>
|
||||||
|
<td><%= email.to.join(', ') %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Delivered-To</th>
|
||||||
|
<td><%= email.delivered_to.join(', ') %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Subject</th>
|
||||||
|
<td><%= email.subject %></td>
|
||||||
|
</tr>
|
||||||
|
<% if email.organisations.present? %>
|
||||||
|
<tr>
|
||||||
|
<th>Clients</th>
|
||||||
|
<td>
|
||||||
|
<% email.organisations.presence.each do |organisation| %>
|
||||||
|
<span class="email_attribute_organisation"><%= organisation %></span>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<% if email.servers.present? %>
|
||||||
|
<tr>
|
||||||
|
<th>Servers</th>
|
||||||
|
<td>
|
||||||
|
<% email.servers.presence.each do |server| %>
|
||||||
|
<span class="email_attribute_server"><%= server %></span>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<% if email.issues.present? %>
|
||||||
|
<tr>
|
||||||
|
<th>Issues</th>
|
||||||
|
<td>
|
||||||
|
<% email.issues.presence.each do |issue| %>
|
||||||
|
<span class="email_attribute_issue"><%= issue %></span>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<tr>
|
||||||
|
<th>From Cron</th>
|
||||||
|
<td>
|
||||||
|
<span class="<%= email.cron? ? "email_attribute_cron" : "" %>"><%= email.cron? ? "Yes" : "No" %></span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<thead class="email_additional_headers">
|
||||||
|
<% email.headers.each do |header| %>
|
||||||
|
<tr>
|
||||||
|
<th><%= header["name"] %></th>
|
||||||
|
<td><%= header["value"] %><td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<% if email.plain_body.present? %>
|
||||||
|
<pre><%= email.plain_body %></pre>
|
||||||
|
<% else %>
|
||||||
|
<i>Empty body</i>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
41
app/views/emails/_list.html.erb
Normal file
41
app/views/emails/_list.html.erb
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Date</th>
|
||||||
|
<th>Subject</th>
|
||||||
|
<th>Metadata</th>
|
||||||
|
<th colspan="3"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<% @emails.each do |email| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= email.date %></td>
|
||||||
|
<td><%= email.subject %></td>
|
||||||
|
<td>
|
||||||
|
<% email.organisations.each do |organisation| %>
|
||||||
|
<span class="email_attribute_organisation"><%= organisation %></span>
|
||||||
|
<% end if email.organisations %>
|
||||||
|
<% email.servers.each do |server| %>
|
||||||
|
<span class="email_attribute_server"><%= server %></span>
|
||||||
|
<% end if email.servers %>
|
||||||
|
<% if email.cron? %>
|
||||||
|
<span class="email_attribute_cron">cron</span>
|
||||||
|
<% end %>
|
||||||
|
<% if email.mailing_list? %>
|
||||||
|
<span class="email_attribute_mailing_list">list</span>
|
||||||
|
<% end %>
|
||||||
|
<% if email.junk? %>
|
||||||
|
<span class="email_attribute_junk">junk</span>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td><%= link_to 'Show', email, "data-turbo-frame": "_top" %></td>
|
||||||
|
<td><%= link_to 'Edit', edit_email_path(email), "data-turbo-frame": "_top" %></td>
|
||||||
|
<td><%= link_to 'Destroy', email, method: :delete, data: { confirm: 'Are you sure?' }, "data-turbo-frame": "_top" %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<%= paginate @emails %>
|
|
@ -2,48 +2,6 @@
|
||||||
|
|
||||||
<h1>Emails</h1>
|
<h1>Emails</h1>
|
||||||
|
|
||||||
<table>
|
<%= turbo_frame_tag "emails" do %>
|
||||||
<thead>
|
<%= render partial: "list", object: @emails %>
|
||||||
<tr>
|
<% end %>
|
||||||
<th>Date</th>
|
|
||||||
<th>Subject</th>
|
|
||||||
<th>Metadata</th>
|
|
||||||
<th colspan="3"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
|
|
||||||
<tbody>
|
|
||||||
<% @emails.each do |email| %>
|
|
||||||
<tr>
|
|
||||||
<td><%= email.date %></td>
|
|
||||||
<td><%= email.subject %></td>
|
|
||||||
<td>
|
|
||||||
<% email.organisations.each do |organisation| %>
|
|
||||||
<span class="email_attribute_organisation"><%= organisation %></span>
|
|
||||||
<% end if email.organisations %>
|
|
||||||
<% email.servers.each do |server| %>
|
|
||||||
<span class="email_attribute_server"><%= server %></span>
|
|
||||||
<% end if email.servers %>
|
|
||||||
<% if email.cron? %>
|
|
||||||
<span class="email_attribute_cron">cron</span>
|
|
||||||
<% end %>
|
|
||||||
<% if email.mailing_list? %>
|
|
||||||
<span class="email_attribute_mailing_list">list</span>
|
|
||||||
<% end %>
|
|
||||||
<% if email.junk? %>
|
|
||||||
<span class="email_attribute_junk">junk</span>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
<td><%= link_to 'Show', email %></td>
|
|
||||||
<td><%= link_to 'Edit', edit_email_path(email) %></td>
|
|
||||||
<td><%= link_to 'Destroy', email, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<%= paginate @emails %>
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<%= link_to 'New Email', new_email_path %>
|
|
||||||
|
|
|
@ -1,86 +1,12 @@
|
||||||
<p id="notice"><%= notice %></p>
|
<p id="notice"><%= notice %></p>
|
||||||
|
|
||||||
<div class="email_container">
|
<%= turbo_stream_from @email %>
|
||||||
<table class="email_content">
|
|
||||||
<thead class="email_main_headers">
|
|
||||||
<tr>
|
|
||||||
<th>Date</th>
|
|
||||||
<td><%= @email.date %></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>From</th>
|
|
||||||
<td><%= @email.from.join(', ') %></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>To</th>
|
|
||||||
<td><%= @email.to.join(', ') %></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>Delivered-To</th>
|
|
||||||
<td><%= @email.delivered_to.join(', ') %></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>Subject</th>
|
|
||||||
<td><%= @email.subject %></td>
|
|
||||||
</tr>
|
|
||||||
<% if @email.organisations.present? %>
|
|
||||||
<tr>
|
|
||||||
<th>Clients</th>
|
|
||||||
<td>
|
|
||||||
<% @email.organisations.presence.each do |organisation| %>
|
|
||||||
<span class="email_attribute_organisation"><%= organisation %></span>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
<% if @email.servers.present? %>
|
|
||||||
<tr>
|
|
||||||
<th>Servers</th>
|
|
||||||
<td>
|
|
||||||
<% @email.servers.presence.each do |server| %>
|
|
||||||
<span class="email_attribute_server"><%= server %></span>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
<% if @email.issues.present? %>
|
|
||||||
<tr>
|
|
||||||
<th>Issues</th>
|
|
||||||
<td>
|
|
||||||
<% @email.issues.presence.each do |issue| %>
|
|
||||||
<span class="email_attribute_issue"><%= issue %></span>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
<tr>
|
|
||||||
<th>From Cron</th>
|
|
||||||
<td>
|
|
||||||
<span class="<%= @email.cron? ? "email_attribute_cron" : "" %>"><%= @email.cron? ? "Yes" : "No" %></span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<thead class="email_additional_headers">
|
|
||||||
<% @email.headers.each do |header| %>
|
|
||||||
<tr>
|
|
||||||
<th><%= header["name"] %></th>
|
|
||||||
<td><%= header["value"] %><td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td colspan="2">
|
|
||||||
<% if @email.plain_body.present? %>
|
|
||||||
<pre><%= @email.plain_body %></pre>
|
|
||||||
<% else %>
|
|
||||||
<i>Empty body</i>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<%= link_to 'Edit', edit_email_path(@email) %> |
|
<%= turbo_frame_tag "room" do %>
|
||||||
<%= link_to 'Back', emails_path %>
|
<%= render @email %>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<%= link_to 'Edit', edit_email_path(@email) %> |
|
||||||
|
<%= link_to 'Back', emails_path, "data-turbo-frame": "_top" %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<%= Time.now %>
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue