Skip to content

Commit

Permalink
Merge pull request demarches-simplifiees#9101 from tchak/feat-accredi…
Browse files Browse the repository at this point in the history
…atation-jo

ETQ administrateur, je voudrais pouvoir utiliser le numéro d'accréditation Paris 2024
  • Loading branch information
tchak authored and maatinito committed Sep 4, 2023
1 parent 276ce67 commit 50ca6e7
Show file tree
Hide file tree
Showing 42 changed files with 801 additions and 20 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ gem 'devise-i18n'
gem 'devise-two-factor'
gem 'discard'
gem 'dotenv-rails', require: 'dotenv/rails-now' # dotenv should always be loaded before rails
gem 'dry-monads'
gem 'elastic-apm'
gem 'flipper'
gem 'flipper-active_record'
Expand Down
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,14 @@ GEM
dotenv (= 2.7.6)
railties (>= 3.2)
dry-cli (1.0.0)
dry-core (1.0.0)
concurrent-ruby (~> 1.0)
zeitwerk (~> 2.6)
dry-inflector (0.2.0)
dry-monads (1.6.0)
concurrent-ruby (~> 1.0)
dry-core (~> 1.0, < 2)
zeitwerk (~> 2.6)
dumb_delegator (1.0.0)
ecma-re-validator (0.3.0)
regexp_parser (~> 2.0)
Expand Down Expand Up @@ -851,6 +858,7 @@ DEPENDENCIES
devise-two-factor
discard
dotenv-rails
dry-monads
elastic-apm
factory_bot
flipper
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
- each_champ do |champ|
- if champ.repetition?
- champ.rows.each.with_index do |row, i|
.fr-background-alt--grey.fr-p-2w.fr-my-3w.fr-ml-2w.champ-repetition
%p.font-weight-bold= "#{champ.libelle} #{i + 1} :"

= render Dossiers::ChampsRowsShowComponent.new(champs: row, seen_at:, profile:)

- else
= render Dossiers::RowShowComponent.new(label: champ.libelle, seen_at:, profile:, content_class: champ.type_champ, updated_at: updated_after_deposer?(champ) ? champ.updated_at : nil) do |c|
- if champ.blank?
- c.blank do
= t(blank_key(champ))
- else
- c.with_value do
- case champ.type_champ
- when TypeDeChamp.type_champs.fetch(:carte)
= render partial: "shared/champs/carte/show", locals: { champ: champ }
- when TypeDeChamp.type_champs.fetch(:dossier_link)
= render partial: "shared/champs/dossier_link/show", locals: { champ: champ }
- when TypeDeChamp.type_champs.fetch(:multiple_drop_down_list)
= render partial: "shared/champs/multiple_drop_down_list/show", locals: { champ: champ }
- when TypeDeChamp.type_champs.fetch(:piece_justificative), TypeDeChamp.type_champs.fetch(:titre_identite)
= render partial: "shared/champs/piece_justificative/show", locals: { champ: champ }
- when TypeDeChamp.type_champs.fetch(:siret)
= render partial: "shared/champs/siret/show", locals: { champ: champ, profile: @profile }
- when TypeDeChamp.type_champs.fetch(:iban)
= render partial: "shared/champs/iban/show", locals: { champ: champ }
- when TypeDeChamp.type_champs.fetch(:textarea)
= render partial: "shared/champs/textarea/show", locals: { champ: champ }
- when TypeDeChamp.type_champs.fetch(:annuaire_education)
= render partial: "shared/champs/annuaire_education/show", locals: { champ: champ }
- when TypeDeChamp.type_champs.fetch(:cnaf)
= render partial: "shared/champs/cnaf/show", locals: { champ: champ, profile: @profile }
- when TypeDeChamp.type_champs.fetch(:dgfip)
= render partial: "shared/champs/dgfip/show", locals: { champ: champ, profile: @profile }
- when TypeDeChamp.type_champs.fetch(:pole_emploi)
= render partial: "shared/champs/pole_emploi/show", locals: { champ: champ, profile: @profile }
- when TypeDeChamp.type_champs.fetch(:mesri)
= render partial: "shared/champs/mesri/show", locals: { champ: champ, profile: @profile }
- when TypeDeChamp.type_champs.fetch(:address)
= render partial: "shared/champs/address/show", locals: { champ: champ }
- when TypeDeChamp.type_champs.fetch(:communes)
= render partial: "shared/champs/communes/show", locals: { champ: champ }
- when TypeDeChamp.type_champs.fetch(:regions)
= render partial: "shared/champs/regions/show", locals: { champ: champ }
- when TypeDeChamp.type_champs.fetch(:rna)
= render partial: "shared/champs/rna/show", locals: { champ: champ, profile: @profile }
- when TypeDeChamp.type_champs.fetch(:epci)
= render partial: "shared/champs/epci/show", locals: { champ: champ }
- when TypeDeChamp.type_champs.fetch(:cojo)
= render partial: "shared/champs/cojo/show", locals: { champ: champ, profile: @profile }
- when TypeDeChamp.type_champs.fetch(:date)
%p= champ.to_s
- when TypeDeChamp.type_champs.fetch(:datetime)
%p= champ.to_s
- when TypeDeChamp.type_champs.fetch(:number), TypeDeChamp.type_champs.fetch(:integer_number), TypeDeChamp.type_champs.fetch(:decimal_number)
%p= helpers.number_with_html_delimiter(champ.to_s)
- else
= helpers.format_text_value(champ.to_s.strip) # format already wrap in p

