From c555ec6f86689aaac6f665cc53e54e827f3577a4 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Tue, 3 Jan 2023 15:16:45 +0100 Subject: [PATCH] routes --- .../admin/communication/websites/pages_controller.rb | 6 +++++- app/views/admin/communication/websites/pages/_form.html.erb | 6 +++++- .../admin/communication/websites/pages/_treebranch.html.erb | 4 ++-- app/views/admin/communication/websites/pages/index.html.erb | 6 +++--- app/views/admin/communication/websites/pages/show.html.erb | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/controllers/admin/communication/websites/pages_controller.rb b/app/controllers/admin/communication/websites/pages_controller.rb index 203ff4d27..84085d6ac 100644 --- a/app/controllers/admin/communication/websites/pages_controller.rb +++ b/app/controllers/admin/communication/websites/pages_controller.rb @@ -28,6 +28,7 @@ class Admin::Communication::Websites::PagesController < Admin::Communication::We def show breadcrumb + add_breadcrumb(@page, admin_communication_website_page_path(@page)) end def static @@ -42,10 +43,12 @@ class Admin::Communication::Websites::PagesController < Admin::Communication::We def new @page.website = @website breadcrumb + add_breadcrumb(t('create')) end def edit breadcrumb + add_breadcrumb(@page, admin_communication_website_page_path(@page)) add_breadcrumb t('edit') end @@ -56,6 +59,7 @@ class Admin::Communication::Websites::PagesController < Admin::Communication::We redirect_to admin_communication_website_page_path(@page), notice: t('admin.successfully_created_html', model: @page.to_s) else breadcrumb + add_breadcrumb(t('create')) render :new, status: :unprocessable_entity end end @@ -66,6 +70,7 @@ class Admin::Communication::Websites::PagesController < Admin::Communication::We redirect_to admin_communication_website_page_path(@page), notice: t('admin.successfully_updated_html', model: @page.to_s) else breadcrumb + add_breadcrumb(@page, admin_communication_website_page_path(@page)) add_breadcrumb t('edit') render :edit, status: :unprocessable_entity end @@ -91,7 +96,6 @@ class Admin::Communication::Websites::PagesController < Admin::Communication::We super add_breadcrumb t('admin.communication.website.pages.structure'), admin_communication_website_pages_path - breadcrumb_for @page end def page_params diff --git a/app/views/admin/communication/websites/pages/_form.html.erb b/app/views/admin/communication/websites/pages/_form.html.erb index 5d0d81291..81496623e 100644 --- a/app/views/admin/communication/websites/pages/_form.html.erb +++ b/app/views/admin/communication/websites/pages/_form.html.erb @@ -1,4 +1,8 @@ -<%= simple_form_for [:admin, page] do |f| %> +<% +url = page.new_record? ? admin_communication_website_pages_path + : admin_communication_website_page_path(page) +%> +<%= simple_form_for page, url: url do |f| %> <%= f.error_notification %> <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %> diff --git a/app/views/admin/communication/websites/pages/_treebranch.html.erb b/app/views/admin/communication/websites/pages/_treebranch.html.erb index 47459b77c..8244cfbae 100644 --- a/app/views/admin/communication/websites/pages/_treebranch.html.erb +++ b/app/views/admin/communication/websites/pages/_treebranch.html.erb @@ -28,8 +28,8 @@ <span class="me-3 show-on-hover"><%= t("communication.website.pages.defaults.#{page.kind}.admin_description") %></span> <% end %> <div class="btn-group"> - <%= duplicate_link page if page.is_regular_page?%> - <%= edit_link page %> + <%= 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> diff --git a/app/views/admin/communication/websites/pages/index.html.erb b/app/views/admin/communication/websites/pages/index.html.erb index 0f387e4fa..08f84bcf3 100644 --- a/app/views/admin/communication/websites/pages/index.html.erb +++ b/app/views/admin/communication/websites/pages/index.html.erb @@ -15,12 +15,12 @@ admin_communication_website_page_path(website_id: @homepage.website.id, id: @homepage.id) %> <div class="btn-group ms-auto" role="group"> - <%= edit_link @homepage %> + <%= 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 %>"> + data-id="<%= @homepage.id %>" + data-sort-url="<%= reorder_admin_communication_website_pages_path %>"> <%= render 'treebranch', pages: @first_level_pages %> </ul> </li> diff --git a/app/views/admin/communication/websites/pages/show.html.erb b/app/views/admin/communication/websites/pages/show.html.erb index ce1aa34d4..c8d6a6191 100644 --- a/app/views/admin/communication/websites/pages/show.html.erb +++ b/app/views/admin/communication/websites/pages/show.html.erb @@ -106,5 +106,5 @@ <% content_for :action_bar_right do %> <%= preview_link %> - <%= edit_link @page %> + <%= link_to t('edit'), edit_admin_communication_website_page_path(@page), class: button_classes %> <% end %> -- GitLab