From d106f2afd71507413635a98a3b7d5167284fe85d Mon Sep 17 00:00:00 2001 From: Eric Leroy-Terquem Date: Thu, 3 Aug 2023 10:36:09 +0200 Subject: [PATCH 1/7] feat(routing): add a warning if option added to tdc used by routing rules --- .../revision_changes_component.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/procedure/revision_changes_component/revision_changes_component.html.haml b/app/components/procedure/revision_changes_component/revision_changes_component.html.haml index 8325a5c41e7..2c658e62daf 100644 --- a/app/components/procedure/revision_changes_component/revision_changes_component.html.haml +++ b/app/components/procedure/revision_changes_component/revision_changes_component.html.haml @@ -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 From 8fc6930d9b5e5cc2b688452bb306e2104f6f259f Mon Sep 17 00:00:00 2001 From: Eric Leroy-Terquem Date: Thu, 3 Aug 2023 14:01:05 +0200 Subject: [PATCH 2/7] feat(routing): add a warning at publication if groups with invalid routing rules --- .../revision_changes_component.fr.yml | 1 + .../revision_changes_component.html.haml | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/app/components/procedure/revision_changes_component/revision_changes_component.fr.yml b/app/components/procedure/revision_changes_component/revision_changes_component.fr.yml index cd7dcb4e07e..518dc49a047 100644 --- a/app/components/procedure/revision_changes_component/revision_changes_component.fr.yml +++ b/app/components/procedure/revision_changes_component/revision_changes_component.fr.yml @@ -9,6 +9,7 @@ fr: other: "%{count} dossiers en cours de traitement portent ce champ. Les données associées avec ce champ seront supprimées." 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é. diff --git a/app/components/procedure/revision_changes_component/revision_changes_component.html.haml b/app/components/procedure/revision_changes_component/revision_changes_component.html.haml index 2c658e62daf..31d4ec80247 100644 --- a/app/components/procedure/revision_changes_component/revision_changes_component.html.haml +++ b/app/components/procedure/revision_changes_component/revision_changes_component.html.haml @@ -148,3 +148,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") From b5f721912f02d06712190e2193c9dab73de76fc4 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 3 Aug 2023 11:06:40 +0200 Subject: [PATCH 3/7] fix(dossier): removing options from multiselect should update conditions --- app/controllers/champs/options_controller.rb | 8 ++++++-- app/views/champs/options/remove.turbo_stream.haml | 4 +--- .../dossiers/update_annotations.turbo_stream.haml | 9 +-------- .../dossiers/_update_champs.turbo_stream.haml | 15 +++++++++++++++ app/views/users/dossiers/update.turbo_stream.haml | 15 +-------------- 5 files changed, 24 insertions(+), 27 deletions(-) create mode 100644 app/views/shared/dossiers/_update_champs.turbo_stream.haml diff --git a/app/controllers/champs/options_controller.rb b/app/controllers/champs/options_controller.rb index 4f55ce070b6..9629865a366 100644 --- a/app/controllers/champs/options_controller.rb +++ b/app/controllers/champs/options_controller.rb @@ -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 diff --git a/app/views/champs/options/remove.turbo_stream.haml b/app/views/champs/options/remove.turbo_stream.haml index b8c303ff193..679c610de07 100644 --- a/app/views/champs/options/remove.turbo_stream.haml +++ b/app/views/champs/options/remove.turbo_stream.haml @@ -1,3 +1 @@ -= fields_for @champ.input_name, @champ do |form| - = turbo_stream.replace @champ.input_group_id do - = render EditableChamp::EditableChampComponent.new champ: @champ, form: += render partial: 'shared/dossiers/update_champs', locals: { to_show: @to_show, to_hide: @to_hide, to_update: @to_update } diff --git a/app/views/instructeurs/dossiers/update_annotations.turbo_stream.haml b/app/views/instructeurs/dossiers/update_annotations.turbo_stream.haml index 83ca04a5dd1..679c610de07 100644 --- a/app/views/instructeurs/dossiers/update_annotations.turbo_stream.haml +++ b/app/views/instructeurs/dossiers/update_annotations.turbo_stream.haml @@ -1,8 +1 @@ -- if @to_show.present? - = turbo_stream.show_all(@to_show) -- if @to_hide.present? - = turbo_stream.hide_all(@to_hide) -- @to_update.each do |champ| - = fields_for champ.input_name, champ do |form| - = turbo_stream.replace champ.input_group_id do - = render EditableChamp::EditableChampComponent.new champ:, form: += render partial: 'shared/dossiers/update_champs', locals: { to_show: @to_show, to_hide: @to_hide, to_update: @to_update } diff --git a/app/views/shared/dossiers/_update_champs.turbo_stream.haml b/app/views/shared/dossiers/_update_champs.turbo_stream.haml new file mode 100644 index 00000000000..f3ce3e5f203 --- /dev/null +++ b/app/views/shared/dossiers/_update_champs.turbo_stream.haml @@ -0,0 +1,15 @@ +- if to_show.present? + = turbo_stream.show_all(to_show) +- if to_hide.present? + = turbo_stream.hide_all(to_hide) +- to_update.each do |champ| + = fields_for champ.input_name, champ do |form| + - if champ.refresh_after_update? + = turbo_stream.replace champ.input_group_id do + = render EditableChamp::EditableChampComponent.new champ:, form: + - else + = turbo_stream.update champ.labelledby_id do + = render EditableChamp::ChampLabelContentComponent.new champ:, form: + += turbo_stream.remove_all(".editable-champ .spinner-removable") += turbo_stream.hide_all(".editable-champ .spinner") diff --git a/app/views/users/dossiers/update.turbo_stream.haml b/app/views/users/dossiers/update.turbo_stream.haml index e998f507c1d..b7c234b2325 100644 --- a/app/views/users/dossiers/update.turbo_stream.haml +++ b/app/views/users/dossiers/update.turbo_stream.haml @@ -1,17 +1,4 @@ -- if @to_show.present? - = turbo_stream.show_all(@to_show) -- if @to_hide.present? - = turbo_stream.hide_all(@to_hide) -- @to_update.each do |champ| - = fields_for champ.input_name, champ do |form| - - if champ.refresh_after_update? - = turbo_stream.replace champ.input_group_id do - = render EditableChamp::EditableChampComponent.new champ:, form: - - else - = turbo_stream.update champ.labelledby_id do - = render EditableChamp::ChampLabelContentComponent.new champ:, form: += render partial: 'shared/dossiers/update_champs', locals: { to_show: @to_show, to_hide: @to_hide, to_update: @to_update, dossier: @dossier, annotation: false } -= turbo_stream.remove_all(".editable-champ .spinner-removable"); -= turbo_stream.hide_all(".editable-champ .spinner"); = turbo_stream.replace_all '.dossier-edit-sticky-footer' do = render Dossiers::EditFooterComponent.new(dossier: @dossier, annotation: false) From 813018e9b7b226c53e918d054bcb2ad5fda7cc07 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 3 Aug 2023 17:48:40 +0200 Subject: [PATCH 4/7] chore(coldwired): update to enable style attribute preservation --- package.json | 6 +++--- yarn.lock | 30 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index 6efef06ab5e..8228a19cef4 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "dependencies": { - "@coldwired/actions": "^0.11.0", - "@coldwired/turbo-stream": "^0.11.0", - "@coldwired/utils": "^0.10.0", + "@coldwired/actions": "^0.11.1", + "@coldwired/turbo-stream": "^0.11.1", + "@coldwired/utils": "^0.11.1", "@gouvfr/dsfr": "^1.7.2", "@graphiql/plugin-explorer": "^0.2.0", "@graphiql/toolkit": "^0.8.4", diff --git a/yarn.lock b/yarn.lock index 8daafad1595..d4d42c039ea 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1155,28 +1155,28 @@ "@babel/helper-validator-identifier" "^7.19.1" to-fast-properties "^2.0.0" -"@coldwired/actions@^0.11.0": - version "0.11.0" - resolved "https://registry.yarnpkg.com/@coldwired/actions/-/actions-0.11.0.tgz#b50f833074ff4cd0b80afe022efb9c44b048b21a" - integrity sha512-IIF1fCCPWRywUfF1nG0QvOzjqKZWKBoniyS2qEJbejpE5FB17eohLIG4GZpkxFtzW+yb96ASRcqAFYcmMEjmYQ== +"@coldwired/actions@^0.11.1": + version "0.11.1" + resolved "https://registry.yarnpkg.com/@coldwired/actions/-/actions-0.11.1.tgz#1e2c387dcaadfd4d1d319a9611ab46695ad0726d" + integrity sha512-1KX5sjFCtOiLawxCUIq/oYboVE6t6ELKXJto+E7uMmERoHN/2lrr0JmmX5bIsjaHGeqTzZUweOa7Sp705kexIQ== dependencies: - "@coldwired/utils" "^0.10.0" + "@coldwired/utils" "^0.11.1" morphdom "^2.7.0" tiny-invariant "^1.3.1" -"@coldwired/turbo-stream@^0.11.0": - version "0.11.0" - resolved "https://registry.yarnpkg.com/@coldwired/turbo-stream/-/turbo-stream-0.11.0.tgz#fef5338cf95c5e331aa229c5edda92383bc6a05d" - integrity sha512-Ty1xvjBzqp9dXZfibH6mYTgESmccxe6utG9wZbla+GcsibgCDJJ7NWQEs13RNUhVeCeSRyDL8Ho//UpwqFUEHg== +"@coldwired/turbo-stream@^0.11.1": + version "0.11.1" + resolved "https://registry.yarnpkg.com/@coldwired/turbo-stream/-/turbo-stream-0.11.1.tgz#0f0f710422f61700cb8d8d8368799dbce64dd083" + integrity sha512-i8ubx6EeLAw84KGYxnxZUlEgVidBmAMCItZcgM3fpv9EN6f4tt3rc53sA+0wAECeZoP6FmqvkNxlPuFIMlBo3A== dependencies: - "@coldwired/actions" "^0.11.0" - "@coldwired/utils" "^0.10.0" + "@coldwired/actions" "^0.11.1" + "@coldwired/utils" "^0.11.1" tiny-invariant "^1.3.1" -"@coldwired/utils@^0.10.0": - version "0.10.0" - resolved "https://registry.yarnpkg.com/@coldwired/utils/-/utils-0.10.0.tgz#9d7fd3b3abc437db39abf714b263b55afa2fcc43" - integrity sha512-5rbSe+k60GgXb55uVvqloest7JWSdSIwRCSirs/u7JWWv6UP+UuYEYQjCpgQVTqBNwYMXiaB843VnWApxsf8oQ== +"@coldwired/utils@^0.11.1": + version "0.11.1" + resolved "https://registry.yarnpkg.com/@coldwired/utils/-/utils-0.11.1.tgz#d126246ab66591467e9e4c765769f133f6236ddb" + integrity sha512-vuW1hVhD5U4NX/0dl+fT4RL92T5fEITwc9l/DnaBoP5SAuCAVRnHCWcdyROGz55E4WvSXFqAHD6qkxRwOKG2og== "@emotion/is-prop-valid@^0.8.2": version "0.8.8" From e584edeb16cf289818cd0ee65278950b4cd9e6e6 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Mon, 7 Aug 2023 17:11:02 +0200 Subject: [PATCH 5/7] graphql(attachment): prevent null errors --- app/graphql/extensions/attachment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/graphql/extensions/attachment.rb b/app/graphql/extensions/attachment.rb index c0612d8fbdb..633d7a01133 100644 --- a/app/graphql/extensions/attachment.rb +++ b/app/graphql/extensions/attachment.rb @@ -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 From cd85bad37988876ada7eb5a44bcc70a64cc2a972 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Mon, 7 Aug 2023 17:11:32 +0200 Subject: [PATCH 6/7] graphql(query): expose __typename and timestamps one some nodes --- app/graphql/api/v2/stored_query.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/graphql/api/v2/stored_query.rb b/app/graphql/api/v2/stored_query.rb index 9111d77c0c7..5650db3fb2c 100644 --- a/app/graphql/api/v2/stored_query.rb +++ b/app/graphql/api/v2/stored_query.rb @@ -242,6 +242,7 @@ def self.get(query_id) } fragment DossierFragment on Dossier { + __typename id number archived @@ -463,6 +464,7 @@ def self.get(query_id) __typename label stringValue + updatedAt ... on DateChamp { date } @@ -592,11 +594,13 @@ def self.get(query_id) fragment FileFragment on File { + __typename filename contentType checksum byteSize: byteSizeBigInt url + createdAt } fragment AddressFragment on Address { @@ -643,6 +647,7 @@ def self.get(query_id) fragment PageInfoFragment on PageInfo { hasPreviousPage hasNextPage + startCursor endCursor } GRAPHQL From 81d544c5a4614dd6c3f125d7049ff03c2141e1f6 Mon Sep 17 00:00:00 2001 From: Christophe Robillard Date: Wed, 9 Aug 2023 15:37:33 +0200 Subject: [PATCH 7/7] improve wording --- app/views/user_mailer/invite_instructeur.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/user_mailer/invite_instructeur.html.haml b/app/views/user_mailer/invite_instructeur.html.haml index 2d597f427ce..996d00505a9 100644 --- a/app/views/user_mailer/invite_instructeur.html.haml +++ b/app/views/user_mailer/invite_instructeur.html.haml @@ -7,7 +7,7 @@ Vous venez d’être nommé instructeur sur #{APPLICATION_NAME}. %p - Votre compte a été créé pour l'adresse email #{@user.email}. Pour l’activer, je vous invite à cliquer sur le lien suivant :  + Votre compte a été créé pour l'adresse email #{@user.email}. Pour l’activer, nous vous invitons à cliquer sur le lien suivant :  = link_to(users_activate_url(token: @reset_password_token), users_activate_url(token: @reset_password_token)) %p