9 changes: 9 additions & 0 deletions app/components/editable_champ/cojo_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class EditableChamp::COJOComponent < EditableChamp::EditableChampBaseComponent
def input_group_class
if @champ.accreditation_success?
'fr-input-group--valid'
elsif @champ.accreditation_error?
'fr-input-group--error'
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
en:
accreditation_number_label: Accreditation number
accreditation_number_notice: Identification number issued by Paris 2024
accreditation_birthdate_label: Date of birth
accreditation_number_error: Invalid accreditation number
accreditation_number_verification_pending: Accreditation number verification in progress
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
fr:
accreditation_number_label: Numéro d‘accréditation
accreditation_number_notice: Numéro d‘identification délivré par Paris 2024
accreditation_birthdate_label: Date de naissance
accreditation_number_error: Le numéro d‘accréditation est incorrect
accreditation_number_verification_pending: Vérification du numéro d‘accréditation en cours
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

.fr-input-group{ class: input_group_class }
= @form.label :accreditation_number, for: @champ.accreditation_number_input_id, class: 'fr-label' do
- safe_join [t('.accreditation_number_label'), @champ.required? ? render(EditableChamp::AsteriskMandatoryComponent.new) : ''], ' '
%p.fr-hint-text{ id: dom_id(@champ, :accreditation_number_notice) }= t('.accreditation_number_notice')
= @form.text_field :accreditation_number,
required: @champ.required?,
aria: { describedby: [dom_id(@champ, :accreditation_number_notice), @champ.accreditation_error? ? dom_id(@champ, :accreditation_number_error) : nil].compact.join(' ') },
data: { controller: 'format', format: 'integer' },
class: "width-33-desktop fr-input small-margin", id: @champ.accreditation_number_input_id

- if @champ.accreditation_error?
%p.fr-error-text{ id: dom_id(@champ, :accreditation_number_error) }= t('.accreditation_number_error')
- elsif @champ.fetch_external_data_pending?
%p.fr-info-text= t('.accreditation_number_verification_pending')

