diff --git a/app/assets/stylesheets/admin/commons/table.sass b/app/assets/stylesheets/admin/commons/table.sass index 509bff9c9fc776c3d195eecd85d08be267960f46..4539feb70afb04fa0873fd2164bb86604f9b6d45 100644 --- a/app/assets/stylesheets/admin/commons/table.sass +++ b/app/assets/stylesheets/admin/commons/table.sass @@ -6,4 +6,11 @@ td:last-of-type, th:last-of-type padding-right: 0 - text-align: right \ No newline at end of file + text-align: right +.table-selectable + overflow-x: visible + table + margin-left: -25px + th:first-of-type, + td:first-of-type + width: 25px \ No newline at end of file diff --git a/app/controllers/admin/communication/websites/menus_controller.rb b/app/controllers/admin/communication/websites/menus_controller.rb index 6294e26bc13a2902d6e4df8a0047af3e5137ba99..441bbd9987c6aa6991a6d4760ef9bbe28454ea61 100644 --- a/app/controllers/admin/communication/websites/menus_controller.rb +++ b/app/controllers/admin/communication/websites/menus_controller.rb @@ -4,7 +4,7 @@ class Admin::Communication::Websites::MenusController < Admin::Communication::We include Admin::Translatable def index - @menus = @menus.for_language(current_website_language).ordered.page(params[:page]) + @menus = @menus.for_language(current_website_language).ordered breadcrumb end diff --git a/app/controllers/admin/communication/websites/pages_controller.rb b/app/controllers/admin/communication/websites/pages_controller.rb index c99e344ddcb8420035192c9ac9ff8193b2eea971..8c665fbfb4dcb3f883d0de0dd5149ed7d32bc9a5 100644 --- a/app/controllers/admin/communication/websites/pages_controller.rb +++ b/app/controllers/admin/communication/websites/pages_controller.rb @@ -4,7 +4,18 @@ class Admin::Communication::Websites::PagesController < Admin::Communication::We include Admin::Translatable + has_scope :for_search_term + has_scope :for_published + has_scope :for_full_width + def index + @pages = apply_scopes(@pages).for_language(current_website_language) + .ordered + .page(params[:page]) + breadcrumb + end + + def tree @homepage = @website.special_page(Communication::Website::Page::Home, language: current_website_language) @first_level_pages = @homepage.children.ordered @pages = @website.pages.for_language(current_website_language) diff --git a/app/helpers/admin/application_helper.rb b/app/helpers/admin/application_helper.rb index 78e5719184cb6e56db98526aba9478fe75239c62..07e0aad316697e45d572dc8f3f26ac53c1595160 100644 --- a/app/helpers/admin/application_helper.rb +++ b/app/helpers/admin/application_helper.rb @@ -48,7 +48,7 @@ module Admin::ApplicationHelper end def preview_link - raw "<button class=\"btn btn-primary btn-xs\" + raw "<button class=\"btn btn-light btn-xs\" type=\"button\" data-bs-toggle=\"modal\" data-bs-target=\"#preview\" diff --git a/app/models/communication/website/page.rb b/app/models/communication/website/page.rb index d61dff08e4dacf04feaae9b215c021bfd2bdc7f0..148457ed46487c643e238acfb7d79ab7e7d0d01b 100644 --- a/app/models/communication/website/page.rb +++ b/app/models/communication/website/page.rb @@ -87,7 +87,18 @@ class Communication::Website::Page < ApplicationRecord scope :recent, -> { order(updated_at: :desc).limit(5) } scope :published, -> { where(published: true) } - + scope :ordered, -> { order(:title) } + + scope :for_search_term, -> (term) { + where(" + unaccent(communication_website_pages.meta_description) ILIKE unaccent(:term) OR + unaccent(communication_website_pages.summary) ILIKE unaccent(:term) OR + unaccent(communication_website_pages.title) ILIKE unaccent(:term) + ", term: "%#{sanitize_sql_like(term)}%") + } + scope :for_published, -> (published) { where(published: published == 'true') } + scope :for_full_width, -> (full_width) { where(full_width: full_width == 'true') } + def template_static "admin/communication/websites/pages/static" end diff --git a/app/services/filters/admin/communication/websites/pages.rb b/app/services/filters/admin/communication/websites/pages.rb new file mode 100644 index 0000000000000000000000000000000000000000..5633d1f6a8829045e3f1735e4a808423a933dc94 --- /dev/null +++ b/app/services/filters/admin/communication/websites/pages.rb @@ -0,0 +1,20 @@ +module Filters + class Admin::Communication::Websites::Pages < Filters::Base + def initialize(user) + super(user) + add_search + add :for_published, + [{ to_s: I18n.t('true'), id: 'true' }, { to_s: I18n.t('false'), id: 'false' }], + I18n.t( + 'filters.attributes.element', + element: I18n.t('admin.communication.website.pages.published_status').downcase + ) + add :for_full_width, + [{ to_s: I18n.t('true'), id: 'true' }, { to_s: I18n.t('false'), id: 'false' }], + I18n.t( + 'filters.attributes.element', + element: I18n.t('admin.communication.website.pages.full_width_status').downcase + ) + end + end +end diff --git a/app/views/admin/communication/websites/menus/_list.html.erb b/app/views/admin/communication/websites/menus/_list.html.erb index f372f34de3d0649e17004bb6169e11527f87b0ab..ff02d372bed2dd8ae25289224e89972145a40336 100644 --- a/app/views/admin/communication/websites/menus/_list.html.erb +++ b/app/views/admin/communication/websites/menus/_list.html.erb @@ -3,16 +3,14 @@ <thead> <tr> <th><%= Communication::Website::Menu.human_attribute_name('title') %></th> - <th><%= Communication::Website::Menu.human_attribute_name('items') %></th> - <th></th> <th></th> + <th><%= Communication::Website::Menu.human_attribute_name('items') %></th> </tr> </thead> <tbody> <% menus.each do |menu| %> <tr> <td><%= link_to menu, admin_communication_website_menu_path(website_id: menu.website.id, id: menu.id) %></td> - <td><%= menu.items.count %></td> <td> <% if menu.automatic %> <span class="badge bg-success"> @@ -20,18 +18,7 @@ </span> <% end %> </td> - <td> - <div class="btn-group" role="group"> - <%= link_to t('edit'), - edit_admin_communication_website_menu_path(website_id: menu.website.id, id: menu.id), - class: button_classes if can?(:update, menu) %> - <%= link_to t('delete'), - admin_communication_website_menu_path(website_id: menu.website.id, id: menu.id), - method: :delete, - data: { confirm: t('please_confirm') }, - class: button_classes_danger if can?(:destroy, menu) %> - </div> - </td> + <td><%= menu.items.count %></td> </tr> <% end %> </tbody> diff --git a/app/views/admin/communication/websites/menus/index.html.erb b/app/views/admin/communication/websites/menus/index.html.erb index b44d69ac87e62053aa4f131124c71f59ab0b3779..25d77adc2ce65c80a92b62425f09d71528e819e7 100644 --- a/app/views/admin/communication/websites/menus/index.html.erb +++ b/app/views/admin/communication/websites/menus/index.html.erb @@ -1,4 +1,4 @@ -<% content_for :title, "#{Communication::Website::Menu.model_name.human(count: 2)}" %> +<% content_for :title, Communication::Website::Menu.model_name.human(count: 2) %> <% content_for :title_right do %> <%= @menus.count %> @@ -6,12 +6,8 @@ <% end %> <%= render 'admin/communication/websites/sidebar' do %> - <%= render 'admin/communication/websites/menus/list', menus: @menus %> - <% if @menus.total_pages > 1 %> - <%= paginate @menus, theme: 'bootstrap-5' %> + <% osuny_panel Communication::Website::Menu.model_name.human(count: 2), + action: create_link(Communication::Website::Menu) do %> + <%= render 'admin/communication/websites/menus/list', menus: @menus %> <% end %> <% end %> - -<% content_for :action_bar_right do %> - <%= create_link Communication::Website::Menu %> -<% end %> diff --git a/app/views/admin/communication/websites/menus/items/_treebranch.html.erb b/app/views/admin/communication/websites/menus/items/_treebranch.html.erb index cd2b795c0114cdfa1c13ac8229c5e1827e42fe7f..3f2213b5a8cfa5fa4998170a6ca136918eba35b0 100644 --- a/app/views/admin/communication/websites/menus/items/_treebranch.html.erb +++ b/app/views/admin/communication/websites/menus/items/_treebranch.html.erb @@ -5,7 +5,7 @@ class: 'js-treeview-openzone d-inline-block p-2 ps-0', style: 'width: 22px', remote: true do %> <%= render 'admin/application/tree/folder' %> <% end %> - <%= link_to_if can?(:read, item), item, admin_communication_website_menu_item_path(website_id: item.website.id, menu_id: item.menu.id, id: item.id) %> + <%= item %> <%= render 'admin/application/tree/sort' %> <%= link_to children_admin_communication_website_menu_item_path(website_id: item.website.id, menu_id: item.menu.id, id: item.id), class: 'js-treeview-openzone small ps-2', remote: true do %> @@ -13,14 +13,12 @@ <span class="close_text"><%= t 'folder.close' %></span> <% end %> <div class="btn-group ms-auto" role="group"> + <%= link_to t('show'), + admin_communication_website_menu_item_path(website_id: item.website.id, menu_id: item.menu.id, id: item.id), + class: 'ps-3' %> <%= link_to t('edit'), edit_admin_communication_website_menu_item_path(website_id: item.website.id, menu_id: item.menu.id, id: item.id), - class: button_classes if can?(:edit, item) %> - <%= link_to t('delete'), - admin_communication_website_menu_item_path(website_id: item.website.id, menu_id: item.menu.id, id: item.id), - method: :delete, - data: { confirm: t('please_confirm') }, - class: button_classes_danger if can?(:destroy, item) %> + class: 'ps-3' %> </div> </div> <ul class="list-unstyled treeview__children js-treeview-children <%= 'js-treeview-sortable-container' if can?(:reorder, item) %> ms-4" data-id="<%= item.id %>"> diff --git a/app/views/admin/communication/websites/menus/items/show.html.erb b/app/views/admin/communication/websites/menus/items/show.html.erb index 33673d2b6bc600ab0b12d1db05787b97a81ca252..0c0476a28b7b33b36ff0cd342829989982106664 100644 --- a/app/views/admin/communication/websites/menus/items/show.html.erb +++ b/app/views/admin/communication/websites/menus/items/show.html.erb @@ -28,6 +28,14 @@ </div> <% end %> +<% content_for :action_bar_left do %> + <%= link_to t('delete'), + admin_communication_website_menu_item_path(website_id: @item.website.id, menu_id: @item.menu.id, id: @item.id), + method: :delete, + data: { confirm: t('please_confirm') }, + class: button_classes_danger if can?(:destroy, @item) %> +<% end %> + <% content_for :action_bar_right do %> <%= link_to t('edit'), edit_admin_communication_website_menu_item_path(@item, website_id: @website, menu_id: @menu.id), diff --git a/app/views/admin/communication/websites/pages/_list.html.erb b/app/views/admin/communication/websites/pages/_list.html.erb index b72267cf6e0fcac22eff405dc425b2272e81bb87..c6ae2e2b731ed857b9f1ce194066c47318da9aba 100644 --- a/app/views/admin/communication/websites/pages/_list.html.erb +++ b/app/views/admin/communication/websites/pages/_list.html.erb @@ -1,25 +1,22 @@ -<% - hide_buttons ||= false -%> <div class="table-responsive"> <table class="<%= table_classes %>"> <thead> <tr> - <th class="ps-0" width="60%"><%= Communication::Website::Page.human_attribute_name('title') %></th> - <th><%= Communication::Website::Page.human_attribute_name('featured_image') %></th> - <th><%= Communication::Website::Page.human_attribute_name('parent') %></th> - <% unless hide_buttons %> - <th width="150"></th> - <% end %> + <th class="ps-0"><%= Communication::Website::Page.human_attribute_name('title') %></th> + <th width="100"><%= Communication::Website::Page.human_attribute_name('featured_image') %></th> + <th width="200"></th> </tr> </thead> <tbody> <% pages.each do |page| %> - <tr> + <tr class="<%= 'draft' unless page.published? %>"> <td class="ps-0"> <%= link_to page, admin_communication_website_page_path(website_id: page.website.id, id: page.id), class: "#{'draft' unless page.published?}" %> + <% if page.ancestors.many? %> + <p class="small text-muted mb-0"><%= page.ancestors.join(' / ') %></p> + <% end %> </td> <td> <% if page.featured_image.attached? && page.featured_image.representable? %> @@ -27,23 +24,12 @@ <% end %> </td> <td> - <%= link_to page.parent, - admin_communication_website_page_path(website_id: page.website.id, id: page.id) if page.parent %> + <% if page.full_width %> + <span class="badge bg-light text-black"> + <%= Communication::Website::Page.human_attribute_name('full_width') %> + </span> + <% end %> </td> - <% unless hide_buttons %> - <td class="text-end pe-0"> - <div class="btn-group" role="group"> - <%= link_to t('edit'), - edit_admin_communication_website_page_path(website_id: page.website.id, id: page.id), - class: button_classes if can?(:update, page) %> - <%= link_to t('delete'), - admin_communication_website_page_path(website_id: page.website.id, id: page.id), - method: :delete, - data: { confirm: page.children.any? ? t('please_confirm_with_children') : t('please_confirm') }, - class: button_classes_danger if can?(:destroy, page) && !page.is_special_page? %> - </div> - </td> - <% end %> </tr> <% end %> </tbody> diff --git a/app/views/admin/communication/websites/pages/_treebranch.html.erb b/app/views/admin/communication/websites/pages/_treebranch.html.erb index 2a479388880de0b48d54d2cb20e0ec9ef16b91a8..1a40c45f77e4ee54c659da05aadfb607f75a257a 100644 --- a/app/views/admin/communication/websites/pages/_treebranch.html.erb +++ b/app/views/admin/communication/websites/pages/_treebranch.html.erb @@ -5,9 +5,7 @@ class: 'js-treeview-openzone d-inline-block p-2 ps-0', style: 'width: 22px', remote: true do %> <%= render 'admin/application/tree/folder' %> <% end %> - <%= link_to page, - admin_communication_website_page_path(website_id: page.website.id, id: page.id), - class: "leaf-title" %> + <%= page %> <%= render 'admin/application/tree/sort' unless page.is_home? %> <%= link_to children_admin_communication_website_page_path(website_id: page.website.id, id: page.id), class: 'js-treeview-openzone small ps-2', remote: true do %> @@ -18,11 +16,9 @@ <% if page.is_special_page? %> <span class="me-3 show-on-hover"><%= t("communication.website.pages.defaults.#{page.type_key}.title") %></span> <% end %> - <div class="btn-group"> - <%= duplicate_link page if page.is_regular_page? %> - <%= link_to t('edit'), edit_admin_communication_website_page_path(page), class: button_classes %> - <%= destroy_link page, confirm_message: page.children.any? ? t('please_confirm_with_children') : t('please_confirm') if page.is_regular_page? %> - </div> + </div> + <div class="btn-group"> + <%= link_to t('admin.communication.website.pages.show'), admin_communication_website_page_path(page) %> </div> </div> <ul class="list-unstyled treeview__children js-treeview-children <%= 'js-treeview-sortable-container' if can?(:reorder, page) %> ms-4" data-id="<%= page.id %>"> diff --git a/app/views/admin/communication/websites/pages/index.html.erb b/app/views/admin/communication/websites/pages/index.html.erb index 70de04929cdef98d39e9ca1713b6779a3bf4bfd7..12b504f7348526ac5e7688ecb1ab8aec4fd22026 100644 --- a/app/views/admin/communication/websites/pages/index.html.erb +++ b/app/views/admin/communication/websites/pages/index.html.erb @@ -1,35 +1,31 @@ <% content_for :title, t('admin.communication.website.pages.structure') %> <% content_for :title_right do %> - <%= @pages.size %> - <%= Communication::Website::Page.model_name.human(count: @pages.size).downcase %> + <%= @pages.total_count %> + <%= Communication::Website::Page.model_name.human(count: @pages.total_count).downcase %> <% end %> <%= render 'admin/communication/websites/sidebar' do %> - <ul class="list-unstyled treeview"> - <li class="treeview__element treeview__element--opened treeview__element--loaded" data-id="<%= @homepage.id %>" data-parent=""> - <div class="d-flex align-items-center treeview__label border-bottom p-1"> - <div class="d-inline-block p-2 ps-0" style="width: 22px"> - <span class="close_btn text-primary"> - <i class="close_btn--with_children <%= Icon::FOLDER_OPENED_FULL %>"></i> - </span> - </div> - <%= link_to @homepage, - admin_communication_website_page_path(website_id: @homepage.website.id, id: @homepage.id) - %> - <div class="btn-group ms-auto" role="group"> - <%= link_to t('edit'), edit_admin_communication_website_page_path(@homepage), class: button_classes %> - </div> - </div> - <ul class="list-unstyled ms-4 treeview__children js-treeview <%= 'treeview--sortable js-treeview-sortable js-treeview-sortable-container' if can?(:reorder, @homepage) %>" - data-id="<%= @homepage.id %>" - data-sort-url="<%= reorder_admin_communication_website_pages_path %>"> - <%= render 'treebranch', pages: @first_level_pages %> - </ul> - </li> - </ul> -<% end %> - -<% content_for :action_bar_right do %> - <%= create_link Communication::Website::Page %> -<% end %> + <% osuny_panel t('admin.communication.website.pages.structure'), + action: create_link(Communication::Website::Page) do %> + <ul class="nav nav-tabs justify-content-md-end mt-0 mt-md-n4"> + <li class="nav-item"> + <a class="nav-link active" aria-current="page"> + <i class="fas fa-list"></i> + <%= t('admin.communication.website.pages.as_list') %> + </a> + </li> + <li class="nav-item"> + <a class="nav-link" href="<%= tree_admin_communication_website_pages_path %>"> + <i class="fas fa-sitemap"></i> + <%= t('admin.communication.website.pages.as_tree') %> + </a> + </li> + </ul> + <div class="position-relative mt-2"> + <%= render 'filters', current_path: admin_communication_website_pages_path, filters: @filters %> + <%= render 'admin/communication/websites/pages/list', pages: @pages %> + <%= paginate @pages, theme: 'bootstrap-5' %> + </div> + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/communication/websites/pages/show.html.erb b/app/views/admin/communication/websites/pages/show.html.erb index 34e2c9deb480fc0c79d1b9b446b2e792b798b42e..e476827977f011c177074ba54edcc284755f728a 100644 --- a/app/views/admin/communication/websites/pages/show.html.erb +++ b/app/views/admin/communication/websites/pages/show.html.erb @@ -31,6 +31,7 @@ <% content_for :action_bar_left do %> <%= destroy_link @page if @page.is_regular_page? %> + <%= duplicate_link @page if @page.is_regular_page? %> <%= static_link static_admin_communication_website_page_path(@page) %> <% end %> diff --git a/app/views/admin/communication/websites/pages/tree.html.erb b/app/views/admin/communication/websites/pages/tree.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..3d52ebfe6f4140ca2229c9048660e930dda811d7 --- /dev/null +++ b/app/views/admin/communication/websites/pages/tree.html.erb @@ -0,0 +1,43 @@ +<% content_for :title, t('admin.communication.website.pages.structure') %> + +<% content_for :title_right do %> + <%= @pages.size %> + <%= Communication::Website::Page.model_name.human(count: @pages.size).downcase %> +<% end %> + +<%= render 'admin/communication/websites/sidebar' do %> + <% osuny_panel t('admin.communication.website.pages.structure'), + action: create_link(Communication::Website::Page) do %> + <ul class="nav nav-tabs justify-content-md-end mt-0 mt-md-n4"> + <li class="nav-item"> + <a class="nav-link" href="<%= admin_communication_website_pages_path %>"> + <i class="fas fa-list"></i> + <%= t('admin.communication.website.pages.as_list') %> + </a> + </li> + <li class="nav-item"> + <a class="nav-link active" aria-current="page"> + <i class="fas fa-sitemap"></i> + <%= t('admin.communication.website.pages.as_tree') %> + </a> + </li> + </ul> + <ul class="list-unstyled treeview"> + <li class="treeview__element treeview__element--opened treeview__element--loaded" data-id="<%= @homepage.id %>" data-parent=""> + <div class="d-flex align-items-center treeview__label border-bottom p-1"> + <div class="d-inline-block p-2 ps-0" style="width: 22px"> + <span class="close_btn text-primary"> + <i class="close_btn--with_children <%= Icon::FOLDER_OPENED_FULL %>"></i> + </span> + </div> + <%= @homepage %> + </div> + <ul class="list-unstyled ms-4 treeview__children js-treeview <%= 'treeview--sortable js-treeview-sortable js-treeview-sortable-container' if can?(:reorder, @homepage) %>" + data-id="<%= @homepage.id %>" + data-sort-url="<%= reorder_admin_communication_website_pages_path %>"> + <%= render 'treebranch', pages: @first_level_pages %> + </ul> + </li> + </ul> + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/communication/websites/posts/_list.html.erb b/app/views/admin/communication/websites/posts/_list.html.erb index 0da0f7042829555e0fc90cab2d5a93edc6d7a9b8..8de554b6e4453990ff37542c1a4131977cf79906 100644 --- a/app/views/admin/communication/websites/posts/_list.html.erb +++ b/app/views/admin/communication/websites/posts/_list.html.erb @@ -1,69 +1,57 @@ <% - hide_author ||= false - hide_category ||= false - hide_buttons ||= false - selectable ||= false +hide_author ||= false +hide_category ||= false +hide_buttons ||= false +selectable ||= false %> <% if selectable %> <input type="hidden" name="ids[]" value=""> <% end %> -<div class="table-responsive"> +<div class="table-responsive <%= 'table-selectable' if selectable %>"> <table class="<%= table_classes %>"> <thead> <tr> <% if selectable %> - <th class="ps-0"> - <%= check_box_tag nil, nil, false, data: { batch_selectable_role: "select-all" } %> + <th class="border-0"> + <%= check_box_tag nil, nil, false, data: { batch_selectable_role: "select-all" } if selectable %> </th> <% end %> <th class="ps-0" width="60%"><%= Communication::Website::Post.human_attribute_name('title') %></th> + <th class="ps-3"><%= Communication::Website::Post.human_attribute_name('meta') %></th> <th><%= Communication::Website::Post.human_attribute_name('featured_image') %></th> - <th<% unless hide_buttons %> colspan="2"<% end %> class="ps-3"><%= Communication::Website::Post.human_attribute_name('meta') %></th> </tr> </thead> <tbody> <% posts.each do |post| %> <tr <% unless post.published? %>class="draft"<% end %>> <% if selectable %> - <td class="ps-0"> - <%= check_box_tag "ids[]", post.id, false, data: { batch_selectable_role: "select-single" } %> - </td> + <td class="border-0"><%= check_box_tag "ids[]", post.id, false, data: { batch_selectable_role: "select-single" } %></td> <% end %> - <td class="ps-0"><%= link_to post, - admin_communication_website_post_path(website_id: post.website.id, id: post.id), - class: "#{'draft' unless post.published?}" %></td> - <td><%= image_tag post.featured_image.representation(resize: '200x'), - width: 100 if post.featured_image.attached? && post.featured_image.representable? %></td> + <td class="ps-0"> + <%= link_to post, + admin_communication_website_post_path(website_id: post.website.id, id: post.id), + class: "#{'draft' unless post.published?}" %> + </td> <td class="ps-3 small"> - <%= l post.published_at, format: :date_with_explicit_month if post.published_at %><br> + <% if post.published_at %> + <%= l post.published_at, format: :date_with_explicit_month %><br> + <% end %> <% if !hide_author && post.author %> - <%= link_to post.author, admin_communication_website_author_path(website_id: post.website.id, id: post.author.id) %><br> + <%= post.author %><br> <% end %> <% unless hide_category %> <ul class="list-unstyled mb-0"> <% post.categories.each do |category| %> - <li><%= link_to_if can?(:read, category), category, admin_communication_website_category_path(website_id: post.website.id, id: category.id), class: 'small' %></li> + <li><%= category %></li> <% end %> </ul> <% end %> <% if post.pinned %> - <span class="badge bg-success"><%= Communication::Website::Post.human_attribute_name('pinned') %></span> + <%= Communication::Website::Post.human_attribute_name('pinned') %> <% end %> </td> - <% unless hide_buttons %> - <td> - <div class="btn-group" role="group"> - <%= link_to t('edit'), - edit_admin_communication_website_post_path(website_id: post.website.id, id: post.id), - class: button_classes if can?(:update, post) %> - <%= link_to t('delete'), - admin_communication_website_post_path(website_id: post.website.id, id: post.id), - method: :delete, - data: { confirm: t('please_confirm') }, - class: button_classes_danger if can?(:destroy, post) %> - </div> - </td> - <% end %> + <td><%= image_tag post.featured_image.representation(resize: '200x'), + width: 100 if post.featured_image.attached? && post.featured_image.representable? %></td> </tr> <% end %> </tbody> diff --git a/app/views/admin/communication/websites/posts/index.html.erb b/app/views/admin/communication/websites/posts/index.html.erb index a007077e007ae5d9bbb0c663268d99c426b474d9..c6c64458d91a39a72a97e5b8d1ea798d241b7ca8 100644 --- a/app/views/admin/communication/websites/posts/index.html.erb +++ b/app/views/admin/communication/websites/posts/index.html.erb @@ -13,9 +13,9 @@ class: button_classes('ms-2 btn-light') if can?(:create, Communication::Website::Post) %> <%= osuny_panel Communication::Website::Post.model_name.human(count: 2), action: action do %> - <%= render 'filters', current_path: admin_communication_website_posts_path, filters: @filters %> <div data-batch-selectable class="mb-5"> <%= form_tag publish_admin_communication_website_posts_path do %> + <%= render 'filters', current_path: admin_communication_website_posts_path, filters: @filters %> <%= render 'admin/communication/websites/posts/list', posts: @posts, selectable: true %> <%= paginate @posts, theme: 'bootstrap-5' %> <div> diff --git a/app/views/admin/communication/websites/show/_pages.html.erb b/app/views/admin/communication/websites/show/_pages.html.erb index 1194a061bddafbb9f21a478a9035d0d4008f1ae7..d7d20872aaea4f8c5adcd145e69071c94e520df5 100644 --- a/app/views/admin/communication/websites/show/_pages.html.erb +++ b/app/views/admin/communication/websites/show/_pages.html.erb @@ -8,5 +8,30 @@ subtitle = link_to t('communication.website.see_all', number: @all_pages.count), <%= osuny_panel t('communication.website.last_pages'), subtitle: subtitle, action: action do %> - <%= render 'admin/communication/websites/pages/list', pages: @pages, hide_buttons: true %> + <div class="table-responsive"> + <table class="<%= table_classes %>"> + <thead> + <tr> + <th class="ps-0"><%= Communication::Website::Page.human_attribute_name('title') %></th> + <th width="100"><%= Communication::Website::Page.human_attribute_name('featured_image') %></th> + </tr> + </thead> + <tbody> + <% @pages.each do |page| %> + <tr class="<%= 'draft' unless page.published? %>"> + <td class="ps-0"> + <%= link_to page, + admin_communication_website_page_path(website_id: page.website.id, id: page.id), + class: "#{'draft' unless page.published?}" %> + </td> + <td> + <% if page.featured_image.attached? && page.featured_image.representable? %> + <%= image_tag page.featured_image.representation(resize: '200x'), width: 100 %> + <% end %> + </td> + </tr> + <% end %> + </tbody> + </table> + </div> <% end %> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index ce3ed16af992f6c863f5f0950e9b1755e5aa7070..d367f86beb6e42a846b2a39d391f87201d480a1a 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -668,8 +668,13 @@ en: placeholder: Enter video title website: pages: + as_list: See as a list + as_tree: Organize structure delete_special_page_notice: Can't delete this page - structure: Structure + full_width_status: Full width + show: Show page + structure: Pages + published_status: Publication status post: pinned_status: Pinned status communication: diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 4d269ddf2be87b72b67fac9e324ed34dec066df7..cf157e7e98a3b4bf2a1d814aa94a3df60990d4ea 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -665,8 +665,13 @@ fr: placeholder: Entrer le titre de la vidéo website: pages: + as_list: Voir en liste + as_tree: Organiser l'arborescence delete_special_page_notice: Impossible de supprimer cette page - structure: Arborescence + full_width_status: Pleine largeur + show: Voir la page + structure: Pages + published_status: État de publication post: pinned_status: Mise en avant communication: diff --git a/config/routes/admin/communication.rb b/config/routes/admin/communication.rb index f448c4dba79c173400f385e5270ce74463ee9344..03c198bee398a7926d380d7c743350a55534db43 100644 --- a/config/routes/admin/communication.rb +++ b/config/routes/admin/communication.rb @@ -16,6 +16,7 @@ namespace :communication do resources :pages, controller: 'websites/pages', path: '/:lang/pages' do collection do post :reorder + get :tree end member do get :children