feat(dossier): inform dossier en_construction having not submitted changes
This commit is contained in:
parent
606493b7dd
commit
c35176703f
9 changed files with 92 additions and 3 deletions
|
@ -0,0 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Dossiers::EnConstructionNotSubmittedComponent < ApplicationComponent
|
||||
attr_reader :dossier
|
||||
attr_reader :user
|
||||
|
||||
def initialize(dossier:, user:)
|
||||
@dossier = dossier
|
||||
@user = user
|
||||
|
||||
@fork = @dossier.find_editing_fork(user, rebase: false)
|
||||
end
|
||||
|
||||
def render?
|
||||
@fork&.forked_with_changes?
|
||||
end
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
en:
|
||||
title: Modifications not yet submitted
|
||||
body: |
|
||||
You have made changes after submitting your file. Submit them
|
||||
so that the administration can take them into account.
|
||||
buttons:
|
||||
edit: Continue to edit
|
||||
submit: Submit file changes
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
fr:
|
||||
title: Des modifications n’ont pas encore été déposées
|
||||
body: |
|
||||
Vous avez apporté des modifications après le dépôt de votre dossier.
|
||||
Déposez-les afin que l’administration les prenne en compte.
|
||||
buttons:
|
||||
edit: Continuer à modifier
|
||||
submit: Déposer les modifications
|
|
@ -0,0 +1,9 @@
|
|||
= render Dsfr::CalloutComponent.new(title: t(".title"), icon: "fr-fi-information-line") do |c|
|
||||
- c.body do
|
||||
= t(".body")
|
||||
|
||||
- c.bottom do
|
||||
%ul.fr-mt-2w.fr-btns-group.fr-btns-group--inline
|
||||
%li= link_to t(".buttons.edit"), modifier_dossier_path(dossier), class: "fr-btn"
|
||||
%li= button_to t(".buttons.submit"), modifier_dossier_path(dossier), class: "fr-btn fr-btn--secondary", method: :post
|
||||
|
|
@ -27,7 +27,7 @@ class Dsfr::CalloutComponent < ApplicationComponent
|
|||
when :success
|
||||
"fr-callout--green-emeraude"
|
||||
else
|
||||
# info is default theme
|
||||
"fr-background-alt--blue-france"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,8 +13,11 @@ module DossierCloneConcern
|
|||
find_editing_fork(user) || clone(user:, fork: true)
|
||||
end
|
||||
|
||||
def find_editing_fork(user)
|
||||
editing_forks.find_by(user:)&.tap(&:rebase!)
|
||||
def find_editing_fork(user, rebase: true)
|
||||
fork = editing_forks.find_by(user:)
|
||||
fork.rebase! if rebase && fork
|
||||
|
||||
fork
|
||||
end
|
||||
|
||||
def owner_editing_fork
|
||||
|
|
|
@ -6,6 +6,12 @@
|
|||
.dossier-container.mb-4
|
||||
= render partial: 'users/dossiers/show/header', locals: { dossier: @dossier }
|
||||
|
||||
- if @dossier.en_construction?
|
||||
.fr-container
|
||||
.fr-grid-row.fr-grid-row--center
|
||||
.fr-col-md-10.fr-col-lg-9
|
||||
= render Dossiers::EnConstructionNotSubmittedComponent.new(dossier: @dossier, user: current_user)
|
||||
|
||||
= render partial: 'shared/dossiers/demande', locals: { dossier: @dossier, demande_seen_at: nil, profile: 'usager' }
|
||||
|
||||
.container
|
||||
|
|
|
@ -13,6 +13,11 @@
|
|||
%li.termine{ class: dossier.termine? ? 'active' : nil }
|
||||
= t('views.users.dossiers.show.status_overview.status_completed')
|
||||
|
||||
- if dossier.en_construction?
|
||||
.fr-grid-row.fr-grid-row--center
|
||||
.fr-col-md-10.fr-col-lg-9
|
||||
= render Dossiers::EnConstructionNotSubmittedComponent.new(dossier: dossier, user: current_user)
|
||||
|
||||
.fr-grid-row.fr-grid-row--center
|
||||
.fr-col-md-10.fr-col-lg-9.status-explanation
|
||||
-# brouillon does not occure
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe Dossiers::EnConstructionNotSubmittedComponent, type: :component do
|
||||
let(:dossier) { create(:dossier, :en_construction) }
|
||||
|
||||
subject {
|
||||
render_inline(described_class.new(dossier:, user: dossier.user)).to_html
|
||||
}
|
||||
|
||||
context "without fork" do
|
||||
it { expect(subject).to be_empty }
|
||||
end
|
||||
|
||||
context "with a fork" do
|
||||
let!(:fork) { dossier.find_or_create_editing_fork(dossier.user) }
|
||||
|
||||
it "render nothing without changes" do
|
||||
expect(subject).to be_empty
|
||||
end
|
||||
|
||||
context "with changes" do
|
||||
before { fork.champs_public.first.update(value: "new value") }
|
||||
|
||||
it "inform user" do
|
||||
expect(subject).to include("Des modifications n’ont pas encore été déposées")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue