diff --git a/app/controllers/admin/communication/websites_controller.rb b/app/controllers/admin/communication/websites_controller.rb index 66cff8d0661bb0171f51bf64488eea16c95d8b35..48bf0cbcdc7abe68f13d9c8f123302ab2cacfd4b 100644 --- a/app/controllers/admin/communication/websites_controller.rb +++ b/app/controllers/admin/communication/websites_controller.rb @@ -22,6 +22,7 @@ class Admin::Communication::WebsitesController < Admin::Communication::Applicati @imported_website = @website.imported_website @imported_pages = @imported_website.pages.page params[:pages_page] @imported_posts = @imported_website.posts.page params[:posts_page] + @imported_categories = @imported_website.categories @imported_media = @imported_website.media.includes(file_attachment: :blob ).page params[:media_page] @imported_media_total_size = @imported_website.media.joins(file_attachment: :blob).sum(:byte_size) breadcrumb diff --git a/app/models/communication/website/category.rb b/app/models/communication/website/category.rb index 23b4e519bada11be211638cedc92f836e1bf9cd8..108c7e5fcee44c4ed9b096cd33b1d9266343d822 100644 --- a/app/models/communication/website/category.rb +++ b/app/models/communication/website/category.rb @@ -36,7 +36,8 @@ class Communication::Website::Category < ApplicationRecord optional: true has_many :children, class_name: 'Communication::Website::Category', - foreign_key: :parent_id + foreign_key: :parent_id, + dependent: :destroy has_and_belongs_to_many :posts, class_name: 'Communication::Website::Post', join_table: 'communication_website_categories_posts', diff --git a/app/views/admin/communication/websites/import.html.erb b/app/views/admin/communication/websites/import.html.erb index 0274d1e7abccbe17f75cb18e6154133d6327e82f..0510ac65e070d605219d95b9070dc067d7b9d078 100644 --- a/app/views/admin/communication/websites/import.html.erb +++ b/app/views/admin/communication/websites/import.html.erb @@ -103,3 +103,31 @@ <%= paginate @imported_media, param_name: :media_page, theme: 'bootstrap-5' %> </div> </div> + +<div class="card mt-5"> + <div class="card-header"> + <h2><%= @imported_categories.count %> categories</h2> + </div> + <table class="<%= table_classes %>"> + <thead> + <tr> + <th><%= Communication::Website::Category.human_attribute_name('name') %></th> + <th><%= Communication::Website::Imported::Category.human_attribute_name('original') %></th> + <th class="text-end" width="150"> </th> + </tr> + </thead> + <tbody> + <% @imported_categories.each do |category| %> + <tr> + <td><%= category.name %></td> + <td class="small"><%= link_to category.url, category.url, target: :_blank %></td> + <td class="text-end"> + <%= link_to t('show'), + admin_communication_website_category_path(website_id: category.category.website.id, id: category.category.id), + class: button_classes %> + </td> + </tr> + <% end %> + </tbody> + </table> +</div> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 6d084a518683b316cf5859c7cf348db2166899f5..0805e93a70dfdb3a057e729a997a7dd3fe8da131 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -52,13 +52,15 @@ en: communication/website/category: children: Children categories description: Description + name: Name parent: Parent category slug: slug - title: Title + communication/website/imported/category: + original: Original communication/website/imported/medium: filename: Filename communication/website/page: - children: Children pages + children: Children pages title: Title description: Description (SEO) featured_image: Featured image diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 05b42a0f2ed3a2efe330b0fe1318aaea7ef9646f..341b927163c7485be7369432bd5dc563b897c989 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -51,9 +51,11 @@ fr: communication/website/category: children: Catégories enfantes description: Description + name: Nom parent: Catégorie parente slug: slug - title: Titre + communication/website/imported/category: + original: Original communication/website/imported/medium: filename: Nom du fichier communication/website/page: