diff --git a/app/controllers/admin/application_controller.rb b/app/controllers/admin/application_controller.rb index 0e72a394ed8a500d32d61242aaceb3114b457b3b..5ed9a73d73fa8e1c8daccd9e9fa2e0b9ce34d82d 100644 --- a/app/controllers/admin/application_controller.rb +++ b/app/controllers/admin/application_controller.rb @@ -9,6 +9,12 @@ class Admin::ApplicationController < ApplicationController add_breadcrumb t('dashboard'), :admin_root_path end + def short_breadcrumb + @menu_collapsed = true + add_breadcrumb t('dashboard'), :admin_root_path + add_breadcrumb '...' + end + def breadcrumb_for(object, **options) return unless object object.persisted? ? add_breadcrumb(object, [:admin, object, options]) diff --git a/app/controllers/admin/communication/website/application_controller.rb b/app/controllers/admin/communication/website/application_controller.rb index ebf2579c9822540259e0eb4fa2066a43431ee924..351e872c3d844f2c3ad9e6936ade85508d792d86 100644 --- a/app/controllers/admin/communication/website/application_controller.rb +++ b/app/controllers/admin/communication/website/application_controller.rb @@ -4,8 +4,7 @@ class Admin::Communication::Website::ApplicationController < Admin::Communicatio protected def breadcrumb - add_breadcrumb t('dashboard'), :admin_root_path - add_breadcrumb '...' + short_breadcrumb breadcrumb_for @website, website_id: nil end diff --git a/app/controllers/admin/research/journal/application_controller.rb b/app/controllers/admin/research/journal/application_controller.rb index 43064c7e660f1a4d38676e2978438a533fc63288..a4365619e623fa21d840e35e3e709942f152c64c 100644 --- a/app/controllers/admin/research/journal/application_controller.rb +++ b/app/controllers/admin/research/journal/application_controller.rb @@ -4,8 +4,7 @@ class Admin::Research::Journal::ApplicationController < Admin::Research::Applica protected def breadcrumb - add_breadcrumb t('dashboard'), :admin_root_path - add_breadcrumb '...' + short_breadcrumb breadcrumb_for @journal, journal_id: nil end diff --git a/app/models/communication/website/page.rb b/app/models/communication/website/page.rb index 114d2e4d3ea927b7120c59b8d28afd4a3174bbd9..fe2dbca5b7431bf89f5f571e9fca5743479fa4dc 100644 --- a/app/models/communication/website/page.rb +++ b/app/models/communication/website/page.rb @@ -43,6 +43,7 @@ class Communication::Website::Page < ApplicationRecord after_save :publish_to_github scope :ordered, -> { order(:path) } + scope :recent, -> { order(updated_at: :desc).limit(10) } def content @content ||= github.read_file_at "_pages/#{id}.html" diff --git a/app/views/admin/application/_nav.html.erb b/app/views/admin/application/_nav.html.erb index 00d41bb7c8f0e7d4bee127d8320bd0100693b95d..d29518d0eb758811fc9bc34589dc8d3211ad8760 100644 --- a/app/views/admin/application/_nav.html.erb +++ b/app/views/admin/application/_nav.html.erb @@ -1,4 +1,4 @@ -<nav id="sidebar" class="sidebar"> +<nav id="sidebar" class="sidebar<%= ' collapsed' if @menu_collapsed %>"> <div class="sidebar-content js-simplebar"> <%= link_to admin_root_path, class: 'sidebar-brand' do %> <%= image_tag 'osuny-white.svg', class: 'img-fluid' %> diff --git a/app/views/admin/communication/website/pages/_list.html.erb b/app/views/admin/communication/website/pages/_list.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..f32da088e1ad87f40724ed94777312960426ff3b --- /dev/null +++ b/app/views/admin/communication/website/pages/_list.html.erb @@ -0,0 +1,21 @@ +<table class="table"> + <thead> + <tr> + <th><%= Communication::Website::Page.human_attribute_name('title') %></th> + <th><%= Communication::Website::Page.human_attribute_name('path') %></th> + <th></th> + </tr> + </thead> + <tbody> + <% pages.each do |page| %> + <tr> + <td><%= link_to page, admin_communication_website_page_path(page.id) %></td> + <td><%= page.path %></td> + <td class="text-end"> + <%= edit_link page %> + <%= destroy_link page %> + </td> + </tr> + <% end %> + </tbody> +</table> diff --git a/app/views/admin/communication/website/pages/index.html.erb b/app/views/admin/communication/website/pages/index.html.erb index 829bfcfff9baf12f699bdba5c11efbc5da44b212..157e08e9dc5aa647152f7ba1711596363a702057 100644 --- a/app/views/admin/communication/website/pages/index.html.erb +++ b/app/views/admin/communication/website/pages/index.html.erb @@ -1,26 +1,6 @@ <% content_for :title, Communication::Website::Page.model_name.human(count: 2) %> -<table class="table"> - <thead> - <tr> - <th><%= Communication::Website::Page.human_attribute_name('title') %></th> - <th><%= Communication::Website::Page.human_attribute_name('path') %></th> - <th></th> - </tr> - </thead> - <tbody> - <% @pages.each do |page| %> - <tr> - <td><%= link_to page, admin_communication_website_page_path(page.id) %></td> - <td><%= page.path %></td> - <td class="text-end"> - <%= edit_link page %> - <%= destroy_link page %> - </td> - </tr> - <% end %> - </tbody> -</table> +<%= render 'admin/communication/website/pages/list', pages: @pages %> <% content_for :buttons do %> <%= create_link Communication::Website::Page %> diff --git a/app/views/admin/communication/websites/show.html.erb b/app/views/admin/communication/websites/show.html.erb index 31fbef1b33b67c53314b8d4ab15278c161470799..098fff18349df342ae21221d75df270865a61400 100644 --- a/app/views/admin/communication/websites/show.html.erb +++ b/app/views/admin/communication/websites/show.html.erb @@ -13,18 +13,12 @@ <%= link_to t('create'), new_admin_communication_website_page_path(website_id: @website), - class: button_classes %> + class: button_classes('me-3') %> <%= link_to 'Toutes les pages', admin_communication_website_pages_path(website_id: @website) %> -<div class="row"> - <% @website.pages.ordered.limit(5).each do |page| %> - <div class="col-md-3 mt-4"> - <%= link_to page, admin_communication_website_page_path(website_id: @website, id: page) %> - </div> - <% end %> -</div> +<%= render 'admin/communication/website/pages/list', pages: @website.pages.recent %> <% content_for :buttons do %> <%= edit_link @website %> diff --git a/app/views/admin/dashboard/index.html.erb b/app/views/admin/dashboard/index.html.erb index 8b1daf9ecba76ab4ba76fdc56e0e4cc1a6133e03..b57ad81a832076a9d4dd3e2ad7cd3cbbb95eef2c 100644 --- a/app/views/admin/dashboard/index.html.erb +++ b/app/views/admin/dashboard/index.html.erb @@ -10,3 +10,37 @@ </div> </div> </div> + +<% if current_university.research_journals.any? %> + <h2 class="h4 my-4"><%= Research::Journal.model_name.human(count: 2) %></h2> + <div class="row"> + <% current_university.research_journals.each do |journal| %> + <div class="col-md-4"> + <div class="card"> + <div class="card-body"> + <span class="float-end"><i class="fas fa-newspaper fa-2x"></i></span> + <h4><%= journal %></h4> + <p><%= link_to 'Voir', [:admin, journal], class: 'stretched-link' %></p> + </div> + </div> + </div> + <% end %> + </div> +<% end %> + +<% if current_university.communication_websites.any? %> + <h2 class="h4 my-4"><%= Communication::Website.model_name.human(count: 2) %></h2> + <div class="row"> + <% current_university.communication_websites.each do |website| %> + <div class="col-md-4"> + <div class="card"> + <div class="card-body"> + <span class="float-end"><i class="fas fa-sitemap fa-2x"></i></span> + <h4><%= website %></h4> + <p><%= link_to 'Voir', [:admin, website], class: 'stretched-link' %></p> + </div> + </div> + </div> + <% end %> + </div> +<% end %>