diff --git a/app/controllers/admin/communication/extranets/posts/categories_controller.rb b/app/controllers/admin/communication/extranets/posts/categories_controller.rb index e4180f3bd1e1dac519402cf76a13aab798361d25..d86b9fba380bfad2a8999c501b6b7525b11921f1 100644 --- a/app/controllers/admin/communication/extranets/posts/categories_controller.rb +++ b/app/controllers/admin/communication/extranets/posts/categories_controller.rb @@ -1,7 +1,8 @@ class Admin::Communication::Extranets::Posts::CategoriesController < Admin::Communication::Extranets::ApplicationController - load_and_authorize_resource class: Communication::Extranet::Post::Category, through: :extranet + load_and_authorize_resource class: Communication::Extranet::Post::Category, through: :extranet, through_association: :post_categories def index + @categories = @categories.ordered breadcrumb end @@ -10,9 +11,6 @@ class Admin::Communication::Extranets::Posts::CategoriesController < Admin::Comm end def new - if current_user.person.present? - @post.author = current_user.person - end breadcrumb end @@ -31,7 +29,6 @@ class Admin::Communication::Extranets::Posts::CategoriesController < Admin::Comm end def update - @category.add_photo_import params[:photo_import] if @category.update(category_params) redirect_to admin_communication_extranet_post_category_path(@category), notice: t('admin.successfully_updated_html', model: @category.to_s) else @@ -50,6 +47,7 @@ class Admin::Communication::Extranets::Posts::CategoriesController < Admin::Comm def breadcrumb super + add_breadcrumb Communication::Extranet.human_attribute_name(:feature_posts), admin_communication_extranet_posts_path add_breadcrumb Communication::Extranet::Post::Category.model_name.human(count: 2), admin_communication_extranet_post_categories_path breadcrumb_for @category end diff --git a/app/views/admin/communication/extranets/posts/categories/_form.html.erb b/app/views/admin/communication/extranets/posts/categories/_form.html.erb index e82335fbeb15088be8e18bc6e108175dcef5957c..3e20c2e4df27707303dda601a436c1e651de34ad 100644 --- a/app/views/admin/communication/extranets/posts/categories/_form.html.erb +++ b/app/views/admin/communication/extranets/posts/categories/_form.html.erb @@ -1,35 +1,14 @@ -<%= simple_form_for [:admin, post] do |f| %> +<%= simple_form_for [:admin, category] do |f| %> <%= f.error_notification %> <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %> <div class="row"> <div class="col-md-8"> <%= osuny_panel t('content') do %> - <%= f.input :title %> - <%= render 'admin/application/summary/form', f: f, about: post %> + <%= f.input :name %> <% end %> </div> <div class="col-md-4"> - <%= osuny_panel t('metadata') do %> - <% if can? :publish, post %> - <div class="row pure__row--small"> - <div class="col-6"> - <%= f.input :published %> - </div> - </div> - <%= f.input :published_at, html5: true, as: :date %> - <% end %> - <%= f.association :author, - collection: @extranet.connected_persons.ordered, - label_method: :to_s_alphabetical %> - <%= f.input :slug, - as: :string, - input_html: post.persisted? ? {} : { - class: 'js-slug-input', - data: { source: '#communication_extranet_post_title' } - } %> - <% end %> - <%= render 'admin/application/featured_image/edit', about: @post, f: f %> </div> </div> <% content_for :action_bar_right do %> diff --git a/app/views/admin/communication/extranets/posts/categories/_list.html.erb b/app/views/admin/communication/extranets/posts/categories/_list.html.erb index 461b8086a281ff598ae27e85899c4ae4851b3366..e553d2d004b953398e638b9bd1ff4a7b67a2efa5 100644 --- a/app/views/admin/communication/extranets/posts/categories/_list.html.erb +++ b/app/views/admin/communication/extranets/posts/categories/_list.html.erb @@ -14,13 +14,13 @@ <td> <div class="btn-group" role="group"> <%= link_to t('edit'), - edit_admin_communication_extranet_post_path(website_id: post.extranet.id, id: post.id), - class: button_classes if can?(:update, post) %> + edit_admin_communication_extranet_post_category_path(website_id: category.id, id: category.id), + class: button_classes if can?(:update, category) %> <%= link_to t('delete'), - admin_communication_extranet_post_path(extranet_id: post.extranet.id, id: post.id), + admin_communication_extranet_post_category_path(extranet_id: category.extranet.id, id: category.id), method: :delete, data: { confirm: t('please_confirm') }, - class: button_classes_danger if can?(:destroy, post) %> + class: button_classes_danger if can?(:destroy, category) %> </div> </td> </tr> diff --git a/app/views/admin/communication/extranets/posts/categories/edit.html.erb b/app/views/admin/communication/extranets/posts/categories/edit.html.erb index 834ab342d7f5e13313cf8ebb245946da21961cfc..213c0056b51e4ccbfb3ed8619a16bf3b0af53ef7 100644 --- a/app/views/admin/communication/extranets/posts/categories/edit.html.erb +++ b/app/views/admin/communication/extranets/posts/categories/edit.html.erb @@ -1,5 +1,5 @@ -<% content_for :title, @post %> +<% content_for :title, @category %> <%= render 'admin/communication/extranets/sidebar' do %> - <%= render 'form', post: @post %> + <%= render 'form', category: @category %> <% end %> diff --git a/app/views/admin/communication/extranets/posts/categories/new.html.erb b/app/views/admin/communication/extranets/posts/categories/new.html.erb index 90355fd68bb218aa81575b670ee4c2270682efee..dffe93cc2bb91a5bb9d56144cb362177247fb42d 100644 --- a/app/views/admin/communication/extranets/posts/categories/new.html.erb +++ b/app/views/admin/communication/extranets/posts/categories/new.html.erb @@ -1,5 +1,5 @@ -<% content_for :title, Communication::Extranet::Post.model_name.human %> +<% content_for :title, Communication::Extranet::Post::Category.model_name.human %> <%= render 'admin/communication/extranets/sidebar' do %> - <%= render 'form', post: @post %> + <%= render 'form', category: @category %> <% end %> diff --git a/app/views/admin/communication/extranets/posts/categories/show.html.erb b/app/views/admin/communication/extranets/posts/categories/show.html.erb index ad9c804d175b4e4646f32224c592078f240ca9f0..de73ef2f7ac1c40360ebfb669fead139480a09a4 100644 --- a/app/views/admin/communication/extranets/posts/categories/show.html.erb +++ b/app/views/admin/communication/extranets/posts/categories/show.html.erb @@ -1,47 +1,18 @@ -<% content_for :title, @post %> +<% content_for :title, @category %> <%= render 'admin/communication/extranets/sidebar' do %> <div class="row"> <div class="col-xl-8"> - <%= render 'admin/application/summary/show', about: @post %> - <%= render 'admin/communication/blocks/list', about: @post %> </div> <div class="col-xl-4"> - <% - action = '' - action += link_to t('open'), - posts_communication_extranet_post_url(@post.slug, host: @post.extranet.url, extranet_id: nil), - target: :_blank, - class: 'btn btn-light btn-xs' if @post.published - %> - <%= osuny_panel t('metadata'), action: action do %> - <div class="row pure__row--small"> - <div class="col-6"> - <%= osuny_label Communication::Extranet::Post.human_attribute_name('published') %> - <p> - <%= t @post.published %><% if @post.published & @post.published_at %>, - <%= l @post.published_at.to_date, format: :long if @post.published_at %> - <% end %> - </p> - </div> - </div> - <% if @post.author %> - <%= osuny_label Communication::Extranet::Post.human_attribute_name('author') %> - <p><%= @post.author %></p> - <% end %> - <%= osuny_label Communication::Extranet::Post.human_attribute_name('slug') %> - <p><%= @post.slug %></p> - <% end %> - <%= render 'admin/application/featured_image/show', about: @post %> </div> </div> <% end %> <% content_for :action_bar_left do %> - <%= destroy_link @post %> + <%= destroy_link @category %> <% end %> <% content_for :action_bar_right do %> - <%= preview_link %> - <%= edit_link @post %> + <%= edit_link @category %> <% end %> diff --git a/app/views/admin/communication/extranets/posts/index.html.erb b/app/views/admin/communication/extranets/posts/index.html.erb index ea6456ecdbbe5c026a56c6001dc4a5d73a79d960..cbf3d5fdf58b1c078afbc51d21172c1a77405044 100644 --- a/app/views/admin/communication/extranets/posts/index.html.erb +++ b/app/views/admin/communication/extranets/posts/index.html.erb @@ -6,7 +6,8 @@ <%= paginate @posts, theme: 'bootstrap-5' %> </section> - <% action = link_to t('create'), new_admin_communication_extranet_posts_category_path, class: button_classes %> + <% action = link_to t('create'), new_admin_communication_extranet_post_category_path, class: button_classes %> + <%# action = create_link Communication::Website::Category %> <%= osuny_panel Communication::Website::Category.model_name.human(count: 2), action: action do %> <%= render 'admin/communication/extranets/posts/categories/list', categories: @categories %> <% end %> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 11977d24430a10666ecdd0061ebc4734d135818a..b3f982592507509884c520b7f7baed84efcc2b14 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -19,6 +19,9 @@ en: one: Post other: Posts all: All posts + communication/extranet/post/category: + one: Category + other: Categories communication/website: one: Website other: Websites @@ -94,6 +97,8 @@ en: published_at: Publication date slug: Slug title: Title + communication/extranet/post/category: + name: Name communication/website: about: About about_: Independent website diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index d6224c02806ac435dc803b6ffeba3e47f6631929..f0ce1b4830ebcfe55f8adc243ee4a01229a657e6 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -19,6 +19,9 @@ fr: one: Actualité other: Actualités all: Toutes les actualités + communication/extranet/post/category: + one: Catégorie + other: Catégories communication/website: one: Site Web other: Sites Web @@ -94,6 +97,8 @@ fr: published_at: Date de publication slug: Identifiant title: Titre + communication/extranet/post/category: + name: Nom communication/website: about: Sujet du site about_: Site indépendant diff --git a/config/routes/admin/communication.rb b/config/routes/admin/communication.rb index 41481b3c1066f5f5bc37d27fdb306e7f0e95e5c0..5db6d8e7f5f1afcaa5be3d48e3afd530010e5dee 100644 --- a/config/routes/admin/communication.rb +++ b/config/routes/admin/communication.rb @@ -74,9 +74,11 @@ namespace :communication do end end namespace :posts do - resources :categories, controller: 'extranets/posts/categories' end resources :posts, controller: 'extranets/posts' do + collection do + resources :categories, controller: 'extranets/posts/categories', as: 'post_categories' + end member do get :preview end