amelioration(data): pour les dossiers en brouillon ayant un groupe_instructeur_id, supprime cette information

This commit is contained in:
Martin 2023-07-18 16:44:03 +02:00 committed by mfo
parent 425d8867be
commit 367a557aaf
4 changed files with 22 additions and 47 deletions

View file

@ -1,22 +0,0 @@
class Dsfr::CheckboxComponent < ApplicationComponent
attr_reader :error
def initialize(form:, target:, checkboxes:, error: nil)
@form = form
@target = target
@checkboxes = checkboxes
@error = error
end
def error?
# TODO: mettre correctement le aria-labelled-by avec l'id du div qui contient les erreurs
# https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/bouton-radio/
@error.present?
end
def each_checkboxes
@checkboxes.each do |button|
yield(*button.values_at(:label, :checked_value, :unchecked_value, :hint), button.except(:label, :checked_value, :unchecked_value, :hint))
end
end
end

View file

@ -1,20 +0,0 @@
%fieldset{ class: class_names("fr-fieldset": true, "fr-fieldset--error": error?), 'aria-labelledby': 'radio-hint-element-legend radio-hint-element-messages', role: error? ? :group : nil }
%legend.fr-fieldset__legend--regular.fr-fieldset__legend
= content
- each_checkboxes do |label, checked_value, unchecked_value, hint, button_options|
.fr-fieldset__element
.fr-checkbox-group
= @form.check_box @target, button_options.merge(id: checked_value.to_s.parameterize, multiple: true), checked_value, unchecked_value
= @form.label @target, for: checked_value.to_s.parameterize, class: 'fr-label' do
- capture do
= label
= button_options[:after_label] if button_options[:after_label]
%span.fr-hint-text= hint if hint
.fr-messages-group{ 'aria-live': 'assertive' }
- if error?
%p.fr-message.fr-message--error= error

View file

@ -135,7 +135,7 @@ class Dossier < ApplicationRecord
aasm whiny_persistence: true, column: :state, enum: true do
state :brouillon, initial: true
state :en_construction, before_enter: :compute_routing
state :en_construction
state :en_instruction
state :accepte
state :refuse
@ -870,10 +870,6 @@ class Dossier < ApplicationRecord
end
end
def compute_routing
RoutingEngine.compute(self)
end
def after_passer_en_instruction(h)
instructeur = h[:instructeur]
disable_notification = h.fetch(:disable_notification, false)

View file

@ -0,0 +1,21 @@
namespace :after_party do
desc 'Deployment task: reset_dossier_brouillon_groupe_instructeur_id'
task reset_dossier_brouillon_groupe_instructeur_id: :environment do
puts "Running deploy task 'reset_dossier_brouillon_groupe_instructeur_id'"
dossier_brouillon = Dossier.state_brouillon.where.not(groupe_instructeur_id: nil)
progress = ProgressReport.new(dossier_brouillon.count)
# Put your task implementation HERE.
dossier_brouillon.in_batches do |relation|
progress.inc(relation.count)
relation.update_all(groupe_instructeur_id: nil)
end
progress.finish
# Update task as completed. If you remove the line below, the task will
# run with every deploy (or every time you call after_party:run).
AfterParty::TaskRecord
.create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
end
end