forked from demarches-simplifiees/demarches-simplifiees.fr
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/import-2023-06-26'
- Loading branch information
Showing
56 changed files
with
787 additions
and
436 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,29 @@ | ||
@import "colors"; | ||
@import "constants"; | ||
|
||
.demande { | ||
padding-top: 3 * $default-padding; | ||
padding-bottom: 3 * $default-padding; | ||
|
||
h1 { | ||
margin-bottom: $default-padding; | ||
.dossier-show { | ||
@media (max-width: 48em) { | ||
.d-block-sm { | ||
display: block; | ||
} | ||
} | ||
|
||
.intro { | ||
margin: $default-padding 0; | ||
.champ-label { | ||
font-weight: 600; | ||
margin-bottom: 0; | ||
color: var(--text-action-high-grey); | ||
} | ||
|
||
b { | ||
font-weight: bold; | ||
.champ-content { | ||
padding: 0 0 0.5rem; | ||
|
||
p { | ||
padding: 0; | ||
margin: 0; | ||
} | ||
} | ||
|
||
hr { | ||
border: none; | ||
height: 1px; | ||
background-color: $grey; | ||
margin-top: 2 * $default-padding; | ||
margin-bottom: 2 * $default-padding; | ||
.top-bordered { | ||
border-top: 1px solid var(--border-default-grey); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class Dossiers::ChampRowShowComponent < ApplicationComponent | ||
include ChampHelper | ||
include DossierHelper | ||
include ApplicationHelper | ||
def initialize(champs:, demande_seen_at:, profile:, repetition:) | ||
@repetition = repetition | ||
@champs = champs | ||
@demande_seen_at = demande_seen_at | ||
@profile = profile | ||
end | ||
|
||
def updated_after_deposer?(champ) | ||
return false if champ.dossier.depose_at.blank? | ||
champ.updated_at > champ.dossier.depose_at | ||
end | ||
|
||
def number_with_html_delimiter(num) | ||
# we are using the span delimiter that doesn't insert spaces when copying and pasting the number | ||
number_with_delimiter(num, delimiter: tag.span(class: 'numbers-delimiter')) | ||
end | ||
end |
3 changes: 3 additions & 0 deletions
3
app/components/dossiers/champ_row_show_component/champ_row_show_component.en.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
en: | ||
blank: "blank (optional)" |
3 changes: 3 additions & 0 deletions
3
app/components/dossiers/champ_row_show_component/champ_row_show_component.fr.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
fr: | ||
blank: "non saisi (facultatif)" |
66 changes: 66 additions & 0 deletions
66
app/components/dossiers/champ_row_show_component/champ_row_show_component.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
- @champs.each do |champ| | ||
.fr-px-4v.fr-my-2v | ||
- if champ.repetition? | ||
%p.champ-label= "#{champ.libelle} :" | ||
- champ.rows.each do |row| | ||
= render Dossiers::ChampRowShowComponent.new(champs: row, demande_seen_at: @demande_seen_at, profile: @profile, repetition: true) | ||
|
||
- else | ||
.flex.d-block-sm | ||
%p.champ-label.flex-grow= "#{champ.libelle} :" | ||
|
||
- if updated_after_deposer?(champ) | ||
%p.fr-mb-0.fr-text--sm | ||
%span{ class: highlight_if_unseen_class(@demande_seen_at, champ.updated_at) } | ||
= t(:updated_at, scope: [:views, :shared, :dossiers, :form], datetime: try_format_datetime(champ.updated_at)) | ||
|
||
- if champ.blank? && ![TypeDeChamp.type_champs.fetch(:piece_justificative), TypeDeChamp.type_champs.fetch(:titre_identite)].include?(champ.type_champ) | ||
.champ-content.fr-text-mention--grey{ class: [highlight_if_unseen_class(@demande_seen_at, champ.updated_at), champ.type_champ] } | ||
%p | ||
%em= t('.blank') | ||
- else | ||
.champ-content{ class: [highlight_if_unseen_class(@demande_seen_at, champ.updated_at), champ.type_champ] } | ||
- case champ.type_champ | ||
- when TypeDeChamp.type_champs.fetch(:carte) | ||
= render partial: "shared/champs/carte/show", locals: { champ: champ } | ||
- when TypeDeChamp.type_champs.fetch(:dossier_link) | ||
= render partial: "shared/champs/dossier_link/show", locals: { champ: champ } | ||
- when TypeDeChamp.type_champs.fetch(:multiple_drop_down_list) | ||
= render partial: "shared/champs/multiple_drop_down_list/show", locals: { champ: champ } | ||
- when TypeDeChamp.type_champs.fetch(:piece_justificative), TypeDeChamp.type_champs.fetch(:titre_identite) | ||
= render partial: "shared/champs/piece_justificative/show", locals: { champ: champ } | ||
- when TypeDeChamp.type_champs.fetch(:siret) | ||
= render partial: "shared/champs/siret/show", locals: { champ: champ, profile: @profile } | ||
- when TypeDeChamp.type_champs.fetch(:iban) | ||
= render partial: "shared/champs/iban/show", locals: { champ: champ } | ||
- when TypeDeChamp.type_champs.fetch(:textarea) | ||
= render partial: "shared/champs/textarea/show", locals: { champ: champ } | ||
- when TypeDeChamp.type_champs.fetch(:annuaire_education) | ||
= render partial: "shared/champs/annuaire_education/show", locals: { champ: champ } | ||
- when TypeDeChamp.type_champs.fetch(:cnaf) | ||
= render partial: "shared/champs/cnaf/show", locals: { champ: champ, profile: @profile } | ||
- when TypeDeChamp.type_champs.fetch(:dgfip) | ||
= render partial: "shared/champs/dgfip/show", locals: { champ: champ, profile: @profile } | ||
- when TypeDeChamp.type_champs.fetch(:pole_emploi) | ||
= render partial: "shared/champs/pole_emploi/show", locals: { champ: champ, profile: @profile } | ||
- when TypeDeChamp.type_champs.fetch(:mesri) | ||
= render partial: "shared/champs/mesri/show", locals: { champ: champ, profile: @profile } | ||
- when TypeDeChamp.type_champs.fetch(:address) | ||
= render partial: "shared/champs/address/show", locals: { champ: champ } | ||
- when TypeDeChamp.type_champs.fetch(:communes) | ||
= render partial: "shared/champs/communes/show", locals: { champ: champ } | ||
- when TypeDeChamp.type_champs.fetch(:regions) | ||
= render partial: "shared/champs/regions/show", locals: { champ: champ } | ||
- when TypeDeChamp.type_champs.fetch(:rna) | ||
= render partial: "shared/champs/rna/show", locals: { champ: champ, profile: @profile } | ||
- when TypeDeChamp.type_champs.fetch(:epci) | ||
= render partial: "shared/champs/epci/show", locals: { champ: champ } | ||
- when TypeDeChamp.type_champs.fetch(:date) | ||
%p= champ.to_s | ||
- when TypeDeChamp.type_champs.fetch(:datetime) | ||
%p= champ.to_s | ||
- when TypeDeChamp.type_champs.fetch(:number) | ||
%p= number_with_html_delimiter(champ.to_s) | ||
- else | ||
- if champ.present? | ||
= format_text_value(champ.to_s.strip) # format already wrap in p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
class ViewableChamp::SectionComponent < ApplicationComponent | ||
include ApplicationHelper | ||
include TreeableConcern | ||
|
||
def initialize(champs: nil, nodes: nil, demande_seen_at:, profile:) | ||
@demande_seen_at, @profile, @repetition = demande_seen_at, profile | ||
nodes ||= to_tree(champs:) | ||
@nodes = to_sections(nodes:) | ||
end | ||
|
||
def section_id | ||
@section_id ||= header_section ? dom_id(header_section, :content) : SecureRandom.uuid | ||
end | ||
|
||
def header_section | ||
if @nodes.first.is_a?(Champs::HeaderSectionChamp) | ||
@nodes.first | ||
end | ||
end | ||
|
||
def champs | ||
tail.filter { _1.is_a?(Champ) && _1.visible? && !_1.exclude_from_view? } | ||
end | ||
|
||
def sections | ||
tail.filter { !_1.is_a?(Champ) } | ||
end | ||
|
||
def tail | ||
return @nodes if header_section.blank? | ||
_, *rest_of_champ = @nodes | ||
|
||
rest_of_champ | ||
end | ||
|
||
def tag_for_depth | ||
"h#{header_section.level + 1}" if header_section | ||
end | ||
|
||
def first_level? | ||
header_section.level == 1 | ||
end | ||
|
||
private | ||
|
||
def to_sections(nodes:) | ||
nodes.map { _1.is_a?(Array) ? ViewableChamp::SectionComponent.new(nodes: _1, demande_seen_at: @demande_seen_at, profile: @profile) : _1 } | ||
end | ||
end |
3 changes: 3 additions & 0 deletions
3
app/components/viewable_champ/section_component/section_component.en.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
en: | ||
toggle_section: "Show/hide fields of « %{section} »" |
3 changes: 3 additions & 0 deletions
3
app/components/viewable_champ/section_component/section_component.fr.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
fr: | ||
toggle_section: "Afficher/Cacher les champs de la section « %{section} »" |
14 changes: 14 additions & 0 deletions
14
app/components/viewable_champ/section_component/section_component.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
= tag.div(class: "reset-#{tag_for_depth} fr-mt-4v", 'data-controller': 'expand') do | ||
- if header_section | ||
%div{ class: class_names(flex: true, "top-bordered" => header_section.level == 1) } | ||
= render EditableChamp::HeaderSectionComponent.new(champ: header_section, html_class: {' fr-m-0 fr-text--md fr-px-4v flex-grow' => true, "fr-text-action-high--blue-france" => header_section.level == 1, 'fr-py-3v' => header_section.level == 1, 'fr-pt-3v' => header_section.level == 1}) | ||
- if ![champs, sections].map(&:empty?).all? && header_section.level == 1 | ||
%button{ type: "button", aria: { controls: section_id, "expanded": "true", label: t('.toggle_section', section: header_section.libelle) }, href: section_id, 'data-action': 'click->expand#toggle', class: "fr-btn fr-btn--tertiary-no-outline" } | ||
%i.fr-icon-arrow-up-s-line{ 'aria-hidden': 'true', 'data-expand-target': 'icon' } | ||
%div{ id: section_id, 'data-expand-target': 'content' } | ||
- if !champs.empty? | ||
= render Dossiers::ChampRowShowComponent.new(champs: champs, demande_seen_at: @demande_seen_at, profile: @profile, repetition: false) | ||
- sections.each do |section| | ||
= render section |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.