diff --git a/app/views/admin/education/programs/_form.html.erb b/app/views/admin/education/programs/_form.html.erb index 94ceac5fdf2df047072d79eac95df3531604afc1..11fe6ccbfec5b975415ed49b4cde99154baa8c51 100644 --- a/app/views/admin/education/programs/_form.html.erb +++ b/app/views/admin/education/programs/_form.html.erb @@ -48,12 +48,12 @@ <h5 class="card-title mb-0"><%= t('education.program.useful_informations') %></h5> </div> <div class="card-body"> - <%= f.input :description %> - <%= render 'admin/education/programs/forms/rich_text_area', f: f, property: :registration %> - <%= render 'admin/education/programs/forms/rich_text_area', f: f, property: :pricing %> - <%= render 'admin/education/programs/forms/rich_text_area', f: f, property: :duration %> - <%= render 'admin/education/programs/forms/rich_text_area', f: f, property: :accessibility %> - <%= render 'admin/education/programs/forms/rich_text_area', f: f, property: :other %> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :description %> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :registration %> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :pricing %> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :duration %> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :accessibility %> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :other %> </div> </div> </div> @@ -63,7 +63,7 @@ <h5 class="card-title mb-0"><%= t('activerecord.attributes.education/program.team') %></h5> </div> <div class="card-body"> - <%= render 'admin/education/programs/forms/rich_text_area', f: f, property: :contacts %> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :contacts %> </div> <div class="card-body"> <%= f.association :teachers, @@ -107,15 +107,15 @@ <div class="card-body"> <div class="row"> <div class="col-md-4"> - <%= render 'admin/education/programs/forms/rich_text_area', f: f, property: :objectives %> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :objectives %> </div> <div class="col-md-4"> - <%= render 'admin/education/programs/forms/rich_text_area', f: f, property: :opportunities %> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :opportunities %> </div> <div class="col-md-4"> - <%= render 'admin/education/programs/forms/rich_text_area', f: f, property: :prerequisites %> - <%= render 'admin/education/programs/forms/rich_text_area', f: f, property: :pedagogy %> - <%= render 'admin/education/programs/forms/rich_text_area', f: f, property: :evaluation %> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :prerequisites %> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :pedagogy %> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :evaluation %> </div> </div> </div> diff --git a/app/views/admin/education/programs/forms/_rich_text_area.html.erb b/app/views/admin/education/programs/forms/_input_with_inheritance.html.erb similarity index 82% rename from app/views/admin/education/programs/forms/_rich_text_area.html.erb rename to app/views/admin/education/programs/forms/_input_with_inheritance.html.erb index 50abd4dd0ce3ec6de5d3cab6ef1e4273e9e7c887..1553ecf8787c044259f170b646cb82d6e094a20c 100644 --- a/app/views/admin/education/programs/forms/_rich_text_area.html.erb +++ b/app/views/admin/education/programs/forms/_input_with_inheritance.html.erb @@ -2,6 +2,8 @@ program = f.object best_prop_value = program.public_send("best_#{property}") best_prop_source = program.public_send("best_#{property}_source") +is_rich_text = best_prop_value.is_a?(ActionText::RichText) +as = is_rich_text ? :rich_text_area : :text id = "#{property}Collapse" %> <% if best_prop_source %> @@ -17,7 +19,7 @@ id = "#{property}Collapse" </a> </div> <div class="collapse" id="<%= id %>"> - <%= f.input property, as: :rich_text_area, label: false %> + <%= f.input property, as: as, label: false %> <div class="bg-light p-2 mt-n2"> <b><%= t 'admin.inheritance.sentence_html', link: link_to(best_prop_source, [:admin, best_prop_source]) %></b><br> <%= best_prop_value %> @@ -25,5 +27,5 @@ id = "#{property}Collapse" </div> </div> <% else %> - <%= f.input property, as: :rich_text_area %> + <%= f.input property, as: as %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 0cfcfdfea20a380af4adf181f5a705d58f77eb95..2809996a77254e6316cb35e105cb8913a4131d33 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -46,6 +46,9 @@ en: attachment_not_available: Attachment not available dashboard: Dashboard infos: Infos + inheritance: + sentence_html: Value inherited from %{link} + status: Inherited value password_hint: Leave blank if you do not wish to change the password. successfully_created_html: "<i>%{model}</i> was successfully created." successfully_destroyed_html: "<i>%{model}</i> was successfully destroyed." diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 0c9b6919723521bedad6bd688837076261ecf2f3..886a1e0025237f44e055198c333324182d626693 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -43,12 +43,12 @@ fr: one: Utilisateur·rice other: Utilisateur·rice·s admin: - inheritance: - status: Valeur héritée - sentence_html: Valeur héritée de %{link} attachment_not_available: Impossible d'accéder à l'élément dashboard: Tableau de bord infos: Infos + inheritance: + sentence_html: Valeur héritée de %{link} + status: Valeur héritée password_hint: Laissez vide si vous ne souhaitez pas modifier le mot de passe. successfully_created_html: "<i>%{model}</i> a bien été créé(e)." successfully_destroyed_html: "<i>%{model}</i> a bien été détruit(e)."