From ef8392047981ebb62b08da4829d7b85bc6c86282 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Sun, 31 Jan 2021 12:34:01 +0100 Subject: [PATCH] Extraction de partiels et activiation des turbo-frames sur la liste --- app/models/email.rb | 1 + app/views/emails/_email.html.erb | 81 +++++++++++++++++++++++ app/views/emails/_list.html.erb | 41 ++++++++++++ app/views/emails/index.html.erb | 48 +------------- app/views/emails/show.html.erb | 92 +++----------------------- app/views/layouts/application.html.erb | 1 + 6 files changed, 136 insertions(+), 128 deletions(-) create mode 100644 app/views/emails/_email.html.erb create mode 100644 app/views/emails/_list.html.erb diff --git a/app/models/email.rb b/app/models/email.rb index 7cf1aa1..71e119d 100644 --- a/app/models/email.rb +++ b/app/models/email.rb @@ -18,6 +18,7 @@ class Email < ApplicationRecord validates :from, presence: true validates :headers, presence: true + paginates_per 10 def postponed? postponed_until.present? && postponed_until > DateTime.now diff --git a/app/views/emails/_email.html.erb b/app/views/emails/_email.html.erb new file mode 100644 index 0000000..d863ce0 --- /dev/null +++ b/app/views/emails/_email.html.erb @@ -0,0 +1,81 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + <% if email.organisations.present? %> + + + + + <% end %> + <% if email.servers.present? %> + + + + + <% end %> + <% if email.issues.present? %> + + + + + <% end %> + + + + + + + <% email.headers.each do |header| %> + + + + <% end %> + + + + + + + +
diff --git a/app/views/emails/_list.html.erb b/app/views/emails/_list.html.erb new file mode 100644 index 0000000..93dae40 --- /dev/null +++ b/app/views/emails/_list.html.erb @@ -0,0 +1,41 @@ + + + + + + + + + + + + <% @emails.each do |email| %> + + + + + + + + + <% end %> + +
DateSubjectMetadata
<%= email.date %><%= email.subject %> + <% email.organisations.each do |organisation| %> + + <% end if email.organisations %> + <% email.servers.each do |server| %> + + <% end if email.servers %> + <% if email.cron? %> + + <% end %> + <% if email.mailing_list? %> + + <% end %> + <% if email.junk? %> + + <% end %> + <%= link_to 'Show', email, "data-turbo-frame": "_top" %><%= link_to 'Edit', edit_email_path(email), "data-turbo-frame": "_top" %><%= link_to 'Destroy', email, method: :delete, data: { confirm: 'Are you sure?' }, "data-turbo-frame": "_top" %>
+ +<%= paginate @emails %> diff --git a/app/views/emails/index.html.erb b/app/views/emails/index.html.erb index c1dd363..8a1c6e1 100644 --- a/app/views/emails/index.html.erb +++ b/app/views/emails/index.html.erb @@ -2,48 +2,6 @@

Emails

- - - - - - - - - - - - <% @emails.each do |email| %> - - - - - - - - - <% end %> - -
DateSubjectMetadata
<%= email.date %><%= email.subject %> - <% email.organisations.each do |organisation| %> - - <% end if email.organisations %> - <% email.servers.each do |server| %> - - <% end if email.servers %> - <% if email.cron? %> - - <% end %> - <% if email.mailing_list? %> - - <% end %> - <% if email.junk? %> - - <% end %> - <%= link_to 'Show', email %><%= link_to 'Edit', edit_email_path(email) %><%= link_to 'Destroy', email, method: :delete, data: { confirm: 'Are you sure?' } %>
- -<%= paginate @emails %> - -
- -<%= link_to 'New Email', new_email_path %> +<%= turbo_frame_tag "emails" do %> + <%= render partial: "list", object: @emails %> +<% end %> diff --git a/app/views/emails/show.html.erb b/app/views/emails/show.html.erb index 3db9df7..0087258 100644 --- a/app/views/emails/show.html.erb +++ b/app/views/emails/show.html.erb @@ -1,86 +1,12 @@

<%= notice %>

-
- - - - - - - - - - - - - - - - - - - - - - - <% if @email.organisations.present? %> - - - - - <% end %> - <% if @email.servers.present? %> - - - - - <% end %> - <% if @email.issues.present? %> - - - - - <% end %> - - - - - - - <% @email.headers.each do |header| %> - - - - <% end %> - - - - - - - -
+<%= turbo_stream_from @email %> -<%= link_to 'Edit', edit_email_path(@email) %> | -<%= link_to 'Back', emails_path %> +<%= turbo_frame_tag "room" do %> + <%= render @email %> + +

+ <%= link_to 'Edit', edit_email_path(@email) %> | + <%= link_to 'Back', emails_path, "data-turbo-frame": "_top" %> +

+<% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index bec6236..f5a8b3e 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -14,6 +14,7 @@ + <%= Time.now %> <%= yield %>