handle label color translation and class name
This commit is contained in:
parent
9595730fde
commit
468c159b52
6 changed files with 22 additions and 20 deletions
|
@ -28,15 +28,3 @@ $colors: "green-tilleul-verveine",
|
|||
color: var(--text-action-high-#{$color});
|
||||
}
|
||||
}
|
||||
|
||||
.grid-tags {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
@media (min-width: 62em) {
|
||||
.grid-tags {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, 1fr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ module Administrateurs
|
|||
end
|
||||
|
||||
def set_colors_collection
|
||||
@colors_collection = ProcedureLabel.colors.values
|
||||
@colors_collection = ProcedureLabel.colors.keys
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -130,7 +130,7 @@ module DossierHelper
|
|||
end
|
||||
|
||||
def tag_label(name, color)
|
||||
tag.span(name, class: "fr-tag fr-tag--sm fr-tag--#{ProcedureLabel.colors.fetch(color.underscore)}")
|
||||
tag.span(name, class: "fr-tag fr-tag--sm fr-tag--#{ProcedureLabel.class_name(color)}")
|
||||
end
|
||||
|
||||
def demandeur_dossier(dossier)
|
||||
|
|
|
@ -28,4 +28,8 @@ class Label < ApplicationRecord
|
|||
|
||||
validates :name, :color, presence: true
|
||||
validates :name, length: { maximum: NAME_MAX_LENGTH }
|
||||
|
||||
def self.class_name(color)
|
||||
ProcedureLabel.colors.fetch(color.underscore)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
= t('activerecord.attributes.procedure_label.color')
|
||||
= asterisk
|
||||
|
||||
.grid-tags
|
||||
- @colors_collection.each do |color|
|
||||
.fr-fieldset__element
|
||||
.fr-fieldset__element.fr-fieldset__element--inline
|
||||
.fr-radio-group
|
||||
= f.radio_button :color, color, checked: (label.color == color.underscore)
|
||||
= f.label :color, value: color, class: "fr-label fr-tag fr-tag--sm fr-tag--#{color}"
|
||||
= f.radio_button :color, color, checked: (label.color == color)
|
||||
= f.label :color, t("activerecord.attributes.label/color.#{color}"), value: color, class: "fr-label fr-tag fr-tag--sm fr-tag--#{ProcedureLabel.class_name(color)}"
|
||||
|
||||
= render Procedure::FixedFooterComponent.new(procedure: @procedure, form: f)
|
||||
|
|
|
@ -4,3 +4,14 @@ fr:
|
|||
procedure_label:
|
||||
color: Couleur
|
||||
name: Nom
|
||||
procedure_label/color: &color
|
||||
green_tilleul_verveine: 'tilleul'
|
||||
green_bourgeon: 'bourgeon'
|
||||
green_emeraude: 'émeraude'
|
||||
green_menthe: 'menthe'
|
||||
blue_ecume: 'écume'
|
||||
purple_glycine: 'glycine'
|
||||
pink_macaron: 'macaron'
|
||||
yellow_tournesol: 'tournesol'
|
||||
brown_cafe_creme: 'café'
|
||||
beige_gris_galet: 'galet'
|
||||
|
|
Loading…
Reference in a new issue