Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ETQ Usager, je voudrais modifier un dossier en construction via les streams #11068

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/components/attachment/edit_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def attachment_path(**args)

def destroy_attachment_path
if champ.present?
attachment_path(dossier_id: champ&.dossier_id, stable_id: champ&.stable_id, row_id: champ&.row_id)
attachment_path(stream: champ.dossier.stream)
else
attachment_path(auto_attach_url: @auto_attach_url, view_as: @view_as, direct_upload: @direct_upload)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
%span.autosave-explanation-text
- if annotation?
= t('.annotations.explanation')
- elsif dossier.editing_fork?
- elsif dossier.en_construction_for_editor?
= t('.en_construction.explanation')
- else
= t('.brouillon.explanation')
Expand All @@ -15,7 +15,7 @@
%span.autosave-label
- if annotation?
= t('.annotations.confirmation')
- elsif dossier.editing_fork?
- elsif dossier.en_construction_for_editor?
= t('.en_construction.confirmation')
- else
= t('.brouillon.confirmation')
Expand All @@ -27,7 +27,7 @@
%span.autosave-label
- if annotation?
= t('.annotations.error')
- elsif dossier.editing_fork?
- elsif dossier.en_construction_for_editor?
= t('.en_construction.error')
- else
= t('.brouillon.error')
Expand Down
4 changes: 2 additions & 2 deletions app/components/dossiers/champs_rows_show_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def number_with_html_delimiter(num)
end

def blank_key(champ)
key = ".blank_optional"
key += "_attachment" if champ.type_de_champ.piece_justificative_or_titre_identite?
key = champ.mandatory? ? ".blank" : ".blank_optional"
key += "_attachment" if champ.piece_justificative_or_titre_identite?

key
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
en:
blank_optional: "empty (optional)"
blank_optional_attachment: "document not supplied (optional)"
blank: 'empty'
blank_attachment: 'document not supplied'
blank_optional: 'empty (optional)'
blank_optional_attachment: 'document not supplied (optional)'
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
fr:
blank_optional: "non saisi (facultatif)"
blank_optional_attachment: "pièce justificative non saisie (facultative)"
blank: 'non saisi'
blank_attachment: 'pièce justificative non saisie'
blank_optional: 'non saisi (facultatif)'
blank_optional_attachment: 'pièce justificative non saisie (facultative)'
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
= render ViewableChamp::SectionComponent.new(dossier: champ.dossier, types_de_champ:, row_id:, demande_seen_at: seen_at, profile:)

- else
= render Dossiers::RowShowComponent.new(label: champ.libelle, seen_at:, profile:, content_class: champ.type_champ, updated_at: updated_at_after_deposer(champ)) do |c|
= render Dossiers::RowShowComponent.new(label: champ.libelle, seen_at:, profile:, content_class: champ.type_champ, updated_at: updated_at_after_deposer(champ), errors: champ.errors) do |c|
- if champ.blank?
- c.with_blank do
= t(blank_key(champ))
Expand Down
4 changes: 2 additions & 2 deletions app/components/dossiers/edit_footer_component.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class Dossiers::EditFooterComponent < ApplicationComponent
delegate :can_passer_en_construction?, :can_transition_to_en_construction?, :forked_with_changes?, to: :@dossier
delegate :can_passer_en_construction?, :can_transition_to_en_construction?, :user_draft_changes?, to: :@dossier

def initialize(dossier:, annotation:)
@dossier = dossier
Expand All @@ -27,7 +27,7 @@ def can_submit_draft?
end

def can_submit_en_construction?
forked_with_changes?
user_draft_changes?
end

def submit_button_label
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ class Dossiers::EnConstructionNotSubmittedComponent < ApplicationComponent
def initialize(dossier:, user:)
@dossier = dossier
@user = user

@fork = @dossier.find_editing_fork(user, rebase: false)
end

def render?
@fork&.forked_with_changes?
@dossier.user_draft_changes?
end
end
12 changes: 12 additions & 0 deletions app/components/dossiers/row_show_component.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,20 @@
.champ-content.fr-text-mention--grey{ class: content_class }
- if usager?
%p.champ-blank= blank
- if errors.present?
.fr-messages-group
%p.fr-message.fr-message--error
= "« #{label} » "
- errors.each do |error_message|
= error_message

- else

