nouvelle page pour ordonner avec empty layout

This commit is contained in:
benoitqueyron 2024-11-20 16:33:57 +01:00
parent 010ea0586c
commit bc3730a032
No known key found for this signature in database
GPG key ID: AD3C38C9ACA84135
5 changed files with 77 additions and 6 deletions

View file

@ -2,7 +2,7 @@
module Instructeurs module Instructeurs
class ProceduresController < InstructeurController class ProceduresController < InstructeurController
before_action :ensure_ownership!, except: [:index] before_action :ensure_ownership!, except: [:index, :order_positions, :update_order_positions]
before_action :ensure_not_super_admin!, only: [:download_export, :exports] before_action :ensure_not_super_admin!, only: [:download_export, :exports]
ITEMS_PER_PAGE = 100 ITEMS_PER_PAGE = 100
@ -68,6 +68,14 @@ module Instructeurs
@statut.blank? ? @statut = 'en-cours' : @statut = params[:statut] @statut.blank? ? @statut = 'en-cours' : @statut = params[:statut]
end end
def order_positions
@procedures = Procedure.where(id: params[:collection_ids]).order_by_position_for(current_instructeur)
render layout: "empty_layout"
end
def update_order_positions
end
def show def show
@procedure = procedure @procedure = procedure
# Technically, procedure_presentation already sets the attribute. # Technically, procedure_presentation already sets the attribute.

View file

@ -12,17 +12,17 @@
= tab_item(t('pluralize.closed', count: @procedures_closes_count), instructeur_procedures_path(statut: 'archivees'), active: @statut == 'archivees', badge: number_with_html_delimiter(@procedures_closes_count)) = tab_item(t('pluralize.closed', count: @procedures_closes_count), instructeur_procedures_path(statut: 'archivees'), active: @statut == 'archivees', badge: number_with_html_delimiter(@procedures_closes_count))
.fr-container .fr-container
- if @statut.in? ["publiees", "en-cours"] # FIX ME: @statut === "en-cours" à partir du 1/11/2023 - if @statut == "en-cours"
= render Dsfr::CalloutComponent.new(title: nil) do |c| = render Dsfr::CalloutComponent.new(title: nil) do |c|
- c.with_body do - c.with_body do
= t(".procedure_en_cours_description") = t(".procedure_en_cours_description")
- collection = @procedures_en_cours - collection = @procedures_en_cours
- if @statut === "brouillons" - if @statut == "brouillons"
= render Dsfr::CalloutComponent.new(title: nil) do |c| = render Dsfr::CalloutComponent.new(title: nil) do |c|
- c.with_body do - c.with_body do
= t(".procedure_en_test_description") = t(".procedure_en_test_description")
- collection = @procedures_draft - collection = @procedures_draft
- if @statut === "archivees" - if @statut == "archivees"
= render Dsfr::CalloutComponent.new(title: nil) do |c| = render Dsfr::CalloutComponent.new(title: nil) do |c|
- c.with_body do - c.with_body do
= t(".procedure_close_description") = t(".procedure_close_description")
@ -30,8 +30,11 @@
- if collection.present? - if collection.present?
%h2.fr-h6 .fr-container.flex.justify-between.fr-mb-6w
= page_entries_info collection %h2.fr-h6.fr-m-0
= page_entries_info collection
- if (@statut == "en-cours" && collection.size > 1)
= link_to "Personnaliser l'ordre", order_positions_instructeur_procedures_path(collection_ids: collection.map(&:id)), class: 'fr-btn fr-btn--sm fr-btn--tertiary fr-btn--icon-left fr-icon-settings-5-line'
%ul.procedure-list.fr-pl-0 %ul.procedure-list.fr-pl-0
= render partial: 'instructeurs/procedures/list', = render partial: 'instructeurs/procedures/list',
collection: collection, collection: collection,

View file

@ -0,0 +1,24 @@
.fr-container.fr-mt-6w.fr-mb-15w
= link_to " Liste des démarches", instructeur_procedures_path, class: 'fr-link fr-icon-arrow-left-line fr-link--icon--left fr-icon--sm'
%h3.fr-my-3w
Personnaliser l'ordre des #{@procedures.size} démarches « en cours »
%p Déplacez les démarches dans la liste pour les classer en fonction de vos préférences :
%fr-container
= form_tag update_order_positions_instructeur_procedures_path, method: :patch do
- @procedures.each do |procedure|
.fr-card.fr-mb-1w.fr-py-1w.fr-px-2w
.flex.align-center
%button.fr-btn.fr-icon-arrow-up-line.fr-btn--secondary.fr-col-1
%button.fr-btn.fr-icon-arrow-down-line.fr-btn--secondary.fr-col-1.fr-mx-2w
- if procedure.close?
%span.fr-badge.fr-mr-2w Close
- elsif procedure.depubliee?
%span.fr-badge.fr-mr-2w Dépubliée
= "#{procedure.libelle} - n°#{procedure.id}"
= hidden_field_tag "ordered_procedure_ids[]", procedure.id
.fixed-footer.fr-py-1w
.fr-btns-group.fr-btns-group--center.fr-btns-group--inline.fr-btns-group--inline-lg
= link_to "Annuler", instructeur_procedures_path, class: 'fr-btn fr-btn--secondary fr-my-1w'
%button.fr-btn.fr-my-1w{ type: "submit", form: 'order-instructeur-procedures-form' } Valider

View file

@ -0,0 +1,31 @@
!!! 5
%html{ lang: html_lang, data: { fr_scheme: 'system' }, class: yield(:root_class) }
%head
%meta{ "http-equiv": "Content-Type", content: "text/html; charset=UTF-8" }
%meta{ "http-equiv": "X-UA-Compatible", content: "IE=edge" }
%meta{ name: "viewport", content: "width=device-width, initial-scale=1" }
%meta{ name: "application-name", content: Current.application_name }
%meta{ name: "apple-mobile-web-app-title", content: Current.application_name }
= csrf_meta_tags
%title
= content_for?(:title) ? "#{yield(:title)} · #{Current.application_name}" : Current.application_name
= render partial: "layouts/favicons"
= vite_client_tag
= vite_react_refresh_tag
= vite_javascript_tag 'application'
= preload_link_tag(asset_url("Marianne-Regular.woff2"))
= preload_link_tag(asset_url("Spectral-Regular.ttf"))
= vite_stylesheet_tag 'main', media: 'all'
= stylesheet_link_tag 'application', media: 'all'
= render partial: 'layouts/setup_theme'
%body{ class: browser.platform.ios? ? 'ios' : nil, data: { controller: 'turbo' } }
.page-wrapper
%main
= content_for?(:content) ? yield(:content) : yield

View file

@ -461,6 +461,11 @@ Rails.application.routes.draw do
put 'preview' put 'preview'
end end
end end
collection do
get 'order_positions'
patch 'update_order_positions'
end
end end
resources :procedure_presentation, only: [:update] do resources :procedure_presentation, only: [:update] do