feat(procedure): display revisions diffs

This commit is contained in:
Paul Chavard 2022-03-16 16:23:53 +01:00
parent 6d69e153f3
commit c530399eac
5 changed files with 41 additions and 2 deletions

View file

@ -1,7 +1,7 @@
module Administrateurs
class ProceduresController < AdministrateurController
before_action :retrieve_procedure, only: [:champs, :annotations, :edit, :monavis, :update_monavis, :jeton, :update_jeton, :publication, :publish, :transfert, :allow_expert_review, :experts_require_administrateur_invitation]
before_action :procedure_revisable?, only: [:champs, :annotations]
before_action :retrieve_procedure, only: [:champs, :annotations, :modifications, :edit, :monavis, :update_monavis, :jeton, :update_jeton, :publication, :publish, :transfert, :allow_expert_review, :experts_require_administrateur_invitation]
before_action :procedure_revisable?, only: [:champs, :annotations, :modifications]
ITEMS_PER_PAGE = 25
@ -172,6 +172,9 @@ module Administrateurs
def jeton
end
def modifications
end
def update_jeton
token = params[:procedure][:api_entreprise_token]
@procedure.api_entreprise_token = token

View file

@ -653,6 +653,10 @@ class Procedure < ApplicationRecord
!AssignTo.exists?(groupe_instructeur: groupe_instructeurs)
end
def revised?
feature_enabled?(:procedure_revisions) && revisions.size > 2
end
def routee?
routing_enabled? || groupe_instructeurs.size > 1
end

View file

@ -0,0 +1,18 @@
= render partial: 'administrateurs/breadcrumbs',
locals: { steps: [link_to('Démarches', admin_procedures_path),
link_to(@procedure.libelle, admin_procedure_path(@procedure)),
'Modifications'] }
.container
%h1.page-title
Historique des modifications du formulaire
.container
- previous_revision = nil
- @procedure.revisions.each do |revision|
- if previous_revision.present? && !revision.draft?
- changes = previous_revision.compare(revision)
- if changes.present?
.card.mb-4
%h2.card-title= "Modifications publiées le #{l(revision.published_at, format: '%d %B %Y à %R')}"
= render partial: 'revision_changes', locals: { changes: changes }
- previous_revision = revision

View file

@ -134,6 +134,19 @@
%p.card-admin-subtitle Suivi des dossiers
%p.button Modifier
- if @procedure.revised?
= link_to modifications_admin_procedure_path(@procedure), id: 'modifications', class: 'card-admin' do
%div
%span.icon.accept
%p.card-admin-status-accept Activée
%div
%p.card-admin-title
%span.badge.baseline= @procedure.revisions.size - 1
Modifications
%p.card-admin-subtitle Historique des modifications du formulaire
%p.button Voir
%h2.procedure-admin-explanation Pour aller plus loin
.procedure-grid

View file

@ -408,6 +408,7 @@ Rails.application.routes.draw do
get 'apercu'
get 'champs'
get 'annotations'
get 'modifications'
get 'monavis'
patch 'update_monavis'
get 'jeton'