Skip to content

Commit

Permalink
Merge branch 'feature/import-2023-07-27'
Browse files Browse the repository at this point in the history
  • Loading branch information
maatinito committed Dec 8, 2023
2 parents 07f2a39 + 630ae09 commit 972e915
Show file tree
Hide file tree
Showing 70 changed files with 515 additions and 317 deletions.
2 changes: 1 addition & 1 deletion .scss-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ linters:
properties: {}

PseudoElement:
enabled: true
enabled: false # otherwise rules on ::marker fails

# To enable later
QualifyingElement:
Expand Down
5 changes: 0 additions & 5 deletions app/assets/stylesheets/dossier_edit.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ $dossier-actions-bar-border-width: 1px;
}
}

.characters-count {
position: relative;
top: -1rem;
}

.warning {
margin-bottom: 20px;
background-color: #f9b91666;
Expand Down
10 changes: 10 additions & 0 deletions app/assets/stylesheets/dsfr.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
@import "colors";

// overwrite DSFR style for SimpleFormatComponent, some user use markdown with
// ordered list having paragraph between list item
ol.fr-ol-content--override {
list-style-type: decimal;

li::marker {
content: inherit;
}
}

// override default transparent background on inputs & font-size to 16px by default
input,
textarea,
Expand Down
83 changes: 19 additions & 64 deletions app/assets/stylesheets/forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,13 @@
font-style: italic;
}

.fr-input-group,
.fr-select-group {
.fr-input-group {
margin-bottom: 1rem;
}

.section-2 {
margin-top: 1.5rem;
padding-top: 2rem;
padding-top: 1rem;
border-top: 2px solid var(--border-default-grey);
}

Expand All @@ -67,16 +66,6 @@
margin-bottom: 1rem;
}

// Keep only bottom margin in nested (consecutive) header sections, ie. first legend for a same level
.fr-fieldset > .fr-fieldset__legend + .fr-fieldset__element > .fr-fieldset:first-of-type .header-section {
margin-top: 0 !important;
}

// Don't cumulate margin-bottoms for inlined elements (radio...), because .fr-fieldset has already its own
.fr-fieldset__element > .fr-fieldset > .fr-fieldset__element.fr-fieldset__element--inline {
margin-bottom: 0;
}

legend {
width: 100%;
}
Expand All @@ -97,7 +86,7 @@


.mandatory {
color: $dark-red;
fill: currentColor;
}

label:not(.fr-label),
Expand Down Expand Up @@ -158,7 +147,6 @@
}