.champ-content{ class: content_class }
= value
- if errors.present?
.fr-messages-group
%p.fr-message.fr-message--error
= "« #{label} » "
- errors.each do |error_message|
= error_message
4 changes: 3 additions & 1 deletion app/components/dossiers/row_show_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ class Dossiers::RowShowComponent < ApplicationComponent
attr_reader :updated_at
attr_reader :seen_at
attr_reader :content_class
attr_reader :errors

renders_one :value
renders_one :blank

def initialize(label:, profile: nil, updated_at: nil, seen_at: nil, content_class: nil)
def initialize(label:, profile: nil, updated_at: nil, seen_at: nil, content_class: nil, errors: nil)
@label = label
@profile = profile
@updated_at = updated_at
@seen_at = seen_at
@content_class = content_class
@errors = errors&.full_messages
end

def badge_updated_class
Expand Down
2 changes: 1 addition & 1 deletion app/components/editable_champ/carte_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ def react_props
end

def update_path
champs_carte_features_path(@champ.dossier, @champ.stable_id, row_id: @champ.row_id)
champs_carte_features_path(@champ.dossier, @champ.stable_id, row_id: @champ.row_id, stream: @champ.dossier.stream)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- if @champ.mandatory?
= render EditableChamp::AsteriskMandatoryComponent.new

- if @champ.forked_with_changes?
- if @champ.user_draft_changes?
%span.updated-at.highlighted
= t('.changes_to_save')
- elsif @champ.updated_at.present? && @seen_at.present?
Expand Down
4 changes: 2 additions & 2 deletions app/components/editable_champ/editable_champ_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def stimulus_values

def turbo_poll_url_value
if @champ.private?
annotation_instructeur_dossier_path(@champ.dossier.procedure, @champ.dossier, @champ.stable_id, row_id: @champ.row_id, with_public_id: true)
annotation_instructeur_dossier_path(@champ.dossier.procedure, @champ.dossier, @champ.stable_id, row_id: @champ.row_id)
else
champ_dossier_path(@champ.dossier, @champ.stable_id, row_id: @champ.row_id, with_public_id: true)
champ_dossier_path(@champ.dossier, @champ.stable_id, row_id: @champ.row_id, stream: dossier.stream)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
= render EditableChamp::RepetitionRowComponent.new(form: @form, dossier: @champ.dossier, type_de_champ: @champ.type_de_champ, row_id:, row_number:, seen_at: @seen_at)

.actions
= render NestedForms::OwnedButtonComponent.new(formaction: champs_repetition_path(@champ.dossier, @champ.stable_id), http_method: :create, opt: { class: "fr-btn fr-btn--secondary fr-btn--icon-left fr-icon-add-circle-line fr-mb-3w", title: t(".add_title", libelle: @champ.libelle), id: dom_id(@champ, :create_repetition)}) do
= render NestedForms::OwnedButtonComponent.new(formaction: champs_repetition_path(@champ.dossier, @champ.stable_id, stream: @champ.dossier.stream), http_method: :create, opt: { class: "fr-btn fr-btn--secondary fr-btn--icon-left fr-icon-add-circle-line fr-mb-3w", title: t(".add_title", libelle: @champ.libelle), id: dom_id(@champ, :create_repetition)}) do
= t(".add", libelle: @champ.libelle)
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
= render section_component

.flex.row-reverse
= render NestedForms::OwnedButtonComponent.new(formaction: champs_repetition_path(@dossier, @type_de_champ.stable_id, row_id:), http_method: :delete, opt: { class: "fr-btn fr-btn--sm fr-btn--tertiary fr-text-action-high--red-marianne utils-repetition-required-destroy-button", title: t(".delete_title", row_number:)}) do
= render NestedForms::OwnedButtonComponent.new(formaction: champs_repetition_path(@dossier, @type_de_champ.stable_id, row_id:, stream: @dossier.stream), http_method: :delete, opt: { class: "fr-btn fr-btn--sm fr-btn--tertiary fr-text-action-high--red-marianne utils-repetition-required-destroy-button", title: t(".delete_title", row_number:)}) do
= t(".delete")
2 changes: 1 addition & 1 deletion app/components/editable_champ/rna_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ def dsfr_input_classname
end