.fr-input-group{ class: input_group_class }
= @form.label :accreditation_birthdate, for: @champ.accreditation_birthdate_input_id, class: 'fr-label' do
- safe_join [t('.accreditation_birthdate_label'), @champ.required? ? render(EditableChamp::AsteriskMandatoryComponent.new) : ''], ' '
= @form.date_field :accreditation_birthdate,
required: @champ.required?,
aria: { describedby: dom_id(@champ, :accreditation_birthdate) },
class: "width-33-desktop fr-input small-margin", id: @champ.accreditation_birthdate_input_id
22 changes: 21 additions & 1 deletion app/components/editable_champ/editable_champ_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,35 @@ def html_options
"hidden": !@champ.visible?
),
id: @champ.input_group_id,
data: { controller: stimulus_controller, **data_dependent_conditions }
data: { controller: stimulus_controller, **data_dependent_conditions, **stimulus_values }
}
end

def stimulus_values
if @champ.fetch_external_data_pending?
{ turbo_poll_url_value: }
else
{}
end
end

def turbo_poll_url_value
if @champ.private?
annotation_instructeur_dossier_path(@champ.dossier.procedure, @champ.dossier, @champ)
else
champ_dossier_path(@champ.dossier, @champ)
end
end

def stimulus_controller
if autosave_enabled?
# This is an editable champ. Lets find what controllers it might need.
controllers = ['autosave']

if @champ.fetch_external_data_pending?
controllers << 'turbo-poll'
end

controllers.join(' ')
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/components/types_de_champ_editor/champ_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def filter_block_type_champ(type_champ)
end

def filter_featured_type_champ(type_champ)
feature_name = TypeDeChamp::FEATURE_FLAGS[type_champ]
feature_name.blank? || feature_enabled?(feature_name)
feature_name = TypeDeChamp::FEATURE_FLAGS[type_champ.to_sym]
feature_name.blank? || procedure.feature_enabled?(feature_name)
end

def filter_type_champ(type_champ)
Expand Down
14 changes: 14 additions & 0 deletions app/controllers/instructeurs/dossiers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,20 @@ def print
render layout: "print"
end

def annotation
@dossier = dossier_with_champs(pj_template: false)
annotation = @dossier.champs_private_all.find(params[:annotation_id])

respond_to do |format|
format.turbo_stream do
@to_show, @to_hide = []
@to_update = [annotation]

render :update_annotations
end
end
end

def telecharger_pjs
files = ActiveStorage::DownloadableFile.create_list_from_dossiers(Dossier.where(id: dossier.id), with_champs_private: true, include_infos_administration: true)
cleaned_files = ActiveStorage::DownloadableFile.cleanup_list_from_dossier(files)
Expand Down
41 changes: 34 additions & 7 deletions app/controllers/users/dossiers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ class DossiersController < UserController
INSTANCE_ACIONS_ALLOWED_TO_OWNER_OR_INVITE = []

ACTIONS_ALLOWED_TO_ANY_USER = [:index, :recherche, :new, :transferer_all] + INSTANCE_ACTIONS_ALLOWED_TO_ANY_USER
ACTIONS_ALLOWED_TO_OWNER_OR_INVITE = [:show, :destroy, :demande, :messagerie, :brouillon, :submit_brouillon, :submit_en_construction, :modifier, :modifier_legacy, :update, :create_commentaire, :papertrail, :restore] + INSTANCE_ACIONS_ALLOWED_TO_OWNER_OR_INVITE
ACTIONS_ALLOWED_TO_OWNER_OR_INVITE = [:show, :destroy, :demande, :messagerie, :brouillon, :submit_brouillon, :submit_en_construction, :modifier, :modifier_legacy, :update, :create_commentaire, :papertrail, :restore, :champ] + INSTANCE_ACIONS_ALLOWED_TO_OWNER_OR_INVITE

before_action :ensure_ownership!, except: ACTIONS_ALLOWED_TO_ANY_USER + ACTIONS_ALLOWED_TO_OWNER_OR_INVITE
before_action :ensure_ownership_or_invitation!, only: ACTIONS_ALLOWED_TO_OWNER_OR_INVITE
before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update_siret, :brouillon, :submit_brouillon, :submit_en_construction, :modifier, :modifier_legacy, :update]
before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update_siret, :brouillon, :submit_brouillon, :submit_en_construction, :modifier, :modifier_legacy, :update, :champ]
before_action :ensure_dossier_can_be_filled, only: [:brouillon, :modifier, :submit_brouillon, :submit_en_construction, :update]
before_action :ensure_dossier_can_be_viewed, only: [:show]
before_action :forbid_invite_submission!, only: [:submit_brouillon]
Expand Down Expand Up @@ -289,6 +289,20 @@ def merci
@dossier = current_user.dossiers.includes(:procedure).find(params[:id])
end

