Skip to content

Commit

Permalink
Merge branch 'feature/import-2023-10-01-2'
Browse files Browse the repository at this point in the history
  • Loading branch information
maatinito committed Jan 9, 2024
2 parents ce246df + 6cc09fb commit f54730f
Show file tree
Hide file tree
Showing 158 changed files with 353 additions and 2,122 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ group :test do
end

group :development do
gem 'annotate'
gem 'brakeman', require: false
gem 'haml-lint'
gem 'letter_opener_web'
Expand Down
4 changes: 0 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ GEM
aes_key_wrap (1.1.0)
after_party (1.11.2)
anchored (1.1.0)
annotate (3.2.0)
activerecord (>= 3.2, < 8.0)
rake (>= 10.4, < 14.0)
ast (2.4.2)
attr_required (1.0.1)
aws-eventstream (1.1.0)
Expand Down Expand Up @@ -839,7 +836,6 @@ DEPENDENCIES
administrate-field-enum
after_party
anchored
annotate
aws-sdk-s3
axe-core-rspec
bcrypt
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/02_utils.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
white-space: nowrap;
}

.width-max-content {
width: max-content;
}

// sizing
.width-100 {
width: 100%;
Expand Down
32 changes: 2 additions & 30 deletions app/assets/stylesheets/invites_form.scss
Original file line number Diff line number Diff line change
@@ -1,34 +1,6 @@
@import "constants";

#invites-form {
padding: $default-padding;
text-align: left;

form {
display: flex;
margin-top: $default-padding;
}

h4 {
font-weight: bold;
margin-bottom: $default-spacer;
}

p {
margin-bottom: $default-spacer;
}

ul {
list-style-position: inside;
list-style-type: disc;
margin-bottom: $default-padding;
}

input[type=email] {
margin-bottom: $default-spacer;
}

.button {
margin-left: $default-spacer;
@media (min-width: 48em) {
min-width: 400px;
}
}
9 changes: 9 additions & 0 deletions app/components/dsfr/input_errorable.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
module Dsfr
module InputErrorable
extend ActiveSupport::Concern

included do
delegate :object, to: :@form
delegate :errors, to: :object

renders_one :hint

private

# lookup for edge case from `form.rich_text_area`
Expand Down Expand Up @@ -89,6 +92,10 @@ def map_array_to_hash_with_true(array_or_string_or_nil)
end

def hint
get_slot(:hint).presence || default_hint
end

def default_hint
I18n.t("activerecord.attributes.#{object.class.name.underscore}.hints.#{@attribute}")
end

Expand All @@ -101,6 +108,8 @@ def email?
end

def hint?
return true if get_slot(:hint).present?

I18n.exists?("activerecord.attributes.#{object.class.name.underscore}.hints.#{@attribute}")
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ def available_values_for_select(targeted_champ)
return [] if targeted_champ.is_a?(Logic::Empty)
targeted_champ
.options(@revision.types_de_champ_public)
.map { |tdc| [tdc.first, constant(tdc.first).to_json] }
.map { |(label, value)| [label, constant(value).to_json] }
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fr:
other: "%{count} dossiers en cours de traitement portent ce champ. Les <strong>données</strong> associées avec ce champ seront <strong>supprimées</strong>."
add_option: "ajoutés : %{items}"
remove_option: "supprimés : %{items}"
invalid_routing_rules_alert: "Certains groupes d'instructeurs ont une règle de routage invalide. Veuillez mettre à jour la configuration des groupes d'instructeurs après avoir publié les modifications."
public:
add: Le champ « %{label} » a été ajouté.
add_mandatory: Le champ obligatoire « %{label} » a été ajouté.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
- if !total_dossiers.zero? && !change.can_rebase?
.fr-alert.fr-alert--warning.fr-mt-1v
%p= t('.breaking_change', count: total_dossiers)
- if removed.present? && change.type_de_champ.used_by_routing_rules?
- if (removed.present? || added.present? ) && change.type_de_champ.used_by_routing_rules?
.fr-alert.fr-alert--warning.fr-mt-1v
= t(".#{prefix}.update_drop_down_options_alert", label: change.label)
- when :drop_down_other
Expand Down Expand Up @@ -165,3 +165,7 @@
- if @private_move_changes.present?
- list.with_item do
= t(".private.move", count: @private_move_changes.size)
- if @previous_revision.procedure.groupe_instructeurs.any?(&:invalid_rule?)
- list.with_item do
.fr-alert.fr-alert--warning.fr-mt-1v
= t(".invalid_routing_rules_alert")
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
= form_tag(search_admin_procedures_path, data: { turbo: true }, method: :post, class: 'form') do
= label_tag :query, 'Rechercher une procédure'
= form_tag(search_admin_procedures_path, data: { turbo: true }, method: :post) do
.fr-input-group
= label_tag :query, class: "fr-label" do
Rechercher une démarche
%span.fr-hint-text Saisissez au moins 3 lettres

.notice
%p Entrez au minimum 3 lettres


= text_field_tag :query, params[:query], required: true, placeholder: 'politique de la ville', minlength: "3"
= text_field_tag :query, params[:query], required: true, placeholder: 'politique de la ville', minlength: "3", class: "fr-input"

= submit_tag 'Rechercher', class: 'fr-btn'

Expand Down
18 changes: 14 additions & 4 deletions app/controllers/administrateurs/groupe_instructeurs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,22 @@ def create_simple_routing

tdc = @procedure.active_revision.routable_types_de_champ.find { |tdc| tdc.stable_id == stable_id }

tdc_options = tdc.options["drop_down_options"].reject(&:empty?)
tdc_options = tdc.drop_down_options.reject(&:empty?)

tdc_options.each do |option_label|
gi = @procedure.groupe_instructeurs.find_by({ label: option_label }) || @procedure.groupe_instructeurs
.create({ label: option_label, instructeurs: [current_administrateur.instructeur] })
gi.update(routing_rule: ds_eq(champ_value(stable_id), constant(gi.label)))
routing_rule = ds_eq(champ_value(stable_id), constant(option_label))
@procedure
.groupe_instructeurs
.find_or_create_by(label: option_label)
.update(instructeurs: [current_administrateur.instructeur], routing_rule:)
end

if tdc.drop_down_other?
routing_rule = ds_eq(champ_value(stable_id), constant(Champs::DropDownListChamp::OTHER))
@procedure
.groupe_instructeurs
.find_or_create_by(label: 'Autre')
.update(instructeurs: [current_administrateur.instructeur], routing_rule:)
end

@procedure.toggle_routing
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/api/v2/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def authenticate_administrateur_from_token

def api_token
if @api_token.nil?
@api_token = APIToken.find_and_verify(authorization_bearer_token) || false
@api_token = APIToken
.find_and_verify(authorization_bearer_token)
&.tap { _1.touch(:last_v2_authenticated_at) } || false
end
@api_token
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class APIController < ApplicationController
def find_administrateur_for_token(procedure)
api_token = APIToken.find_and_verify(authorization_bearer_token, procedure.administrateurs)
if api_token.present? && api_token.context.fetch(:procedure_ids).include?(procedure.id)
api_token.touch(:last_v1_authenticated_at)
api_token.administrateur
end
end
Expand Down
8 changes: 6 additions & 2 deletions app/controllers/champs/options_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
class Champs::OptionsController < ApplicationController
include TurboChampsConcern

before_action :authenticate_logged_user!

def remove
@champ = policy_scope(Champ).includes(:champs).find(params[:champ_id])
@champ.remove_option([params[:option]].compact)
champ = policy_scope(Champ).includes(:champs).find(params[:champ_id])
champ.remove_option([params[:option]].compact)
champs = champ.private? ? champ.dossier.champs_private_all : champ.dossier.champs_public_all
@to_show, @to_hide, @to_update = champs_to_turbo_update({ params[:champ_id] => true }, champs)
end
end
2 changes: 2 additions & 0 deletions app/controllers/users/commencer_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def commencer
store_user_location!(@procedure, @prefilled_dossier)
end

@usual_traitement_time = @procedure.stats_usual_traitement_time

render 'commencer/show'
end

Expand Down
6 changes: 5 additions & 1 deletion app/dashboards/user_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class UserDashboard < Administrate::BaseDashboard
confirmed?: Field::Boolean,
created_at: Field::DateTime,
updated_at: Field::DateTime,
blocked_at: Field::DateTime,
blocked_reason: Field::String,
current_sign_in_at: Field::DateTime,
dossiers: Field::HasMany
}.freeze
Expand All @@ -36,7 +38,9 @@ class UserDashboard < Administrate::BaseDashboard
:email,
:confirmed?,
:current_sign_in_at,
:created_at
:created_at,
:blocked_at,
:blocked_reason
].freeze

