From c29270e53191723dafd12461a3bb4c054c1602fd Mon Sep 17 00:00:00 2001 From: Luc Donnet Date: Wed, 3 Jan 2018 16:21:22 +0100 Subject: Fix import messages style Refs #4473 @2 --- .../stylesheets/modules/import_messages.sass | 37 +--------------------- app/helpers/imports_helper.rb | 14 ++++++++ app/views/imports/_import_messages.html.slim | 11 +++---- spec/views/imports/show.html.slim_spec.rb | 5 +-- 4 files changed, 20 insertions(+), 47 deletions(-) diff --git a/app/assets/stylesheets/modules/import_messages.sass b/app/assets/stylesheets/modules/import_messages.sass index 6a088dc06..cde903b00 100644 --- a/app/assets/stylesheets/modules/import_messages.sass +++ b/app/assets/stylesheets/modules/import_messages.sass @@ -4,40 +4,5 @@ h1 padding-bottom: 20px - -.import_message-list +ul.list-unstyled padding-bottom: 20px - - .import_messages-head - display: block - font-size: 1.8rem - font-weight: 700 - border-bottom: 2px solid #4b4b4b - padding: 5px 15px 6px 15px - - dl - dd, dt - display: inline-block - letter-spacing: normal - word-spacing: normal - text-rendering: auto - vertical-align: top - padding: 5px 15px 6px 15px - - dt - position: relative - width: 7% - font-weight: 700 - - &:before - content: "" - display: block - position: absolute - z-index: 1 - top: 0 - left: 0 - width: 250% - border-bottom: 1px solid rgba(164, 164, 164, 0.5) - - dd - width: 93% \ No newline at end of file diff --git a/app/helpers/imports_helper.rb b/app/helpers/imports_helper.rb index 1c4549e50..140660153 100644 --- a/app/helpers/imports_helper.rb +++ b/app/helpers/imports_helper.rb @@ -15,6 +15,20 @@ module ImportsHelper end end + # Compliance check set messages + def bootstrap_class_for_message_criticity message_criticity + case message_criticity + when "error" + "alert alert-danger" + when "warning" + "alert alert-warning" + when "info" + "alert alert-info" + else + message_criticity.to_s + end + end + ############################## #      TO CLEAN!!! ############################## diff --git a/app/views/imports/_import_messages.html.slim b/app/views/imports/_import_messages.html.slim index a10dce065..af10b23e5 100644 --- a/app/views/imports/_import_messages.html.slim +++ b/app/views/imports/_import_messages.html.slim @@ -1,11 +1,8 @@ - if import_messages.any? - .import_message-list - .import_messages-head Messages - dl - - import_messages.each do | import_message | - dt.criticity - = import_message.criticity - dd + ul.list-unstyled.import_message-list + - import_messages.each do | import_message | + li + span(class="#{bootstrap_class_for_message_criticity import_message.criticity}") = t( ['import_messages', 'compliance_check_messages', import_message.message_key].join('.'), import_message.message_attributes.symbolize_keys) diff --git a/spec/views/imports/show.html.slim_spec.rb b/spec/views/imports/show.html.slim_spec.rb index 7a046d1a2..faf473758 100644 --- a/spec/views/imports/show.html.slim_spec.rb +++ b/spec/views/imports/show.html.slim_spec.rb @@ -22,10 +22,7 @@ RSpec.describe '/imports/show', type: :view do messages.each do | message | # require 'htmlbeautifier' # b = HtmlBeautifier.beautify(rendered, indent: ' ') - expect(rendered).to have_selector('.import_message-list dl dt.criticity') do - with_text message.criticity - end - expect(rendered).to have_selector('.import_message-list dl dd') do + expect(rendered).to have_selector('.import_message-list li') do with_text rendered_message( message ) end end -- cgit v1.2.3