def champ
@dossier = dossier_with_champs(pj_template: false)
champ = @dossier.champs_public_all.find(params[:champ_id])

respond_to do |format|
format.turbo_stream do
@to_show, @to_hide = []
@to_update = [champ]

render :update, layout: false
end
end
end

def create_commentaire
@commentaire = CommentaireService.create(current_user, dossier, commentaire_params)

Expand Down Expand Up @@ -470,17 +484,30 @@ def page

def champs_public_params
champs_params = params.require(:dossier).permit(champs_public_attributes: [
:id, :value, :value_other, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :identifiant, :numero_fiscal, :reference_avis, :ine, :piece_justificative_file, :code_departement, value: [],
champs_attributes: [
:id, :_destroy, :value, :value_other, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :identifiant, :numero_fiscal, :reference_avis, :ine, :piece_justificative_file, :code_departement, value: []
] + TypeDeChamp::INSTANCE_CHAMPS_PARAMS
:id,
:value,
:value_other,
:external_id,
:primary_value,
:secondary_value,
:numero_allocataire,
:code_postal,
:identifiant,
:numero_fiscal,
:reference_avis,
:ine,
:piece_justificative_file,
:code_departement,
:accreditation_number,
:accreditation_birthdate,
value: []
] + TypeDeChamp::INSTANCE_CHAMPS_PARAMS)
champs_params[:champs_public_all_attributes] = champs_params.delete(:champs_public_attributes) || {}
champs_params
end

def dossier_scope
if action_name == 'update'
if action_name == 'update' || action_name == 'champ'
Dossier.visible_by_user.or(Dossier.for_procedure_preview).or(Dossier.for_editing_fork)
elsif action_name == 'restore'
Dossier.hidden_by_user
Expand Down
1 change: 1 addition & 0 deletions app/graphql/api/v2/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def self.resolve_type(type_definition, object, ctx)
Types::Champs::Descriptor::CiviliteChampDescriptorType,
Types::Champs::Descriptor::CnafChampDescriptorType,
Types::Champs::Descriptor::CodePostalDePolynesieChampDescriptorType,
Types::Champs::Descriptor::COJOChampDescriptorType,
Types::Champs::Descriptor::CommuneChampDescriptorType,
Types::Champs::Descriptor::CommuneDePolynesieChampDescriptorType,
Types::Champs::Descriptor::DateChampDescriptorType,
Expand Down
33 changes: 33 additions & 0 deletions app/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,34 @@ exceed the size of a 32-bit integer, it's encoded as a string.
"""
scalar BigInt

type COJOChampDescriptor implements ChampDescriptor {
"""
Description des champs d’un bloc répétable.
"""
champDescriptors: [ChampDescriptor!] @deprecated(reason: "Utilisez le champ `RepetitionChampDescriptor.champ_descriptors` à la place.")

"""
Description du champ.
"""
description: String
id: ID!

"""
Libellé du champ.
"""
label: String!

"""
Est-ce que le champ est obligatoire ?
"""
required: Boolean!

"""
Type de la valeur du champ.
"""
type: TypeDeChamp! @deprecated(reason: "Utilisez le champ `__typename` à la place.")
}

type CarteChamp implements Champ {
geoAreas: [GeoArea!]!
id: ID!
Expand Down Expand Up @@ -3988,6 +4016,11 @@ enum TypeDeChamp {
"""
code_postal_de_polynesie

"""
Accréditation Paris 2024
"""
cojo

"""
Commune de Polynésie
"""
Expand Down
Loading

0 comments on commit 50ca6e7

Please sign in to comment.