From 7138ec147f9121e0316729d3bc21abc860f70422 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Mon, 18 Oct 2021 17:00:28 +0200 Subject: [PATCH] wip --- .../communication/website/pages_controller.rb | 3 +- .../communication/website/posts_controller.rb | 3 +- .../website/pages/_form.html.erb | 48 +++++++++---------- .../website/pages/_list.html.erb | 6 +-- .../website/pages/index.html.erb | 7 ++- .../website/posts/_list.html.erb | 6 +-- .../website/posts/index.html.erb | 7 ++- .../communication/websites/show.html.erb | 43 +++++++++++------ 8 files changed, 74 insertions(+), 49 deletions(-) diff --git a/app/controllers/admin/communication/website/pages_controller.rb b/app/controllers/admin/communication/website/pages_controller.rb index fc0e9fe7f..d3a2194cf 100644 --- a/app/controllers/admin/communication/website/pages_controller.rb +++ b/app/controllers/admin/communication/website/pages_controller.rb @@ -2,7 +2,7 @@ class Admin::Communication::Website::PagesController < Admin::Communication::Web load_and_authorize_resource class: Communication::Website::Page def index - @pages = @website.pages.ordered + @pages = @website.pages.ordered.page params[:page] breadcrumb end @@ -11,6 +11,7 @@ class Admin::Communication::Website::PagesController < Admin::Communication::Web end def new + @page.website = @website breadcrumb end diff --git a/app/controllers/admin/communication/website/posts_controller.rb b/app/controllers/admin/communication/website/posts_controller.rb index d6a49f8ea..69fe0c760 100644 --- a/app/controllers/admin/communication/website/posts_controller.rb +++ b/app/controllers/admin/communication/website/posts_controller.rb @@ -2,7 +2,7 @@ class Admin::Communication::Website::PostsController < Admin::Communication::Web load_and_authorize_resource class: Communication::Website::Post def index - @posts = @website.posts.ordered + @posts = @website.posts.ordered.page params[:page] breadcrumb end @@ -11,6 +11,7 @@ class Admin::Communication::Website::PostsController < Admin::Communication::Web end def new + @post.website = @website breadcrumb end diff --git a/app/views/admin/communication/website/pages/_form.html.erb b/app/views/admin/communication/website/pages/_form.html.erb index 15edf3743..f1b31c116 100644 --- a/app/views/admin/communication/website/pages/_form.html.erb +++ b/app/views/admin/communication/website/pages/_form.html.erb @@ -1,31 +1,31 @@ <%= simple_form_for [:admin, page] do |f| %> -<div class="row"> - <div class="col-md-8"> - <div class="card flex-fill w-100"> - <div class="card-header"> - <h5 class="card-title mb-0">Content</h5> - </div> - <div class="card-body"> - <%= f.input :title %> - <%= f.input :description %> - <%= f.input :text, input_html: { rows: 20 } %> + <div class="row"> + <div class="col-md-8"> + <div class="card flex-fill w-100"> + <div class="card-header"> + <h5 class="card-title">Content</h5> + </div> + <div class="card-body"> + <%= f.input :title %> + <%= f.input :description %> + <%= f.input :text, input_html: { rows: 20 } %> + </div> </div> </div> - </div> - <div class="col-md-4"> - <div class="card flex-fill w-100"> - <div class="card-header"> - <h5 class="card-title mb-0">Metadata</h5> - </div> - <div class="card-body"> - <%= f.input :slug %> - <%= f.input :published %> - <%= f.association :parent, collection: page.website.pages.where.not(id: page) %> + <div class="col-md-4"> + <div class="card flex-fill w-100"> + <div class="card-header"> + <h5 class="card-title">Metadata</h5> + </div> + <div class="card-body"> + <%= f.input :slug %> + <%= f.input :published %> + <%= f.association :parent, collection: page.website.pages.where.not(id: page) %> + </div> </div> </div> </div> -</div> -<% content_for :buttons do %> - <%= submit f %> -<% end %> + <% content_for :buttons do %> + <%= submit f %> + <% end %> <% end %> diff --git a/app/views/admin/communication/website/pages/_list.html.erb b/app/views/admin/communication/website/pages/_list.html.erb index dba9d2fd4..7b063331d 100644 --- a/app/views/admin/communication/website/pages/_list.html.erb +++ b/app/views/admin/communication/website/pages/_list.html.erb @@ -1,7 +1,7 @@ <table class="table"> <thead> <tr> - <th class="ps-0"><%= Communication::Website::Page.human_attribute_name('title') %></th> + <th><%= Communication::Website::Page.human_attribute_name('title') %></th> <th><%= Communication::Website::Page.human_attribute_name('path') %></th> <th width="150"></th> </tr> @@ -9,9 +9,9 @@ <tbody> <% pages.each do |page| %> <tr> - <td class="ps-0"><%= link_to page, admin_communication_website_page_path(website_id: page.website.id, id: page.id) %></td> + <td><%= link_to page, admin_communication_website_page_path(website_id: page.website.id, id: page.id) %></td> <td><%= page.path %></td> - <td class="text-end pe-0"> + <td class="text-end"> <%= link_to t('edit'), edit_admin_communication_website_page_path(website_id: page.website.id, id: page.id), class: button_classes %> diff --git a/app/views/admin/communication/website/pages/index.html.erb b/app/views/admin/communication/website/pages/index.html.erb index 157e08e9d..a35c92fec 100644 --- a/app/views/admin/communication/website/pages/index.html.erb +++ b/app/views/admin/communication/website/pages/index.html.erb @@ -1,6 +1,11 @@ <% content_for :title, Communication::Website::Page.model_name.human(count: 2) %> -<%= render 'admin/communication/website/pages/list', pages: @pages %> +<div class="card"> + <%= render 'admin/communication/website/pages/list', pages: @pages %> + <div class="card-footer"> + <%= paginate @pages, theme: 'bootstrap-5' %> + </div> +</div> <% content_for :buttons do %> <%= create_link Communication::Website::Page %> diff --git a/app/views/admin/communication/website/posts/_list.html.erb b/app/views/admin/communication/website/posts/_list.html.erb index 6dae7e87f..05c71ee32 100644 --- a/app/views/admin/communication/website/posts/_list.html.erb +++ b/app/views/admin/communication/website/posts/_list.html.erb @@ -1,7 +1,7 @@ <table class="table"> <thead> <tr> - <th class="ps-0"><%= Communication::Website::Post.human_attribute_name('title') %></th> + <th><%= Communication::Website::Post.human_attribute_name('title') %></th> <th><%= Communication::Website::Post.human_attribute_name('published_at') %></th> <th width="150"></th> </tr> @@ -9,9 +9,9 @@ <tbody> <% posts.each do |post| %> <tr> - <td class="ps-0"><%= link_to post, admin_communication_website_post_path(website_id: post.website.id, id: post.id) %></td> + <td><%= link_to post, admin_communication_website_post_path(website_id: post.website.id, id: post.id) %></td> <td><%= l post.published_at, format: :long if post.published_at %></td> - <td class="text-end pe-0"> + <td class="text-end"> <%= link_to t('edit'), edit_admin_communication_website_post_path(website_id: post.website.id, id: post.id), class: button_classes %> diff --git a/app/views/admin/communication/website/posts/index.html.erb b/app/views/admin/communication/website/posts/index.html.erb index 395eec23b..e8af860df 100644 --- a/app/views/admin/communication/website/posts/index.html.erb +++ b/app/views/admin/communication/website/posts/index.html.erb @@ -1,6 +1,11 @@ <% content_for :title, Communication::Website::Post.model_name.human(count: 2) %> -<%= render 'admin/communication/website/posts/list', posts: @posts %> +<div class="card"> + <%= render 'admin/communication/website/posts/list', posts: @posts %> + <div class="card-footer"> + <%= paginate @posts, theme: 'bootstrap-5' %> + </div> +</div> <% content_for :buttons do %> <%= create_link Communication::Website::Post %> diff --git a/app/views/admin/communication/websites/show.html.erb b/app/views/admin/communication/websites/show.html.erb index c80c33b93..9901b49a7 100644 --- a/app/views/admin/communication/websites/show.html.erb +++ b/app/views/admin/communication/websites/show.html.erb @@ -9,22 +9,35 @@ <%= link_to @website.about, [:admin, @website.about] unless @website.about.nil? %> </p> -<h2 class="mt-5"><%= Communication::Website::Post.model_name.human(count: 2) %></h2> -<%= link_to t('create'), - new_admin_communication_website_post_path(website_id: @website), - class: button_classes('me-3') %> -<%= link_to t('activerecord.models.communication/website/post.all'), - admin_communication_website_posts_path(website_id: @website) %> -<%= render 'admin/communication/website/posts/list', posts: @website.posts.recent %> +<div class="card mt-5"> + <div class="card-header"> + <div class="float-end"> + <%= link_to t('activerecord.models.communication/website/post.all'), + admin_communication_website_posts_path(website_id: @website), + class: 'me-3' %> + <%= link_to t('create'), + new_admin_communication_website_post_path(website_id: @website), + class: button_classes %> + </div> + <h2 class="card-title"><%= Communication::Website::Post.model_name.human(count: 2) %></h2> + </div> + <%= render 'admin/communication/website/posts/list', posts: @website.posts.recent %> +</div> +<div class="card mt-5"> + <div class="card-header"> + <div class="float-end"> + <%= link_to t('activerecord.models.communication/website/page.all'), + admin_communication_website_pages_path(website_id: @website), + class: 'me-3' %> + <%= link_to t('create'), + new_admin_communication_website_page_path(website_id: @website), + class: button_classes %> + </div> + <h2 class="card-title"><%= Communication::Website::Page.model_name.human(count: 2) %></h2> + </div> + <%= render 'admin/communication/website/pages/list', pages: @website.pages.recent %> +</div> -<h2 class="mt-5"><%= Communication::Website::Page.model_name.human(count: 2) %></h2> - -<%= link_to t('create'), - new_admin_communication_website_page_path(website_id: @website), - class: button_classes('me-3') %> -<%= link_to t('activerecord.models.communication/website/page.all'), - admin_communication_website_pages_path(website_id: @website) %> -<%= render 'admin/communication/website/pages/list', pages: @website.pages.recent %> <% content_for :buttons do %> <% if @website.imported? %> -- GitLab