&.editable-champ-checkbox {
p,
label {
padding-left: 28px;
font-weight: normal;
Expand Down Expand Up @@ -256,7 +244,7 @@
user-select: none;

&:last-of-type {
margin-bottom: $default-fields-spacer;
margin-bottom: 0;
}

&:hover {
Expand Down Expand Up @@ -293,17 +281,21 @@
}
}

input[type=text],
input[type=email],
.fr-label {
// la description d'un champ peut contenir du markup (markdown->html),
// on herite donc la fontsize/mrgin/padding du fr-hint-text
.fr-hint-text > * {
font-size: inherit;
margin: inherit;
// disabled for pf to allow ul/ol tags to work
// padding: inherit;
}
}

input[type=password],
input[type=date],
input[type=datetime-local],
input[type=number],
input[type=tel],
textarea,
select {
display: block;
margin-bottom: $default-fields-spacer;
margin-bottom: 0;

&.small-margin {
margin-bottom: $default-spacer;
Expand All @@ -327,13 +319,6 @@
}

input[type=text]:not([data-address='true']),
input[type=email],
input[type=password],
input[type=date],
input[type=number],
input[type=tel],
input[type=datetime-local],
textarea,
select {
border-radius: 4px;
border: solid 1px $border-grey;
Expand Down Expand Up @@ -375,8 +360,8 @@
input[type=date],
input[type=number],
input[type=datetime-local],
input[type=tel],
textarea {
textarea,
input[type=tel], {
@media (max-width: $two-columns-breakpoint) {
width: 100%;
}
Expand Down Expand Up @@ -435,7 +420,7 @@

margin-left: 5px;
margin-right: 4px;
margin-bottom: $default-fields-spacer;
margin-bottom: 0;
}

[data-reach-combobox-input] {
Expand Down Expand Up @@ -522,16 +507,6 @@
color: $dark-grey;
}

.datetime {
input[type=date] {
display: inline-block;
}

select {
display: inline-block;
}
}

.header-subsection {
font-size: 22px;
color: $blue-france-500;
Expand All @@ -554,20 +529,6 @@
}
}

.siret-info {
margin-top: -$default-fields-spacer;
margin-bottom: $default-fields-spacer;
// Ensure the bottom-margin is not collapsed when the element is empty
min-height: 1px;
}

.rna-info {
margin-top: -$default-fields-spacer;
margin-bottom: $default-fields-spacer;
// Ensure the bottom-margin is not collapsed when the element is empty
min-height: 1px;
}

.send-wrapper {
display: flex;
width: 100%;
Expand Down Expand Up @@ -641,12 +602,6 @@
}
}

[data-react-component-value]:not([data-react-component-value^="ComboMultiple"]) {
[data-reach-combobox-input]:not(.no-margin) {
margin-bottom: $default-fields-spacer;
}
}

[data-react-component-value^="ComboMultiple"] {
margin-bottom: $default-fields-spacer;

Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/manager.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
opacity: 0.6;
}

.mandatory {
.manager-mandatory {
color: #A10005;
font-size: 18px;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.attachment.fr-upload-group{ { id: attachment ? dom_id(attachment, :edit) : nil, class: class_names("fr-mb-2w": !(as_multiple? && downloadable?)) }.compact, **replace_controller_attributes }
.attachment.fr-upload-group{ { id: attachment ? dom_id(attachment, :edit) : nil, class: class_names("fr-mb-1w": !(as_multiple? && downloadable?)) }.compact, **replace_controller_attributes }
- if persisted?
%div{ id: dom_id(attachment, :persisted_row) }
.flex.flex-gap-2{ class: class_names("attachment-error": attachment.virus_scanner_error?) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
.fr-mb-4w.attachment-multiple{ class: class_names("fr-downloads-group": view_as == :download, "destroyable": user_can_destroy?), **replace_controller_attributes }
.attachment-multiple{ class: class_names("fr-downloads-group": view_as == :download, "destroyable": user_can_destroy?), **replace_controller_attributes }
= template
%ul
- each_attachment do |attachment, index|
%li{ id: dom_id(attachment) }
= render Attachment::EditComponent.new(champ:, attached_file:, attachment:, index:, as_multiple: true, view_as:, user_can_destroy:, user_can_replace:, form_object_name:)
- if @attachments.size >= 1
%ul.fr-my-1v
- each_attachment do |attachment, index|
%li{ id: dom_id(attachment) }
= render Attachment::EditComponent.new(champ:, attached_file:, attachment:, index:, as_multiple: true, view_as:, user_can_destroy:, user_can_replace:, form_object_name:)
%div{ id: empty_component_id, class: class_names("hidden": !can_attach_next?) }
= render Attachment::EditComponent.new(champ:, attached_file:, attachment: nil, index: attachments_count, user_can_destroy:, user_can_replace:, form_object_name:)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.autosave.autosave-state-idle{ data: { controller: 'autosave-status' } }
%p.autosave-explanation.fr-text--sm
%p.autosave-explanation.fr-text--sm.fr-mb-0
%span.autosave-explanation-text
- if annotation?
= t('.annotations.explanation')
Expand All @@ -10,7 +10,7 @@
- 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
%p.autosave-status.succeeded.fr-mb-0
%span.autosave-icon.icon.accept
%span.autosave-label
- if annotation?
Expand All @@ -22,7 +22,7 @@
- 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
%p.autosave-status.failed.fr-mb-0
%span.autosave-icon ⚠️
%span.autosave-label
- if annotation?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ en:
submit: Submit the file
submit_changes: Submit file changes
submitting: Submitting…
invite_notice: You are invited to make amendments to this file but only the owner themselves can submit it.
invite_notice: You are invited to make amendments to this file but <strong>only the owner themselves can submit it</strong>.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ fr:
submit: Déposer le dossier
submit_changes: Déposer les modifications
submitting: Envoi en cours…
invite_notice: En tant qu’invité, vous pouvez remplir ce formulaire – mais le titulaire du dossier doit le déposer lui-même.
invite_notice: En tant qu’invité, vous pouvez remplir ce formulaire – mais <strong>le titulaire du dossier doit le déposer lui-même</strong>.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@


- if @dossier.brouillon? && !owner?
.send-notice.invite-cannot-submit
= t('.invite_notice')
.fr-pb-2w.invite-cannot-submit
= render ::Dsfr::AlertComponent.new(state: :info, title: nil, size: :sm, heading_level: :p, extra_class_names:'') do |c|
- c.body do
%p.fr-pb-0= t('.invite_notice').html_safe



- if !annotation?
= render partial: "shared/dossiers/submit_is_over", locals: { dossier: @dossier }
68 changes: 6 additions & 62 deletions app/components/dsfr/input_component.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Dsfr::InputComponent < ApplicationComponent
include Dsfr::InputErrorable

delegate :object, to: :@form
delegate :errors, to: :object

Expand All @@ -18,10 +20,10 @@ def initialize(form:, attribute:, input_type: :text_field, opts: {}, required: t
# and and valid on input only if another input is invalid
def input_group_opts
opts = {
class: class_names('fr-input-group': true,
'fr-password': password?,
"fr-input-group--error": errors_on_attribute?,
"fr-input-group--valid": !errors_on_attribute? && errors_on_another_attribute?)
class: class_names({
'fr-input-group': true,
'fr-password': password?
}.merge(input_group_error_class_names))
}
if email?
opts[:data] = { controller: 'email-input' }
Expand All @@ -33,38 +35,7 @@ def label_opts
{ class: class_names('fr-label': true, 'fr-password__label': password?) }
end

def input_opts
@opts[:class] = class_names(map_array_to_hash_with_true(@opts[:class])
.merge('fr-password__input': password?,
'fr-input': true,
'fr-mb-0': true,
'fr-input--error': errors_on_attribute?))

if errors_on_attribute? || describedby?
@opts.deep_merge!(aria: {
describedby: describedby_id,
invalid: errors_on_attribute?
})
end

if @required
@opts[:required] = true
end

if email?
@opts.deep_merge!(data: {
action: "blur->email-input#checkEmail",
'email-input-target': 'input'
})
end
@opts
end

# errors helpers
def errors_on_attribute?
errors.has_key?(attribute_or_rich_body)
end

def error_messages
errors.full_messages_for(attribute_or_rich_body)
end
Expand All @@ -78,10 +49,6 @@ def label
object.class.human_attribute_name(@attribute)
end

def hint
I18n.t("activerecord.attributes.#{object.class.name.underscore}.hints.#{@attribute}")
end

# kind of input helpers
def password?
@input_type == :password_field
Expand All @@ -96,27 +63,4 @@ def show_password_id
end

private

def hint?
I18n.exists?("activerecord.attributes.#{object.class.name.underscore}.hints.#{@attribute}")
end

def errors_on_another_attribute?
!errors.empty?
end

# lookup for edge case from `form.rich_text_area`
# rich text uses _rich_#{attribute}, but it is saved on #{attribute}, as well as error messages
def attribute_or_rich_body
case @input_type
when :rich_text_area
@attribute.to_s.sub(/\Arich_/, '').to_sym
else
@attribute
end
end

def map_array_to_hash_with_true(array_or_string_or_nil)
Array(array_or_string_or_nil).to_h { [_1, true] }
end
end
Loading

0 comments on commit 972e915

Please sign in to comment.