Skip to content

Commit

Permalink
Merge branch 'feature/import-2023-07-10-02'
Browse files Browse the repository at this point in the history
  • Loading branch information
maatinito committed Sep 20, 2023
2 parents 1839c4a + eba5de4 commit 4d6134c
Show file tree
Hide file tree
Showing 71 changed files with 1,111 additions and 360 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,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 @@ -852,6 +859,7 @@ DEPENDENCIES
devise-two-factor
discard
dotenv-rails
dry-monads
elastic-apm
factory_bot
flipper
Expand Down
17 changes: 0 additions & 17 deletions app/assets/stylesheets/admin-procedures-list.scss

This file was deleted.

2 changes: 1 addition & 1 deletion app/assets/stylesheets/buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
text-align: left;
top: 5 * $default-spacer;
cursor: default;
z-index: 10;
z-index: 11;
list-style: none;

a {
Expand Down
22 changes: 14 additions & 8 deletions app/assets/stylesheets/card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,26 @@
.card {
padding: ($default-spacer * 3) ($default-spacer * 2);
border: 1px solid $border-grey;
margin-bottom: $default-spacer * 2;
margin-bottom: $default-spacer * 4;
background: #FFFFFF;

.notice {
font-size: 16px;
color: #666666;
margin-top: -8px;
margin-bottom: 16px;
}

.card-title {
color: $black;
font-weight: bold;
font-size: 20px;
line-height: 1.5rem;
margin-bottom: $default-spacer * 2;

a:not(:hover) {
background-image: none; // remove DSFR underline
}
}

.logo {
width: auto;
max-width: 50px;
height: fit-content;
margin-right: $default-spacer * 2;
}

&.feedback {
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/flex.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
align-items: flex-start;
}

&.align-end {
align-items: end;
}

&.align-baseline {
align-items: baseline;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
= 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)
Expand Down
11 changes: 8 additions & 3 deletions app/components/dsfr/alert_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,25 @@ def prefix_for_state
end

def alert_class(state)
["fr-alert fr-alert--#{state}", extra_class_names].compact.flatten
class_names(
"fr-alert fr-alert--#{state}" => true,
"fr-alert--sm" => size == :sm,
extra_class_names => true
)
end

private

def initialize(state:, title:, extra_class_names: nil, heading_level: 'h3')
def initialize(state:, title: '', size: '', extra_class_names: nil, heading_level: 'h3')
@state = state
@title = title
@size = size
@block = block
@extra_class_names = extra_class_names
@heading_level = heading_level
end

attr_reader :state, :title, :block, :extra_class_names, :heading_level
attr_reader :state, :title, :size, :block, :extra_class_names, :heading_level

private
end
5 changes: 3 additions & 2 deletions app/components/dsfr/alert_component/alert_component.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
%div{ class: alert_class(state) }
= content_tag(heading_level, class: 'fr-alert__title') do
= "#{prefix_for_state}#{title}"
- if size != :sm
= content_tag(heading_level, class: 'fr-alert__title') do
= "#{prefix_for_state}#{title}"
= body
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? || feature_enabled?(feature_name) || 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
51 changes: 39 additions & 12 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 All @@ -31,9 +31,9 @@ def index
@dossiers_invites = current_user.dossiers_invites.merge(dossiers_visibles)
@dossiers_supprimes_recemment = current_user.dossiers.hidden_by_user.merge(dossiers)
@dossiers_supprimes_definitivement = current_user.deleted_dossiers.includes(:procedure).order_by_updated_at
@dossier_transfers = DossierTransfer.for_email(current_user.email)
@dossier_transferes = dossiers_visibles.where(dossier_transfer_id: DossierTransfer.for_email(current_user.email).ids)
@dossiers_close_to_expiration = current_user.dossiers.close_to_expiration.merge(dossiers_visibles)
@statut = statut(@user_dossiers, @dossiers_traites, @dossiers_invites, @dossiers_supprimes_recemment, @dossiers_supprimes_definitivement, @dossier_transfers, @dossiers_close_to_expiration, params[:statut])
@statut = statut(@user_dossiers, @dossiers_traites, @dossiers_invites, @dossiers_supprimes_recemment, @dossiers_supprimes_definitivement, @dossier_transferes, @dossiers_close_to_expiration, params[:statut])

@dossiers = case @statut
when 'en-cours'
Expand All @@ -47,7 +47,7 @@ def index
when 'dossiers-supprimes-definitivement'
@dossiers_supprimes_definitivement
when 'dossiers-transferes'
@dossier_transfers
@dossier_transferes
when 'dossiers-expirant'
@dossiers_close_to_expiration
end.page(page)
Expand Down Expand Up @@ -293,6 +293,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 @@ -411,14 +425,14 @@ def clone
# if the status tab is filled, then this tab
# else first filled tab
# else en-cours
def statut(mes_dossiers, dossiers_traites, dossiers_invites, dossiers_supprimes_recemment, dossiers_supprimes_definitivement, dossier_transfers, dossiers_close_to_expiration, params_statut)
def statut(mes_dossiers, dossiers_traites, dossiers_invites, dossiers_supprimes_recemment, dossiers_supprimes_definitivement, dossier_transferes, dossiers_close_to_expiration, params_statut)
tabs = {
'en-cours' => mes_dossiers.present?,
'traites' => dossiers_traites.present?,
'dossiers-invites' => dossiers_invites.present?,
'dossiers-supprimes-recemment' => dossiers_supprimes_recemment.present?,
'dossiers-supprimes-definitivement' => dossiers_supprimes_definitivement.present?,
'dossiers-transferes' => dossier_transfers.present?,
'dossiers-transferes' => dossier_transferes.present?,
'dossiers-expirant' => dossiers_close_to_expiration.present?
}
if tabs[params_statut]
Expand Down Expand Up @@ -476,17 +490,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
Loading

0 comments on commit 4d6134c

Please sign in to comment.