diff --git a/app/controllers/admin/communication/website/posts_controller.rb b/app/controllers/admin/communication/website/posts_controller.rb index ed5450d9ec3fe49abbc8296a3c86083a16973ed5..ef53b51ce0fd32a76a5d89d903c3a69c2882b652 100644 --- a/app/controllers/admin/communication/website/posts_controller.rb +++ b/app/controllers/admin/communication/website/posts_controller.rb @@ -57,6 +57,6 @@ class Admin::Communication::Website::PostsController < Admin::Communication::Web def post_params params.require(:communication_website_post) - .permit(:university_id, :website_id, :title, :description, :text, :published, :published_at) + .permit(:university_id, :website_id, :title, :description, :text, :published, :published_at, :featured_image, :featured_image_delete) end end diff --git a/app/views/admin/communication/website/posts/_form.html.erb b/app/views/admin/communication/website/posts/_form.html.erb index f029d406f0f2957bcb7dbcb31b8a5d38077b6fab..7096f6dab592a8e43cc9220a7f0a5c4793774cad 100644 --- a/app/views/admin/communication/website/posts/_form.html.erb +++ b/app/views/admin/communication/website/posts/_form.html.erb @@ -20,7 +20,20 @@ <div class="card-body"> <%= f.input :published %> <%= f.input :published_at, html5: true %> - <%= f.input :featured_image %> + </div> + </div> + <div class="card flex-fill w-100"> + <div class="card-header"> + <h5 class="card-title mb-0"><%= t('activerecord.attributes.communication/website/post.featured_image') %></h5> + </div> + <div class="card-body"> + <%= f.input :featured_image, + as: :single_deletable_file, + direct_upload: true, + label: false, + input_html: { accept: '.jpg,.jpeg,.png' }, + preview: true + %> </div> </div> </div> diff --git a/app/views/admin/communication/website/posts/show.html.erb b/app/views/admin/communication/website/posts/show.html.erb index 9f7ff79dfa378699e39404d99dee1b99097a554a..62ab8733071f7d8a1722f2193fae92b28d8ef3fe 100644 --- a/app/views/admin/communication/website/posts/show.html.erb +++ b/app/views/admin/communication/website/posts/show.html.erb @@ -26,16 +26,17 @@ <table class="<%= table_classes %>"> <tbody> <tr> - <td width="150"><%= Communication::Website::Page.human_attribute_name('slug') %></td> + <td width="150"><%= Communication::Website::Post.human_attribute_name('slug') %></td> <td><%= @post.slug %></td> </tr> <tr> - <td><%= Communication::Website::Page.human_attribute_name('published_at') %></td> - <td><%= l @post.published_at, format: :long if @post.published_at %></td> - </tr> - <tr> - <td><%= Communication::Website::Page.human_attribute_name('published') %></td> - <td><%= t @post.published %></td> + <td><%= Communication::Website::Post.human_attribute_name('published') %></td> + <td> + <%= t @post.published %> + <% if @post.published & @post.published_at %> + <p><small><%= l @post.published_at, format: :long if @post.published_at %></small></p> + <% end %> + </td> </tr> <% if @post.imported_post %> <tr> @@ -43,15 +44,19 @@ <td><a href="<%= @post.imported_post.url %>" target="_blank">Original URL</a></td> </tr> <% end %> - <% if @post.featured_image.attached? %> - <tr> - <td><%= t('communication.website.imported.featured_image') %></td> - <td><%= image_tag @post.featured_image.variant(resize: '400'), class: 'img-responsive' %></td> - </tr> - <% end %> </tbody> </table> </div> + <% if @post.featured_image.attached? %> + <div class="card flex-fill w-100"> + <div class="card-header"> + <h5 class="card-title mb-0"><%= t('activerecord.attributes.communication/website/post.featured_image') %></h5> + </div> + <div class="card-body"> + <%= image_tag @post.featured_image.variant(resize: '400'), class: 'img-fluid' %> + </div> + </div> + <% end %> </div> </div> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index ae2c0416a935ecbdb37f73ccbc9da04bbc7c0c52..e9d5e749ce9789e0c4e605a6a7ad4e72a420478b 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -52,6 +52,7 @@ en: communication/website/post: title: Title description: Description (SEO) + featured_image: Featured image text: Text published: Published ? published_at: Publication date diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 9ba816755606a7d15353ce07450acac0ccdc0d44..6b73c1ed7dee99d47db7c36cf46a2582b527ae9f 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -51,6 +51,7 @@ fr: website: Site Web communication/website/post: description: Description (SEO) + featured_image: Image à la une published: Publié ? published_at: Date de publication text: Texte