def update_path
champs_rna_path(@champ.dossier, @champ.stable_id, row_id: @champ.row_id)
champs_rna_path(@champ.dossier, @champ.stable_id, row_id: @champ.row_id, stream: @champ.dossier.stream)
end
end
2 changes: 1 addition & 1 deletion app/components/editable_champ/siret_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ def hintable?
end

def update_path
champs_siret_path(@champ.dossier, @champ.stable_id, row_id: @champ.row_id)
champs_siret_path(@champ.dossier, @champ.stable_id, row_id: @champ.row_id, stream: @champ.dossier.stream)
end
end
8 changes: 0 additions & 8 deletions app/components/procedure/revision_changes_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ def initialize(new_revision:, previous_revision:)

@tdc_changes = previous_revision.compare_types_de_champ(new_revision)
@public_move_changes, @private_move_changes = @tdc_changes.filter { _1.op == :move }.partition { !_1.private? }
@delete_champ_warning = !total_dossiers.zero? && !@tdc_changes.all?(&:can_rebase?)

@ineligibilite_rules_changes = previous_revision.compare_ineligibilite_rules(new_revision)
end
Expand All @@ -18,11 +17,4 @@ def initialize(new_revision:, previous_revision:)
def used_by_routing_rules?(type_de_champ)
@procedure.used_by_routing_rules?(type_de_champ)
end

def total_dossiers
@total_dossiers ||= @previous_revision.dossiers
.visible_by_administration
.state_en_construction_ou_instruction
.size
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,9 @@
= t('.public.add_mandatory', label: change.label)
- else
= t(".#{prefix}.add", label: change.label)
- if !total_dossiers.zero? && !change.can_rebase?
.fr-alert.fr-alert--warning.fr-mt-1v
%p= t('.breaking_change', count: total_dossiers)
- when :remove
- list.with_item do
= t(".#{prefix}.remove", label: change.label)
- if @delete_champ_warning
.fr-alert.fr-alert--warning.fr-mt-1v
%p= t('.delete_champ_html', count: total_dossiers)
- when :update
- case change.attribute
- when :libelle
Expand All @@ -28,9 +22,6 @@
- when :type_champ
- list.with_item do
= t(".#{prefix}.update_type_champ", label: change.label, to: t("activerecord.attributes.type_de_champ.type_champs.#{change.to}"))
- if !total_dossiers.zero? && !change.can_rebase?
.fr-alert.fr-alert--warning.fr-mt-1v
%p= t('.breaking_change', count: total_dossiers)
- when :description
- list.with_item do
- if change.to.blank?
Expand All @@ -47,15 +38,9 @@
- if change.from == false
- list.with_item do
= t(".public.enable_mandatory", label: change.label)
- if !total_dossiers.zero? && !change.can_rebase?
.fr-alert.fr-alert--warning.fr-mt-1v
%p= t('.breaking_change', count: total_dossiers)
- else
- list.with_item do
= t(".public.disable_mandatory", label: change.label)
- if !total_dossiers.zero? && !change.can_rebase?
.fr-alert.fr-alert--warning.fr-mt-1v
%p= t('.breaking_change', count: total_dossiers)
- when :piece_justificative_template
- list.with_item do
= t(".#{prefix}.update_piece_justificative_template", label: change.label)
Expand All @@ -74,25 +59,16 @@
- if removed.present?
- list.with_item do
= t('.remove_option', items: removed.map{ |term| "« #{term.strip} »" }.join(", "))
- 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? || added.present? ) && used_by_routing_rules?(change.type_de_champ)
.fr-alert.fr-alert--warning.fr-mt-1v
= t(".#{prefix}.update_drop_down_options_alert", label: change.label)
- when :drop_down_other
- if change.from == false
- list.with_item do
= t(".#{prefix}.enable_drop_down_other", label: change.label)
- if !total_dossiers.zero? && !change.can_rebase?
.fr-alert.fr-alert--warning.fr-mt-1v
%p= t('.breaking_change', count: total_dossiers)
- else
- list.with_item do
= t(".#{prefix}.disable_drop_down_other", label: change.label)
- if !total_dossiers.zero? && !change.can_rebase?
.fr-alert.fr-alert--warning.fr-mt-1v
%p= t('.breaking_change', count: total_dossiers)
- when :carte_layers
- added = change.to.sort - change.from.sort
- removed = change.from.sort - change.to.sort
Expand Down Expand Up @@ -122,21 +98,12 @@
- if change.from.nil?
- list.with_item do
= t(".#{prefix}.add_condition", label: change.label, to: change.to)
- if !total_dossiers.zero? && !change.can_rebase?
.fr-alert.fr-alert--warning.fr-mt-1v
%p= t('.breaking_change', count: total_dossiers)
- elsif change.to.nil?
- list.with_item do
= t(".#{prefix}.remove_condition", label: change.label)
- if !total_dossiers.zero? && !change.can_rebase?
.fr-alert.fr-alert--warning.fr-mt-1v
%p= t('.breaking_change', count: total_dossiers)
- else
- list.with_item do
= t(".#{prefix}.update_condition", label: change.label, to: change.to)
- if !total_dossiers.zero? && !change.can_rebase?
.fr-alert.fr-alert--warning.fr-mt-1v
%p= t('.breaking_change', count: total_dossiers)
- when :character_limit
- if change.to.blank?
- list.with_item do
Expand Down
21 changes: 11 additions & 10 deletions app/controllers/attachments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,21 @@