# FORM_ATTRIBUTES
Expand Down
8 changes: 8 additions & 0 deletions app/graphql/api/v2/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,28 @@ def query_info
{
graphql_query: query.query_string,
graphql_variables: query.provided_variables&.to_json,
graphql_mutation: mutation?,
graphql_null_error: errors.any? { _1.is_a? GraphQL::InvalidNullError }.presence,
graphql_timeout_error: errors.any? { _1.is_a? GraphQL::Schema::Timeout::TimeoutError }.presence
}.compact
end

private

def mutation?
query.lookahead.selections.any? { _1.field.type.respond_to?(:mutation) }.presence
rescue
false
end

def compute_demarche_authorization(demarche)
# procedure_ids and token are passed from graphql controller
if self[:procedure_ids].present?
self[:procedure_ids].include?(demarche.id)
elsif self[:token].present?
token = APIToken.find_and_verify(self[:token], demarche.administrateurs)
if token.present?
token.touch(:last_v2_authenticated_at)
Current.user = token.administrateur.user
true
else
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/api/v2/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def handle_timeout(error, query)
end
end

use Timeout, max_seconds: 10
use Timeout, max_seconds: 30
use GraphQL::Batch
use GraphQL::Backtrace

Expand Down
17 changes: 15 additions & 2 deletions app/graphql/api/v2/stored_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def self.get(query_id)
$includeInstructeurs: Boolean = true
$includeAvis: Boolean = false
$includeMessages: Boolean = false
$includeCorrections: Boolean = false
$includeGeometry: Boolean = false
) {
demarche(number: $demarcheNumber) {
Expand Down Expand Up @@ -135,6 +136,7 @@ def self.get(query_id)
$includeInstructeurs: Boolean = true
$includeAvis: Boolean = false
$includeMessages: Boolean = false
$includeCorrections: Boolean = false
$includeGeometry: Boolean = false
) {
groupeInstructeur(number: $groupeInstructeurNumber) {
Expand Down Expand Up @@ -201,6 +203,7 @@ def self.get(query_id)
$includeInstructeurs: Boolean = true
$includeAvis: Boolean = false
$includeMessages: Boolean = false
$includeCorrections: Boolean = false
$includeGeometry: Boolean = false
) {
dossier(number: $dossierNumber) {
Expand Down Expand Up @@ -239,6 +242,7 @@ def self.get(query_id)
}
fragment DossierFragment on Dossier {
__typename
id
number
archived
Expand All @@ -250,6 +254,7 @@ def self.get(query_id)
dateTraitement
dateExpiration
dateSuppressionParUsager
dateDerniereCorrectionEnAttente @include(if: $includeCorrections)
motivation
motivationAttachment {
...FileFragment
Expand Down Expand Up @@ -318,8 +323,8 @@ def self.get(query_id)
dateFermeture
notice { url }
deliberation { url }
demarcheUrl
cadreJuridiqueUrl
demarcheURL
cadreJuridiqueURL
service @include(if: $includeService) {
...ServiceFragment
}
Expand Down Expand Up @@ -409,6 +414,10 @@ def self.get(query_id)
attachments {
...FileFragment
}
correction @include(if: $includeCorrections) {
reason
dateResolution
}
}
fragment GeoAreaFragment on GeoArea {
Expand Down Expand Up @@ -455,6 +464,7 @@ def self.get(query_id)
__typename
label
stringValue
updatedAt
... on DateChamp {
date
}
Expand Down Expand Up @@ -584,11 +594,13 @@ def self.get(query_id)
fragment FileFragment on File {
__typename
filename
contentType
checksum
byteSize: byteSizeBigInt
url
createdAt
}
fragment AddressFragment on Address {
Expand Down Expand Up @@ -635,6 +647,7 @@ def self.get(query_id)
fragment PageInfoFragment on PageInfo {
hasPreviousPage
hasNextPage
startCursor
endCursor
}
GRAPHQL
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/extensions/attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def resolve(object:, **_rest)
# is a lazy value (e.g., a Promise – like in our case)
def after_resolve(value:, **_rest)
if value.respond_to?(:map)
attachments = value.map { after_resolve_attachment(_1) }
attachments = value.map { after_resolve_attachment(_1) }.compact

if options[:as] == :single
attachments.first
Expand Down
Loading

0 comments on commit f54730f

Please sign in to comment.