diff --git a/app/assets/stylesheets/admin/pure/style.sass b/app/assets/stylesheets/admin/pure/style.sass index e052bcace52e0339c7d1bb1f47362f5aed37fe43..511469210c475bef716565923075c68cdac9a452 100644 --- a/app/assets/stylesheets/admin/pure/style.sass +++ b/app/assets/stylesheets/admin/pure/style.sass @@ -69,6 +69,8 @@ a border-color: $color-valid .form-label color: $color-text-alt +p + .form-label + margin-top: $spacing0 .card margin-bottom: $spacing1 diff --git a/app/helpers/admin/application_helper.rb b/app/helpers/admin/application_helper.rb index c1d8e91089d5e35534e3fe3b9c258157544eca2b..449763dbc83d21409d17b65e2108001e73f0cae0 100644 --- a/app/helpers/admin/application_helper.rb +++ b/app/helpers/admin/application_helper.rb @@ -61,8 +61,8 @@ module Admin::ApplicationHelper end end - def osuny_label(title) - raw "<label class=\"form-label\">#{title}</label>" + def osuny_label(title, classes: '') + raw "<label class=\"form-label #{classes}\">#{title}</label>" end def if_appstack(string) diff --git a/app/models/concerns/with_inheritance.rb b/app/models/concerns/with_inheritance.rb index 0815a0aa3f892b695d5abdb01c156a90bfef218b..3b3002479c448757e8f92e421554e9810eea9ce7 100644 --- a/app/models/concerns/with_inheritance.rb +++ b/app/models/concerns/with_inheritance.rb @@ -23,15 +23,13 @@ module WithInheritance def best(property) value = send(property) - text = value.nil? ? '' : value.to_html - text = Static.html_to_text text - text.blank? ? parent&.send("best_#{property}") : value + html = value.nil? ? '' : value.to_html + Static.blank?(html) ? parent&.send("best_#{property}") : value end def best_source(property, is_ancestor: false) value = send(property) - text = Static.html_to_text value.to_html - return (is_ancestor ? self : nil) if text.present? + return (is_ancestor ? self : nil) if Static.has_content?(value&.to_html) parent&.send(:best_source, property, is_ancestor: true) end end diff --git a/app/services/static.rb b/app/services/static.rb index 9e0ad12cf800cd1df232a1b136bfa83d97af2ecd..c2195d44e774106d8f881c56ae87707025923cf9 100644 --- a/app/services/static.rb +++ b/app/services/static.rb @@ -8,11 +8,15 @@ class Static string = string[0..-2] if string.end_with?('/') string end - - def self.html_to_text(string) - string = ActionController::Base.helpers.strip_tags string - string = string.strip - string + + def self.has_content?(html) + !blank?(html) + end + + def self.blank?(html) + text = ActionController::Base.helpers.strip_tags html + text = text.strip + text.blank? end def self.render(template_static, about, website) diff --git a/app/views/admin/application/a11y/_widget.html.erb b/app/views/admin/application/a11y/_widget.html.erb index 22fcc065b4d04c41fbe0baa95758acb3e07b1b58..6da09712b7044b74ed0fea3db2e4710d6b8e77aa 100644 --- a/app/views/admin/application/a11y/_widget.html.erb +++ b/app/views/admin/application/a11y/_widget.html.erb @@ -4,17 +4,13 @@ action = "<i class=\"fas fa-universal-access fa-2x float-end #{ color}\"></i>" %> <%= osuny_panel t('accessibility.label'), action: action do %> <% if about.accessibility_errors.any? %> - <h3 class="h5 text-danger"> - <%= t 'accessibility.errors', count: about.accessibility_errors.count %> - </h3> + <%= osuny_label t('accessibility.errors', count: about.accessibility_errors.count), classes: 'text-danger' %> <ol class="list-unstyled"> <% about.accessibility_errors.each do |key| %> <li> <hr> - <h3 class="h5 text-danger"><%= t "#{key}.title" %></h3> - <p> - <%= t "#{key}.text_html" %> - </p> + <%= osuny_label t("#{key}.title"), classes: 'text-danger' %> + <p><%= t "#{key}.text_html" %></p> </li> <% end %> </ol> @@ -22,14 +18,12 @@ action = "<i class=\"fas fa-universal-access fa-2x float-end #{ color}\"></i>" <p><%= t 'accessibility.errors', count: 0 %></p> <% end %> <% if about.accessibility_warnings.any? %> - <h3 class="h5"> - <%= t 'accessibility.warnings', count: about.accessibility_warnings.count %> - </h3> + <%= osuny_label t('accessibility.warnings', count: about.accessibility_warnings.count) %> <ul class="list-unstyled"> <% about.accessibility_warnings.each do |key| %> <li> <hr> - <h3 class="h5"><%= t "#{key}.title" %></h3> + <%= osuny_label t("#{key}.title") %> <p> <%= t "#{key}.text_html" %> </p> diff --git a/app/views/admin/application/meta_description/_show.html.erb b/app/views/admin/application/meta_description/_show.html.erb index dc73b186085f9a1434760703c2c729ce7ab57f78..d69a0ec4d8a75f8ca6cc54d36c704aa7dc46ee5e 100644 --- a/app/views/admin/application/meta_description/_show.html.erb +++ b/app/views/admin/application/meta_description/_show.html.erb @@ -1,4 +1,4 @@ <%= osuny_panel t('seo') do %> - <h3 class="h5"><%= t('admin.meta_description.label') %></h3> + <%= osuny_label t('admin.meta_description.label') %> <p><%= sanitize about.meta_description %></p> <% end unless about.meta_description.blank? %> diff --git a/app/views/admin/application/property/_summernote_embeds.html.erb b/app/views/admin/application/property/_summernote_embeds.html.erb index 4953d5ce5680f6984f8ce54d898b9e854b5ac8e3..22dac78fd23104c78bc46305abc352641ffac0a9 100644 --- a/app/views/admin/application/property/_summernote_embeds.html.erb +++ b/app/views/admin/application/property/_summernote_embeds.html.erb @@ -1,4 +1,4 @@ -<h3 class="h5"><%= object.class.human_attribute_name(property) %></h3> +<%= osuny_label object.class.human_attribute_name(property) %> <% if object.summernote_embeds.any? %> <% object.summernote_embeds.each do |embed| %> <div class="row mb-3"> diff --git a/app/views/admin/application/property/_text.html.erb b/app/views/admin/application/property/_text.html.erb index fa38997953ae6cf3e8afac22a04bc9faec3c06d6..9e05d1f266b8618588b8eb6c45059f7a93705b43 100644 --- a/app/views/admin/application/property/_text.html.erb +++ b/app/views/admin/application/property/_text.html.erb @@ -4,19 +4,16 @@ if object.respond_to? "best_#{property}" value = object.public_send("best_#{property}").to_s source = object.public_send("best_#{property}_source") end -text = Static.html_to_text value +title = object.class.human_attribute_name(property) +if source + title += ' <span class="small">' + title += t 'admin.inheritance.sentence_html', link: link_to(source, [:admin, source]) + title += '</span>' +end %> -<h3 class="h5"> - <%= object.class.human_attribute_name(property) %> - <% if source %> - <span class="small text-muted"> - <%= t 'admin.inheritance.sentence_html', - link: link_to(source, [:admin, source]) %> - </span> - <% end %> -</h3> +<%= osuny_label title %> <p> - <% if text.blank? %> + <% if Static.blank?(value) %> <i class="fa fa-exclamation-circle text-danger"></i> <%= t 'properties.text.missing' %> <% else %> diff --git a/app/views/admin/communication/websites/categories/show.html.erb b/app/views/admin/communication/websites/categories/show.html.erb index 7d5181b619c323e53cd263915497d161f1a4ee02..001de20aeb3bac00bb1a4f3dd9ef15ad0bfce01e 100644 --- a/app/views/admin/communication/websites/categories/show.html.erb +++ b/app/views/admin/communication/websites/categories/show.html.erb @@ -8,10 +8,10 @@ </div> <div class="col-md-4"> <%= osuny_panel t('metadata') do %> - <h3 class="h5"><%= Communication::Website::Category.human_attribute_name('slug') %></h3> + <%= osuny_label Communication::Website::Category.human_attribute_name('slug') %> <p><%= @category.slug %></p> <% if @category.parent %> - <h3 class="h5"><%= Communication::Website::Category.human_attribute_name('parent') %></h3> + <%= osuny_label Communication::Website::Category.human_attribute_name('parent') %> <p><%= link_to_if can?(:read, @category.parent), @category.parent, admin_communication_website_category_path( @@ -20,7 +20,7 @@ ) %></p> <% end %> <% if @category.children.any? %> - <h3 class="h5"><%= Communication::Website::Category.human_attribute_name('children') %></h3> + <%= osuny_label Communication::Website::Category.human_attribute_name('children') %> <ul class="list-unstyled mb-0"> <% @category.children.each do |child| %> <li><%= link_to_if can?(:read, child), diff --git a/app/views/admin/communication/websites/menus/items/_form.html.erb b/app/views/admin/communication/websites/menus/items/_form.html.erb index 4926ef4362e310e928104a2fefa246d7836c177c..b54a740d557edeeab4cb644cfcec6c27bfefe013 100644 --- a/app/views/admin/communication/websites/menus/items/_form.html.erb +++ b/app/views/admin/communication/websites/menus/items/_form.html.erb @@ -21,9 +21,7 @@ <div class="col-6 col-lg-4 col-xl-3 col-xxl-2"> <div class="card kind" data-kind="<%= kind %>"> <div class="card-body"> - <h3 class="h5"> - <%= t "enums.communication.website.menu.item.kind.#{kind}" %> - </h3> + <%= osuny_label t("enums.communication.website.menu.item.kind.#{kind}") %> <p class="text-end mb-0"> <i class="<%= Communication::Website::Menu::Item.icon_for(kind) %>"></i><br> </p> diff --git a/app/views/admin/communication/websites/posts/show.html.erb b/app/views/admin/communication/websites/posts/show.html.erb index 3bb68a4febef181c28c913ad0f90885288560a76..fc2206f9ccc424b2061c25c429f5fa249b273afc 100644 --- a/app/views/admin/communication/websites/posts/show.html.erb +++ b/app/views/admin/communication/websites/posts/show.html.erb @@ -17,7 +17,7 @@ <%= osuny_panel t('metadata'), action: action do %> <div class="row pure__row--small"> <div class="col-6"> - <h3 class="h5"><%= Communication::Website::Post.human_attribute_name('published') %></h3> + <%= osuny_label Communication::Website::Post.human_attribute_name('published') %> <p> <%= t @post.published %><% if @post.published & @post.published_at %>, <%= l @post.published_at.to_date, format: :long if @post.published_at %> @@ -25,23 +25,23 @@ </p> </div> <div class="col-6"> - <h3 class="h5"><%= Communication::Website::Post.human_attribute_name('pinned') %></h3> + <%= osuny_label Communication::Website::Post.human_attribute_name('pinned') %> <p><%= t @post.pinned %></p> </div> </div> <% if @post.author %> - <h3 class="h5"><%= Communication::Website::Post.human_attribute_name('author') %></h3> + <%= osuny_label Communication::Website::Post.human_attribute_name('author') %> <p><%= link_to_if can?(:read, @post.author), @post.author, admin_communication_website_author_path(@post.author) %></p> <% end %> <% if @post.categories.any? %> - <h3 class="h5"><%= Communication::Website::Post.human_attribute_name('categories') %></h3> + <%= osuny_label Communication::Website::Post.human_attribute_name('categories') %> <ul class="list-unstyled"> <% @post.categories.each do |category| %> <li><%= link_to_if can?(:read, category), category, [:admin, category] %></li> <% end %> </ul> <% end %> - <h3 class="h5"><%= Communication::Website::Post.human_attribute_name('slug') %></h3> + <%= osuny_label Communication::Website::Post.human_attribute_name('slug') %> <p><%= @post.slug %></p> <% end %> <%= render 'admin/application/featured_image/show', about: @post %> diff --git a/app/views/admin/education/cohorts/show.html.erb b/app/views/admin/education/cohorts/show.html.erb index e6597d907d6a6c5a9949f2ee2baffbb584556fa6..dff68265f6e01ff274adb4a8128ff2e579ef473c 100644 --- a/app/views/admin/education/cohorts/show.html.erb +++ b/app/views/admin/education/cohorts/show.html.erb @@ -4,11 +4,11 @@ <div class="col-md-8"> <div class="card flex-fill w-100"> <div class="card-body"> - <h3 class="h5"><%= Education::Cohort.human_attribute_name('school') %></h3> + <%= osuny_label Education::Cohort.human_attribute_name('school') %> <p><%= link_to_if can?(:read, @cohort.school), @cohort.school, [:admin, @cohort.school] %></p> - <h3 class="h5"><%= Education::Cohort.human_attribute_name('program') %></h3> + <%= osuny_label Education::Cohort.human_attribute_name('program') %> <p><%= link_to_if can?(:read, @cohort.program), @cohort.program, [:admin, @cohort.program] %></p> - <h3 class="h5"><%= Education::Cohort.human_attribute_name('year') %></h3> + <%= osuny_label Education::Cohort.human_attribute_name('year') %> <p><%= link_to_if can?(:read, @cohort.academic_year), @cohort.academic_year, [:admin, @cohort.academic_year] %></p> </div> </div> diff --git a/app/views/admin/education/programs/show.html.erb b/app/views/admin/education/programs/show.html.erb index 76a157351eb1ba31f78bd6ff375e7ccecfcb51a8..c6926ee2b30901731198fd1d38b6acc7e197ee85 100644 --- a/app/views/admin/education/programs/show.html.erb +++ b/app/views/admin/education/programs/show.html.erb @@ -8,18 +8,12 @@ collapsed: false do %> <div class="row"> <div class="col-lg-6"> - <h3 class="h5"> - <%= Education::Program.human_attribute_name('name') %> - </h3> + <%= osuny_label Education::Program.human_attribute_name('name') %> <p><%= @program.name %></p> - <h3 class="h5 mt-4"> - <%= Education::Program.human_attribute_name('diploma') %> - </h3> + <%= osuny_label Education::Program.human_attribute_name('diploma') %> <p><%= link_to @program.diploma, [:admin, @program.diploma] if @program.diploma %></p> <% if @program.schools.any? %> - <h3 class="h5 mt-4"> - <%= Education::Program.human_attribute_name('schools') %> - </h3> + <%= osuny_label Education::Program.human_attribute_name('schools') %> <ul class="list-unstyled"> <% @program.schools.ordered.each do |school| %> <li><%= link_to_if can?(:read, school), school, [:admin, school] %></li> @@ -28,30 +22,18 @@ <% end %> </div> <div class="col-lg-6"> - <h3 class="h5"> - <%= Education::Program.human_attribute_name('short_name') %> - </h3> + <%= osuny_label Education::Program.human_attribute_name('short_name') %> <p><%= @program.short_name %></p> - <h3 class="h5 mt-4"> - <%= Education::Program.human_attribute_name('capacity') %> - </h3> + <%= osuny_label Education::Program.human_attribute_name('capacity') %> <p><%= @program.capacity %></p> - <h3 class="h5 mt-4"> - <%= Education::Program.human_attribute_name('initial') %> - </h3> + <%= osuny_label Education::Program.human_attribute_name('initial') %> <p><%= t @program.initial %></p> - <h3 class="h5 mt-4"> - <%= Education::Program.human_attribute_name('continuing') %> - </h3> + <%= osuny_label Education::Program.human_attribute_name('continuing') %> <p><%= t @program.continuing %></p> - <h3 class="h5 mt-4"> - <%= Education::Program.human_attribute_name('apprenticeship') %> - </h3> + <%= osuny_label Education::Program.human_attribute_name('apprenticeship') %> <p><%= t @program.apprenticeship %></p> <% if @program.downloadable_summary.attached? %> - <h3 class="h5 mt-4"> - <%= Education::Program.human_attribute_name('downloadable_summary') %> - </h3> + <%= osuny_label Education::Program.human_attribute_name('downloadable_summary') %> <p><%= link_to "#{@program.downloadable_summary.filename} (#{ number_to_human_size @program.downloadable_summary.blob.byte_size })", url_for(@program.downloadable_summary), target: :_blank %></p> @@ -105,7 +87,7 @@ <%= render 'admin/application/property/text', object: @program, property: :accessibility %> <%= render 'admin/application/property/text', object: @program, property: :contacts %> <% if @program.registration_url.present? %> - <h3 class="h5"><%= Education::Program.human_attribute_name(:registration_url) %></h3> + <%= osuny_label Education::Program.human_attribute_name(:registration_url) %> <p><%= link_to @program.registration_url, @program.registration_url, target: :_blank %></p> <% end %> </div> @@ -123,12 +105,12 @@ </div> <div class="col-lg-4 col-xxl-3"> <%= render 'admin/education/programs/forms/part', part: :technical do %> - <h3 class="h5"><%= Education::Program.human_attribute_name('published') %></h3> + <%= osuny_label Education::Program.human_attribute_name('published') %> <p><%= t @program.published %></p> - <h3 class="h5"><%= Education::Program.human_attribute_name('slug') %></h3> + <%= osuny_label Education::Program.human_attribute_name('slug') %> <p><%= @program.slug %></p> <% if @program.parent %> - <h3 class="h5"><%= Education::Program.human_attribute_name('parent') %></h3> + <%= osuny_label Education::Program.human_attribute_name('parent') %> <p><%= link_to @program.parent, [:admin, @program.parent] %></p> <% end %> <% end %> diff --git a/app/views/admin/education/programs/show/_roles.html.erb b/app/views/admin/education/programs/show/_roles.html.erb index 8d78eb47a00d19e084c2e2424681d740dd457a3e..e8e362c4185f6cb04eebdf286d4f231f4a24452b 100644 --- a/app/views/admin/education/programs/show/_roles.html.erb +++ b/app/views/admin/education/programs/show/_roles.html.erb @@ -5,7 +5,7 @@ class: button_classes if can?(:update, University::Role) %> <% end %> </div> -<h3 class="h5 mt-4 mb-3"><%= Education::Program.human_attribute_name('roles') %></h3> +<h4 class="h5 mt-4 mb-3"><%= Education::Program.human_attribute_name('roles') %></h4> <% if @roles.any? %> <div class="table-responsive"> <table class="<%= table_classes %>"> diff --git a/app/views/admin/education/programs/show/_teachers.html.erb b/app/views/admin/education/programs/show/_teachers.html.erb index 9847c86fc3617209144f143d11f0dff62756e250..3ead05e8ff9bab85cf6d61f161530167a59db34c 100644 --- a/app/views/admin/education/programs/show/_teachers.html.erb +++ b/app/views/admin/education/programs/show/_teachers.html.erb @@ -5,7 +5,7 @@ class: button_classes if can?(:update, University::Person::Involvement) %> <% end %> </div> -<h3 class="h5 mt-4 mb-3"><%= Education::Program.human_attribute_name('teachers') %></h3> +<h4 class="h5 mt-4 mb-3"><%= Education::Program.human_attribute_name('teachers') %></h4> <% if @teacher_involvements.any? %> <div class="table-responsive"> <table class="<%= table_classes %>"> diff --git a/app/views/admin/university/people/_main_infos.html.erb b/app/views/admin/university/people/_main_infos.html.erb index 72b3fd55b91e52081ab536397533917283cf6421..477cfae60f5b96433e45674daff4d32113f0d988 100644 --- a/app/views/admin/university/people/_main_infos.html.erb +++ b/app/views/admin/university/people/_main_infos.html.erb @@ -5,27 +5,27 @@ <div class="row pure__row--small"> <% unless person.gender.blank? %> <div class="col-md-6"> - <h3 class="h5"><%= University::Person.human_attribute_name('gender') %></h3> + <%= osuny_label University::Person.human_attribute_name('gender') %> <p><%= t("activerecord.attributes.university/person.genders.#{person.gender}") %></p> </div> <% end %> <% unless person.email.blank? %> <div class="col-md-6"> - <h3 class="h5"><%= University::Person.human_attribute_name('email') %></h3> + <%= osuny_label University::Person.human_attribute_name('email') %> <p><%= link_to person.email, "mailto:#{person.email}", target: '_blank' %></p> </div> <% end %> <% ['phone_mobile', 'phone_personal', 'phone_professional'].each do |phone| %> <% unless person[phone].blank? %> <div class="col-md-6"> - <h3 class="h5"><%= University::Person.human_attribute_name(phone) %></h3> + <%= osuny_label University::Person.human_attribute_name(phone) %> <p><%= link_to person[phone], "tel:#{person[phone]}", target: '_blank' %></p> </div> <% end %> <% end %> <% unless person.birthdate.blank? %> <div class="col-md-6"> - <h3 class="h5"><%= University::Person.human_attribute_name('birthdate') %></h3> + <%= osuny_label University::Person.human_attribute_name('birthdate') %> <p><%= l(person.birthdate, format: :birthday) %></p> </div> <% end %> @@ -33,32 +33,32 @@ <% value = person.send property %> <% next if value.blank? %> <div class="col-md-6"> - <h3 class="h5"><%= University::Person.human_attribute_name(property) %></h3> + <%= osuny_label University::Person.human_attribute_name(property) %> <p><%= value %></p> </div> <% end %> </div> <% unless person.biography.blank? %> - <h3 class="h5"><%= University::Person.human_attribute_name('biography') %></h3> + <%= osuny_label University::Person.human_attribute_name('biography') %> <%= person.biography %> <% end %> <% end %> <%= osuny_panel University::Person.human_attribute_name('socials') do %> <% unless person.url.blank? %> - <h3 class="h5"><%= University::Person.human_attribute_name('url') %></h3> + <%= osuny_label University::Person.human_attribute_name('url') %> <p><%= link_to person.url, person.url, target: '_blank' %></p> <% end %> <% unless person.linkedin.blank? %> - <h3 class="h5"><%= University::Person.human_attribute_name('linkedin') %></h3> + <%= osuny_label University::Person.human_attribute_name('linkedin') %> <p><%= link_to person.linkedin, person.linkedin, target: '_blank' %></p> <% end %> <% unless person.twitter.blank? %> - <h3 class="h5"><%= University::Person.human_attribute_name('twitter') %></h3> + <%= osuny_label University::Person.human_attribute_name('twitter') %> <p><%= link_to person.twitter, "https://twitter.com/#{person.twitter}", target: '_blank' %></p> <% end %> <% unless person.mastodon.blank? %> - <h3 class="h5"><%= University::Person.human_attribute_name('mastodon') %></h3> + <%= osuny_label University::Person.human_attribute_name('mastodon') %> <p><%= link_to person.mastodon, person.mastodon, target: '_blank' %></p> <% end %> <% end unless person.url.blank? && person.linkedin.blank? && person.twitter.blank? %> @@ -67,10 +67,10 @@ </div> <div class="col-md-4 col-xl-3"> <%= osuny_panel t('metadata') do %> - <h3 class="h5"><%= University::Person.human_attribute_name('slug') %></h3> + <%= osuny_label University::Person.human_attribute_name('slug') %> <p><%= person.slug %></p> <% if person.user.present? %> - <h3 class="h5"><%= University::Person.human_attribute_name('user') %></h3> + <%= osuny_label University::Person.human_attribute_name('user') %> <p><%= link_to_if can?(:read, person.user), person.user, admin_user_path(person.user) %></p> <% end %> <% end %>