def destroy
@attachment = @blob.attachments.find(params[:id])
@attachment.purge_later
flash.notice = 'La pièce jointe a bien été supprimée.'

if params[:dossier_id]
@champ = find_champ
record = @attachment.record

Check warning on line 23 in app/controllers/attachments_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/attachments_controller.rb#L23

Added line #L23 was not covered by tests

if record.is_a?(Champ)
stream = params[:stream]
dossier = record.dossier
dossier.with_stream(stream)
@champ = dossier.champ_for_update(record.type_de_champ, record.row_id, updated_by: current_user.email)
@attachment = @champ.piece_justificative_file.find { _1.blob.id == @blob.id }

Check warning on line 30 in app/controllers/attachments_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/attachments_controller.rb#L25-L30

Added lines #L25 - L30 were not covered by tests
else
@attachment_options = attachment_options
end

@attachment.purge_later
flash.notice = 'La pièce jointe a bien été supprimée.'

Check warning on line 36 in app/controllers/attachments_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/attachments_controller.rb#L35-L36

Added lines #L35 - L36 were not covered by tests

respond_to do |format|
format.turbo_stream
format.html { redirect_back(fallback_location: root_url) }
Expand All @@ -37,11 +43,6 @@

private

def find_champ
dossier = policy_scope(Dossier).includes(:champs).find(params[:dossier_id])
dossier.champs.find_by(stable_id: params[:stable_id], row_id: params[:row_id])
end

def attachment_options
{
attached_file: @attachment.record.public_send(@attachment.name),
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/champs/champ_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ class Champs::ChampController < ApplicationController

def find_champ
dossier = policy_scope(Dossier).includes(:champs, revision: [:types_de_champ]).find(params[:dossier_id])
if params[:stream].in?([Champ::USER_DRAFT_STREAM])
dossier.with_stream(params[:stream])
end
type_de_champ = dossier.find_type_de_champ_by_stable_id(params[:stable_id])
if type_de_champ.repetition?
dossier.project_champ(type_de_champ, nil)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/turbo_champs_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module TurboChampsConcern

def champs_to_turbo_update(params, champs)
to_update = champs.filter { _1.public_id.in?(params.keys) }
.filter { _1.refresh_after_update? || _1.forked_with_changes? }
.filter { _1.refresh_after_update? || _1.user_draft_changes? }

to_show, to_hide = champs.filter(&:conditional?)
.partition(&:visible?)
Expand Down
7 changes: 5 additions & 2 deletions app/controllers/instructeurs/dossiers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ def show
@acls = PiecesJustificativesService.new(user_profile: current_instructeur, export_template: nil).acl_for_dossier_export(dossier.procedure)
render(template: 'dossiers/show', formats: [:pdf])
end
format.all
format.all do
dossier.validate(:champs_public_value)
dossier.check_mandatory_and_visible_champs
end
end
end

Expand Down Expand Up @@ -308,7 +311,7 @@ def update_annotations

respond_to do |format|
format.turbo_stream do
@to_show, @to_hide, @to_update = champs_to_turbo_update(champs_private_attributes_params, dossier.champs.filter(&:private?))
@to_show, @to_hide, @to_update = champs_to_turbo_update(champs_private_attributes_params, dossier.project_champs_private_all)
end
end
end
Expand Down
Loading
Loading