From cbaa77fca75f3e1368cbb81c74c24de3f29e03fe Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 1 Mar 2023 18:30:10 +0100 Subject: [PATCH 1/3] feat(annotations): activate autosave --- .../dossiers/autosave_footer_component.rb | 15 ++++++++ .../autosave_footer_component.en.yml | 15 ++++++++ .../autosave_footer_component.fr.yml | 15 ++++++++ .../autosave_footer_component.html.haml | 37 +++++++++++++++++++ .../dossiers/edit_footer_component.rb | 7 +++- .../edit_footer_component.html.haml | 7 ++-- .../champ_label_content_component.html.haml | 2 +- .../editable_champ_component.rb | 7 +--- .../types_de_champ_editor/champ_component.rb | 4 -- .../concerns/turbo_champs_concern.rb | 23 ++++++++++++ .../instructeurs/dossiers_controller.rb | 11 ++++-- app/controllers/users/dossiers_controller.rb | 30 ++------------- .../mutations/dossier_modifier_annotation.rb | 2 - .../controllers/autosave_controller.ts | 12 +----- app/models/dossier.rb | 10 ----- .../update_annotations.turbo_stream.haml | 8 ++++ app/views/shared/dossiers/_autosave.html.haml | 25 ------------- app/views/shared/dossiers/_edit.html.haml | 4 +- .../dossiers/_edit_annotations.html.haml | 5 +-- config/i18n-tasks.yml | 1 + config/locales/en.yml | 6 --- config/locales/fr.yml | 6 --- .../editable_champ_component_spec.rb | 6 +-- .../instructeurs/dossiers_controller_spec.rb | 6 +-- 24 files changed, 147 insertions(+), 117 deletions(-) create mode 100644 app/components/dossiers/autosave_footer_component.rb create mode 100644 app/components/dossiers/autosave_footer_component/autosave_footer_component.en.yml create mode 100644 app/components/dossiers/autosave_footer_component/autosave_footer_component.fr.yml create mode 100644 app/components/dossiers/autosave_footer_component/autosave_footer_component.html.haml create mode 100644 app/controllers/concerns/turbo_champs_concern.rb create mode 100644 app/views/instructeurs/dossiers/update_annotations.turbo_stream.haml delete mode 100644 app/views/shared/dossiers/_autosave.html.haml diff --git a/app/components/dossiers/autosave_footer_component.rb b/app/components/dossiers/autosave_footer_component.rb new file mode 100644 index 000000000..e0162bed5 --- /dev/null +++ b/app/components/dossiers/autosave_footer_component.rb @@ -0,0 +1,15 @@ +class Dossiers::AutosaveFooterComponent < ApplicationComponent + include ApplicationHelper + attr_reader :dossier + + def initialize(dossier:, annotation:) + @dossier = dossier + @annotation = annotation + end + + private + + def annotation? + @annotation + end +end diff --git a/app/components/dossiers/autosave_footer_component/autosave_footer_component.en.yml b/app/components/dossiers/autosave_footer_component/autosave_footer_component.en.yml new file mode 100644 index 000000000..7ed3e245e --- /dev/null +++ b/app/components/dossiers/autosave_footer_component/autosave_footer_component.en.yml @@ -0,0 +1,15 @@ +--- +en: + brouillon: + explanation: Your draft is automatically saved. + confirmation: Draft saved + error: Impossible to save the draft + en_construction: + explanation: Your file is automatically saved. + confirmation: File saved + error: Impossible to save the file + annotations: + explanation: Your annotations are automatically saved. + confirmation: Annotations saved + error: Impossible to save the annotations + more_information: More informations diff --git a/app/components/dossiers/autosave_footer_component/autosave_footer_component.fr.yml b/app/components/dossiers/autosave_footer_component/autosave_footer_component.fr.yml new file mode 100644 index 000000000..8e1dbad44 --- /dev/null +++ b/app/components/dossiers/autosave_footer_component/autosave_footer_component.fr.yml @@ -0,0 +1,15 @@ +--- +fr: + brouillon: + explanation: Votre brouillon est automatiquement enregistré. + confirmation: Brouillon enregistré + error: Impossible d’enregistrer le brouillon + en_construction: + explanation: Votre dossier est automatiquement enregistré. + confirmation: Dossier enregistré + error: Impossible d’enregistrer le dossier + annotations: + explanation: Vos annotations sont automatiquement enregistrées. + confirmation: Annotations enregistré + error: Impossible d’enregistrer les annotations + more_information: En savoir plus diff --git a/app/components/dossiers/autosave_footer_component/autosave_footer_component.html.haml b/app/components/dossiers/autosave_footer_component/autosave_footer_component.html.haml new file mode 100644 index 000000000..62f95893c --- /dev/null +++ b/app/components/dossiers/autosave_footer_component/autosave_footer_component.html.haml @@ -0,0 +1,37 @@ +.autosave.autosave-state-idle{ data: { controller: 'autosave-status' } } + %p.autosave-explanation.fr-text--sm + %span.autosave-explanation-text + - if annotation? + = t('.annotations.explanation') + - elsif dossier.brouillon? + = t('.brouillon.explanation') + - else + = t('.en_construction.explanation') + - if !annotation? + = link_to t('.more_information'), t("links.common.faq.autosave_url"), class: 'autosave-more-infos fr-link fr-link--sm', **external_link_attributes + + %p.autosave-status.succeeded + %span.autosave-icon.icon.accept + %span.autosave-label + - if annotation? + = t('.annotations.confirmation') + - elsif dossier.brouillon? + = t('.brouillon.confirmation') + - else + = t('.en_construction.confirmation') + - if !annotation? + = link_to t('.more_information'), t("links.common.faq.autosave_url"), class: 'autosave-more-infos fr-link fr-link--sm', **external_link_attributes + + %p.autosave-status.failed + %span.autosave-icon ⚠️ + %span.autosave-label + - if annotation? + = t('.annotations.error') + - elsif dossier.brouillon? + = t('.brouillon.error') + - else + = t('.en_construction.error') + %button.button.small.autosave-retry{ type: :button, data: { action: 'autosave-status#onClickRetryButton', autosave_status_target: 'retryButton' } } + %span.autosave-retry-label réessayer + %span.autosave-retrying-label enregistrement en cours… + diff --git a/app/components/dossiers/edit_footer_component.rb b/app/components/dossiers/edit_footer_component.rb index f0012dd81..6b79fc886 100644 --- a/app/components/dossiers/edit_footer_component.rb +++ b/app/components/dossiers/edit_footer_component.rb @@ -1,6 +1,7 @@ class Dossiers::EditFooterComponent < ApplicationComponent - def initialize(dossier:) + def initialize(dossier:, annotation:) @dossier = dossier + @annotation = annotation end private @@ -9,6 +10,10 @@ class Dossiers::EditFooterComponent < ApplicationComponent controller.current_user.owns?(@dossier) end + def annotation? + @annotation + end + def button_options { class: 'fr-btn fr-btn--sm', diff --git a/app/components/dossiers/edit_footer_component/edit_footer_component.html.haml b/app/components/dossiers/edit_footer_component/edit_footer_component.html.haml index 1d282b0a7..803255861 100644 --- a/app/components/dossiers/edit_footer_component/edit_footer_component.html.haml +++ b/app/components/dossiers/edit_footer_component/edit_footer_component.html.haml @@ -1,12 +1,13 @@ .dossier-edit-sticky-footer .send-dossier-actions-bar - = render partial: 'shared/dossiers/autosave', locals: { dossier: @dossier } + = render Dossiers::AutosaveFooterComponent.new(dossier: @dossier, annotation: annotation?) - - if @dossier.can_transition_to_en_construction? + - if !annotation? && @dossier.can_transition_to_en_construction? = button_to t('.submit'), brouillon_dossier_url(@dossier), button_options - if @dossier.brouillon? && !owner? .send-notice.invite-cannot-submit = t('.invite_notice') - = render partial: "shared/dossiers/submit_is_over", locals: { dossier: @dossier } + - if !annotation? + = render partial: "shared/dossiers/submit_is_over", locals: { dossier: @dossier } diff --git a/app/components/editable_champ/champ_label_content_component/champ_label_content_component.html.haml b/app/components/editable_champ/champ_label_content_component/champ_label_content_component.html.haml index 81c5df6c8..6369facfd 100644 --- a/app/components/editable_champ/champ_label_content_component/champ_label_content_component.html.haml +++ b/app/components/editable_champ/champ_label_content_component/champ_label_content_component.html.haml @@ -8,4 +8,4 @@ - if @champ.rebased_at.present? && @champ.rebased_at > (@seen_at || @champ.updated_at) && current_user.owns_or_invite?(@champ.dossier) %span.updated-at.highlighted - Le type de ce @champ où sa description a été modifiée par l'administration. Vérifier son contenu. + Le type de ce champ ou sa description ont été modifiés par l'administration. Vérifier son contenu. diff --git a/app/components/editable_champ/editable_champ_component.rb b/app/components/editable_champ/editable_champ_component.rb index 2b9391104..622447493 100644 --- a/app/components/editable_champ/editable_champ_component.rb +++ b/app/components/editable_champ/editable_champ_component.rb @@ -28,12 +28,7 @@ class EditableChamp::EditableChampComponent < ApplicationComponent def stimulus_controller if !@champ.block? && @champ.fillable? # This is an editable champ. Lets find what controllers it might need. - controllers = [] - - # This is a public champ – it can have an autosave controller. - if @champ.public? - controllers << 'autosave' - end + controllers = ['autosave'] # This is a dropdown champ. Activate special behaviours it might have. if @champ.simple_drop_down_list? || @champ.linked_drop_down_list? diff --git a/app/components/types_de_champ_editor/champ_component.rb b/app/components/types_de_champ_editor/champ_component.rb index d21c17a9a..856d0d06a 100644 --- a/app/components/types_de_champ_editor/champ_component.rb +++ b/app/components/types_de_champ_editor/champ_component.rb @@ -60,10 +60,6 @@ class TypesDeChampEditor::ChampComponent < ApplicationComponent TypeDeChamp.type_champs .keys - # FIXME - # We can only refresh after update champs when autosave is enabled. And it is disabled for now in private forms. - # So for new we restrict champs that require refresh after update to public forms. - .filter { type_de_champ.public? || !TypeDeChamp.refresh_after_update?(_1) } .filter(&method(:filter_type_champ)) .filter(&method(:filter_featured_type_champ)) .filter(&method(:filter_block_type_champ)) diff --git a/app/controllers/concerns/turbo_champs_concern.rb b/app/controllers/concerns/turbo_champs_concern.rb new file mode 100644 index 000000000..f7e61dd08 --- /dev/null +++ b/app/controllers/concerns/turbo_champs_concern.rb @@ -0,0 +1,23 @@ +module TurboChampsConcern + extend ActiveSupport::Concern + + private + + def champs_to_turbo_update(params, champs) + champ_ids = params.keys.map(&:to_i) + + to_update = champs.filter { _1.id.in?(champ_ids) && _1.refresh_after_update? } + to_show, to_hide = champs.filter(&:conditional?) + .partition(&:visible?) + .map { champs_to_one_selector(_1 - to_update) } + + return to_show, to_hide, to_update + end + + def champs_to_one_selector(champs) + champs + .map(&:input_group_id) + .map { |id| "##{id}" } + .join(',') + end +end diff --git a/app/controllers/instructeurs/dossiers_controller.rb b/app/controllers/instructeurs/dossiers_controller.rb index f013c537a..a55869d72 100644 --- a/app/controllers/instructeurs/dossiers_controller.rb +++ b/app/controllers/instructeurs/dossiers_controller.rb @@ -4,6 +4,7 @@ module Instructeurs include ActionView::Helpers::TextHelper include CreateAvisConcern include DossierHelper + include TurboChampsConcern include ActionController::Streaming include Zipline @@ -244,12 +245,14 @@ module Instructeurs if dossier.champs_private_all.any?(&:changed?) dossier.last_champ_private_updated_at = Time.zone.now end - dossier.save - dossier.log_modifier_annotations!(current_instructeur) + if !dossier.save(context: :annotations) + flash.now.alert = dossier.errors.full_messages + end respond_to do |format| - format.html { redirect_to annotations_privees_instructeur_dossier_path(procedure, dossier) } - format.turbo_stream + format.turbo_stream do + @to_show, @to_hide, @to_update = champs_to_turbo_update(champs_private_params.fetch(:champs_private_all_attributes), dossier.champs_private_all) + end end end diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 5ab9ec3bc..61c777be6 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -1,6 +1,7 @@ module Users class DossiersController < UserController include DossierHelper + include TurboChampsConcern layout 'procedure_context', only: [:identite, :update_identite, :siret, :update_siret] @@ -198,7 +199,7 @@ module Users respond_to do |format| format.html { render :brouillon } format.turbo_stream do - @to_show, @to_hide, @to_update = champs_to_turbo_update + @to_show, @to_hide, @to_update = champs_to_turbo_update(champs_public_params.fetch(:champs_public_all_attributes), dossier.champs_public_all) render(:update, layout: false) end @@ -216,7 +217,7 @@ module Users respond_to do |format| format.html { render :modifier } format.turbo_stream do - @to_show, @to_hide, @to_update = champs_to_turbo_update + @to_show, @to_hide, @to_update = champs_to_turbo_update(champs_public_params.fetch(:champs_public_all_attributes), dossier.champs_public_all) end end end @@ -483,24 +484,6 @@ module Users errors end - def champs_to_turbo_update - champ_ids = champs_public_params - .fetch(:champs_public_all_attributes) - .keys - .map(&:to_i) - - to_update = dossier - .champs_public_all - .filter { _1.id.in?(champ_ids) && _1.refresh_after_update? } - to_show, to_hide = dossier - .champs_public_all - .filter(&:conditional?) - .partition(&:visible?) - .map { champs_to_one_selector(_1 - to_update) } - - return to_show, to_hide, to_update - end - def ensure_ownership! if !current_user.owns?(dossier) forbidden! @@ -561,12 +544,5 @@ module Users submit_validation_options end end - - def champs_to_one_selector(champs) - champs - .map(&:input_group_id) - .map { |id| "##{id}" } - .join(',') - end end end diff --git a/app/graphql/mutations/dossier_modifier_annotation.rb b/app/graphql/mutations/dossier_modifier_annotation.rb index 78a173418..46f8bea3e 100644 --- a/app/graphql/mutations/dossier_modifier_annotation.rb +++ b/app/graphql/mutations/dossier_modifier_annotation.rb @@ -21,8 +21,6 @@ module Mutations end if annotation.save - dossier.log_modifier_annotation!(annotation, instructeur) - { annotation: } else { errors: annotation.errors.full_messages } diff --git a/app/javascript/controllers/autosave_controller.ts b/app/javascript/controllers/autosave_controller.ts index 6f4389af6..9827ce4ea 100644 --- a/app/javascript/controllers/autosave_controller.ts +++ b/app/javascript/controllers/autosave_controller.ts @@ -45,10 +45,7 @@ export class AutosaveController extends ApplicationController { this.#latestPromise = Promise.resolve(); this.onGlobal('autosave:retry', () => this.didRequestRetry()); this.on('change', (event) => this.onChange(event)); - - if (this.saveOnInput) { - this.on('input', (event) => this.onInput(event)); - } + this.on('input', (event) => this.onInput(event)); } disconnect() { @@ -86,8 +83,7 @@ export class AutosaveController extends ApplicationController { this.debounce(this.enqueueAutosaveRequest, AUTOSAVE_DEBOUNCE_DELAY); } else if ( isSelectElement(target) || - isCheckboxOrRadioInputElement(target) || - (!this.saveOnInput && isTextInputElement(target)) + isCheckboxOrRadioInputElement(target) ) { // Wait next tick so champs having JS can interact // with form elements before extracting form data. @@ -138,10 +134,6 @@ export class AutosaveController extends ApplicationController { }, AUTOSAVE_CONDITIONAL_SPINNER_DEBOUNCE_DELAY); } - private get saveOnInput() { - return !!this.form?.dataset.saveOnInput; - } - private didRequestRetry() { if (this.#needsRetry) { this.enqueueAutosaveRequest(); diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 5a1ab913e..7c6597640 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -1062,16 +1062,6 @@ class Dossier < ApplicationRecord end end - def log_modifier_annotations!(instructeur) - champs_private.filter(&:value_previously_changed?).each do |champ| - log_dossier_operation(instructeur, :modifier_annotation, champ) - end - end - - def log_modifier_annotation!(champ, instructeur) - log_dossier_operation(instructeur, :modifier_annotation, champ) - end - def demander_un_avis!(avis) log_dossier_operation(avis.claimant, :demander_un_avis, avis) end diff --git a/app/views/instructeurs/dossiers/update_annotations.turbo_stream.haml b/app/views/instructeurs/dossiers/update_annotations.turbo_stream.haml new file mode 100644 index 000000000..83ca04a5d --- /dev/null +++ b/app/views/instructeurs/dossiers/update_annotations.turbo_stream.haml @@ -0,0 +1,8 @@ +- 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: diff --git a/app/views/shared/dossiers/_autosave.html.haml b/app/views/shared/dossiers/_autosave.html.haml deleted file mode 100644 index 6d4776657..000000000 --- a/app/views/shared/dossiers/_autosave.html.haml +++ /dev/null @@ -1,25 +0,0 @@ -.autosave.autosave-state-idle{ data: { controller: 'autosave-status' } } - %p.autosave-explanation.fr-text--sm - %span.autosave-explanation-text - - if dossier.brouillon? - = t('views.users.dossiers.autosave.draft_explanation') - - else - = t('views.users.dossiers.autosave.explanation') - = link_to t('views.users.dossiers.autosave.more_information'), t("links.common.faq.autosave_url"), class: 'autosave-more-infos fr-link fr-link--sm', **external_link_attributes - - %p.autosave-status.succeeded - %span.autosave-icon.icon.accept - %span.autosave-label - - if dossier.brouillon? - = t('views.users.dossiers.autosave.draft_confirmation') - - else - = t('views.users.dossiers.autosave.confirmation') - = link_to t('views.users.dossiers.autosave.more_information'), t("links.common.faq.autosave_url"), class: 'autosave-more-infos fr-link fr-link--sm', **external_link_attributes - - %p.autosave-status.failed - %span.autosave-icon ⚠️ - %span.autosave-label Impossible d’enregistrer le brouillon - %button.button.small.autosave-retry{ type: :button, data: { action: 'autosave-status#onClickRetryButton', autosave_status_target: 'retryButton' } } - %span.autosave-retry-label réessayer - %span.autosave-retrying-label enregistrement en cours… - diff --git a/app/views/shared/dossiers/_edit.html.haml b/app/views/shared/dossiers/_edit.html.haml index 0c8991525..e6eab415f 100644 --- a/app/views/shared/dossiers/_edit.html.haml +++ b/app/views/shared/dossiers/_edit.html.haml @@ -6,7 +6,7 @@ = render partial: "shared/dossiers/submit_is_over", locals: { dossier: dossier } - if dossier.brouillon? - - form_options = { url: brouillon_dossier_url(dossier), method: :patch, data: { save_on_input: true } } + - form_options = { url: brouillon_dossier_url(dossier), method: :patch } - else - form_options = { url: modifier_dossier_url(dossier), method: :patch } = render Attachment::DeleteFormComponent.new @@ -47,4 +47,4 @@ = fields_for champ.input_name, champ do |form| = render EditableChamp::EditableChampComponent.new form: form, champ: champ - = render Dossiers::EditFooterComponent.new(dossier: dossier) + = render Dossiers::EditFooterComponent.new(dossier: dossier, annotation: false) diff --git a/app/views/shared/dossiers/_edit_annotations.html.haml b/app/views/shared/dossiers/_edit_annotations.html.haml index 654644e0c..9b70a1d36 100644 --- a/app/views/shared/dossiers/_edit_annotations.html.haml +++ b/app/views/shared/dossiers/_edit_annotations.html.haml @@ -7,9 +7,6 @@ = fields_for champ.input_name, champ do |form| = render EditableChamp::EditableChampComponent.new form: form, champ: champ, seen_at: seen_at - - if !dossier.for_procedure_preview? - .send-wrapper - = f.submit 'Sauvegarder', class: 'button primary send', data: { disable: true } - + = render Dossiers::EditFooterComponent.new(dossier: dossier, annotation: true) - else %h2.empty-text Aucune annotation privée diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index c127bad30..687418fad 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -112,6 +112,7 @@ ignore_unused: - 'helpers.page_entries_info.*' - 'combo_search_component.result_slot_html.*' - 'combo_search_component.screen_reader_instructions' +- 'links.common.*' # - '{devise,kaminari,will_paginate}.*' # - 'simple_form.{yes,no}' # - 'simple_form.{placeholders,hints,labels}.*' diff --git a/config/locales/en.yml b/config/locales/en.yml index ab6f83845..4c63f158e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -281,12 +281,6 @@ en: users: dossiers: archived_dossier: "Your file will be kept %{duree_conservation_dossiers_dans_ds} more months" - autosave: - explanation: Your file is automatically saved. - confirmation: File saved - draft_explanation: Your draft is automatically saved. - draft_confirmation: Draft saved - more_information: More informations identite: identity_data: Identity data all_required: All fields are required. diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 3e8e421d9..b60276eed 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -277,12 +277,6 @@ fr: users: dossiers: archived_dossier: "Votre dossier sera conservé %{duree_conservation_dossiers_dans_ds} mois supplémentaire" - autosave: - explanation: Votre dossier est automatiquement enregistré. - confirmation: Dossier enregistré - draft_explanation: Votre brouillon est automatiquement enregistré. - draft_confirmation: Brouillon enregistré - more_information: En savoir plus identite: identity_data: Données d’identité all_required: Tous les champs sont obligatoires. diff --git a/spec/components/editable_champ/editable_champ_component_spec.rb b/spec/components/editable_champ/editable_champ_component_spec.rb index 08025b670..77a6d0645 100644 --- a/spec/components/editable_champ/editable_champ_component_spec.rb +++ b/spec/components/editable_champ/editable_champ_component_spec.rb @@ -24,7 +24,7 @@ describe EditableChamp::EditableChampComponent, type: :component do context 'when a private champ' do let(:champ) { create(:champ, dossier: dossier, private: true) } - it { expect(subject).to eq('') } + it { expect(subject).to eq('autosave') } end context 'when a dossier is en_construction' do @@ -41,7 +41,7 @@ describe EditableChamp::EditableChampComponent, type: :component do end context 'when a private dropdown champ' do - let(:controllers) { ['champ-dropdown'] } + let(:controllers) { ['autosave', 'champ-dropdown'] } let(:champ) { create(:champ_drop_down_list, dossier: dossier, private: true) } it { expect(subject).to eq(data) } @@ -56,7 +56,7 @@ describe EditableChamp::EditableChampComponent, type: :component do end context 'when a private dropdown champ' do - let(:controllers) { ['champ-dropdown'] } + let(:controllers) { ['autosave', 'champ-dropdown'] } let(:champ) { create(:champ_drop_down_list, dossier: dossier, private: true) } it { expect(subject).to eq(data) } diff --git a/spec/controllers/instructeurs/dossiers_controller_spec.rb b/spec/controllers/instructeurs/dossiers_controller_spec.rb index 86b114add..cdcdf1398 100644 --- a/spec/controllers/instructeurs/dossiers_controller_spec.rb +++ b/spec/controllers/instructeurs/dossiers_controller_spec.rb @@ -771,7 +771,7 @@ describe Instructeurs::DossiersController, type: :controller do expect(controller.current_instructeur).to receive(:mark_tab_as_seen).with(dossier, :annotations_privees) another_instructeur.follow(dossier) Timecop.freeze(now) - patch :update_annotations, params: params + patch :update_annotations, params: params, format: :turbo_stream champ_multiple_drop_down_list.reload champ_linked_drop_down_list.reload @@ -819,7 +819,7 @@ describe Instructeurs::DossiersController, type: :controller do expect(champ_datetime.value).to eq('2019-12-21T13:17:00+01:00') expect(champ_repetition.champs.first.value).to eq('text') expect(dossier.reload.last_champ_private_updated_at).to eq(now) - expect(response).to redirect_to(annotations_privees_instructeur_dossier_path(dossier.procedure, dossier)) + expect(response).to have_http_status(200) } it 'updates the annotations' do @@ -848,7 +848,7 @@ describe Instructeurs::DossiersController, type: :controller do it { expect(dossier.reload.last_champ_private_updated_at).to eq(nil) - expect(response).to redirect_to(annotations_privees_instructeur_dossier_path(dossier.procedure, dossier)) + expect(response).to have_http_status(200) } end end From c521724cf4f161ce7bac48b8b465e51a914c838a Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 7 Mar 2023 17:48:06 +0000 Subject: [PATCH 2/3] Update app/components/dossiers/edit_footer_component.rb Co-authored-by: Colin Darie --- app/components/dossiers/edit_footer_component.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/dossiers/edit_footer_component.rb b/app/components/dossiers/edit_footer_component.rb index 6b79fc886..cf43539bb 100644 --- a/app/components/dossiers/edit_footer_component.rb +++ b/app/components/dossiers/edit_footer_component.rb @@ -11,7 +11,7 @@ class Dossiers::EditFooterComponent < ApplicationComponent end def annotation? - @annotation + @annotation.present? end def button_options From 53e6ad135f6425da1f2a938bd09cffeba0126126 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 7 Mar 2023 17:48:16 +0000 Subject: [PATCH 3/3] Update app/controllers/concerns/turbo_champs_concern.rb Co-authored-by: Colin Darie --- app/controllers/concerns/turbo_champs_concern.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/concerns/turbo_champs_concern.rb b/app/controllers/concerns/turbo_champs_concern.rb index f7e61dd08..abb60bbff 100644 --- a/app/controllers/concerns/turbo_champs_concern.rb +++ b/app/controllers/concerns/turbo_champs_concern.rb @@ -16,8 +16,7 @@ module TurboChampsConcern def champs_to_one_selector(champs) champs - .map(&:input_group_id) - .map { |id| "##{id}" } + .map { "##{_1.input_group_id}" } .join(',') end end