diff --git a/app/controllers/instructeurs/procedures_controller.rb b/app/controllers/instructeurs/procedures_controller.rb index d5d7cdc53..ba5cf835f 100644 --- a/app/controllers/instructeurs/procedures_controller.rb +++ b/app/controllers/instructeurs/procedures_controller.rb @@ -2,7 +2,7 @@ module Instructeurs 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] ITEMS_PER_PAGE = 100 @@ -68,6 +68,14 @@ module Instructeurs @statut.blank? ? @statut = 'en-cours' : @statut = params[:statut] 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 @procedure = procedure # Technically, procedure_presentation already sets the attribute. diff --git a/app/views/instructeurs/procedures/index.html.haml b/app/views/instructeurs/procedures/index.html.haml index f18d64e94..7a04633b7 100644 --- a/app/views/instructeurs/procedures/index.html.haml +++ b/app/views/instructeurs/procedures/index.html.haml @@ -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)) .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| - c.with_body do = t(".procedure_en_cours_description") - collection = @procedures_en_cours - - if @statut === "brouillons" + - if @statut == "brouillons" = render Dsfr::CalloutComponent.new(title: nil) do |c| - c.with_body do = t(".procedure_en_test_description") - collection = @procedures_draft - - if @statut === "archivees" + - if @statut == "archivees" = render Dsfr::CalloutComponent.new(title: nil) do |c| - c.with_body do = t(".procedure_close_description") @@ -30,8 +30,11 @@ - if collection.present? - %h2.fr-h6 - = page_entries_info collection + .fr-container.flex.justify-between.fr-mb-6w + %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 = render partial: 'instructeurs/procedures/list', collection: collection, diff --git a/app/views/instructeurs/procedures/order_positions.html.haml b/app/views/instructeurs/procedures/order_positions.html.haml new file mode 100644 index 000000000..7d3634aba --- /dev/null +++ b/app/views/instructeurs/procedures/order_positions.html.haml @@ -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 diff --git a/app/views/layouts/empty_layout.html.haml b/app/views/layouts/empty_layout.html.haml new file mode 100644 index 000000000..fee313006 --- /dev/null +++ b/app/views/layouts/empty_layout.html.haml @@ -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 diff --git a/config/routes.rb b/config/routes.rb index 518f513aa..4f6ac0518 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -461,6 +461,11 @@ Rails.application.routes.draw do put 'preview' end end + + collection do + get 'order_positions' + patch 'update_order_positions' + end end resources :procedure_presentation, only: [:update] do