fetch procedure info on demand

Co-authored-by: Paul Chavard <paul.chavard@beta.gouv.fr>
Co-authored-by: Colin Darie <colin@darie.eu>
Co-authored-by: Martin <martin@sharypic.com>
This commit is contained in:
Christophe Robillard 2022-12-01 19:59:34 +01:00
parent 112fae8f00
commit f3f8bc74c7
5 changed files with 36 additions and 4 deletions

View file

@ -332,6 +332,14 @@ module Administrateurs
@procedure = Procedure.includes(draft_revision: { revision_types_de_champ_public: :type_de_champ }).find(@procedure.id)
end
def detail
@procedure = Procedure.find(params[:id])
render turbo_stream: [
turbo_stream.remove("procedure_detail_#{@procedure.id}"),
turbo_stream.replace("procedure_#{@procedure.id}", partial: "detail", locals: { procedure: @procedure, show_detail: params[:show_detail] })
]
end
def all
@filter = ProceduresFilter.new(current_administrateur, params)
all_procedures = filter_procedures(@filter)

View file

@ -0,0 +1,21 @@
%tr.procedure{ id: "procedure_#{procedure.id}" }
%td
= button_to detail_admin_procedure_path(procedure["id"]), params: show_detail ? {} : { show_detail: true }, method: :get, title: 'Cacher les détails', class: [ show_detail ? 'fr-icon-subtract-line':'fr-icon-add-line', "fr-icon--sm fr-mr-1w fr-mb-1w fr-text-action-high--blue-france fr-btn fr-btn--tertiary-no-outline"] do
Cacher les détails
%td= procedure.libelle
%td= procedure.id
%td= procedure.administrateurs.count
%td= t procedure.aasm_state, scope: 'activerecord.attributes.procedure.aasm_state'
%td= l(procedure.published_at, format: :message_date_without_time)
- if show_detail
%tr.procedure{ id: "procedure_detail_#{procedure.id}" }
%td.fr-highlight--beige-gris-galet{ colspan: '6' }
.fr-container
.fr-grid-row
.fr-col-6
- procedure.zones.uniq.each do |zone|
= zone.label_at(procedure.published_or_created_at)
.fr-col-6
- procedure.administrateurs.uniq.each do |admin|
= admin.email

View file

@ -40,11 +40,12 @@
%th{ scope: 'col' } Administrateurs
%th{ scope: 'col' } Statut
%th{ scope: 'col' } Date
%tbody{ 'data-turbo': 'true' }
- @procedures.each do |procedure|
%tbody{ 'data-controller': 'expand' }
%tr.procedure{ 'data-action': 'click->expand#toggle' }
%tr.procedure{ id: "procedure_#{procedure['id']}" }
%td
%button.fr-icon-add-line.fr-icon--sm.fr-mr-1w.fr-mb-1w.fr-text-action-high--blue-france{ 'aria-hidden': 'true', 'data-expand-target': 'icon' }
= button_to detail_admin_procedure_path(procedure["id"]), params: { show_detail: true}, method: :get, title: 'Afficher details', class: "fr-icon-add-line fr-icon--sm fr-mr-1w fr-mb-1w fr-text-action-high--blue-france fr-btn fr-btn--tertiary-no-outline" do
Afficher details procedure
%td= procedure["libelle"]
%td= procedure["id"]
%td= procedure["admin_count"]

View file

@ -0,0 +1 @@
= turbo_stream.after("procedure_#{@procedure.id}", partial: "detail", locals: { procedure: @procedure })

View file

@ -440,6 +440,7 @@ Rails.application.routes.draw do
end
member do
get 'detail'
get 'apercu'
get 'champs'
get 'zones'