From c02604432247e49e88d07554aa6ac5aab3b9ddfb Mon Sep 17 00:00:00 2001 From: zmagod Date: Wed, 25 Apr 2018 07:32:49 +0200 Subject: [PATCH 1/3] fixes flash message [fixes SCI-2142] --- app/assets/javascripts/application.js.erb | 13 ++++++--- app/views/layouts/application.html.erb | 33 +++-------------------- app/views/layouts/fluid.html.erb | 2 ++ app/views/shared/_flash_alerts.html.erb | 26 ++++++++++++++++++ 4 files changed, 41 insertions(+), 33 deletions(-) create mode 100644 app/views/shared/_flash_alerts.html.erb diff --git a/app/assets/javascripts/application.js.erb b/app/assets/javascripts/application.js.erb index 0725dd6ce..5f5a27d09 100644 --- a/app/assets/javascripts/application.js.erb +++ b/app/assets/javascripts/application.js.erb @@ -204,6 +204,12 @@ var HelperModule = (function(){ } } + helpers.dismissAlert = function() { + $('#alert-flash').on('click', function() { + $('#alert-flash').alert('close'); + }) + } + helpers.flashAlertMsg = function(message, type) { var alertType; var glyphSign; @@ -221,23 +227,22 @@ var HelperModule = (function(){ alertType = ' alert-warning '; glyphSign = ' glyphicon-exclamation-sign '; } - var htmlSnippet = '
' + '
' + - '' + ' ' + '' + message + '' + '
' + '
'; $('#notifications').html(htmlSnippet); helpers.hideFlashMsg(); + helpers.dismissAlert(); } $( document ).ready(function() { helpers.treeLinkTruncation(); helpers.hideFlashMsg(); + helpers.dismissAlert(); }); return helpers; diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index ebad3d034..507624b79 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -36,35 +36,10 @@ <%= render "shared/file_preview_modal.html.erb" %> <%= render "shared/navigation" %> -
- <% if flash[:success] %> -
-
- - - <%= sanitize_input(flash[:success]) %> -
-
- <% end %> - <% if notice %> -
-
- - - <%= notice %> -
-
- <% end %> - <% if alert and !alert.empty? or flash[:error]%> -
-
- - - <%= alert || sanitize_input(flash[:error]) %> -
-
- <% end %> -
+ <% unless user_signed_in? %> + <%= render partial: 'shared/flash_alerts', + locals: { flash: flash, notice: notice, alert: alert } %> + <% end %> <%= render "shared/left_menu_bar" if user_signed_in? %>
diff --git a/app/views/layouts/fluid.html.erb b/app/views/layouts/fluid.html.erb index fc2c73d27..f94eaaf05 100644 --- a/app/views/layouts/fluid.html.erb +++ b/app/views/layouts/fluid.html.erb @@ -1,5 +1,7 @@ <% content_for :content do %>
+ <%= render partial: 'shared/flash_alerts', + locals: { flash: flash, notice: notice, alert: alert } %> diff --git a/app/views/shared/_flash_alerts.html.erb b/app/views/shared/_flash_alerts.html.erb new file mode 100644 index 000000000..c47040588 --- /dev/null +++ b/app/views/shared/_flash_alerts.html.erb @@ -0,0 +1,26 @@ +
+ <% if flash[:success] %> +
+
+ + <%= sanitize_input(flash[:success]) %> +
+
+ <% end %> + <% if notice %> +
+
+ + <%= notice %> +
+
+ <% end %> + <% if alert and !alert.empty? or flash[:error]%> +
+
+ + <%= alert || sanitize_input(flash[:error]) %> +
+
+ <% end %> +
From 4d6e9954811c6a78b118b636a4bc2ff12d6d2437 Mon Sep 17 00:00:00 2001 From: zmagod Date: Wed, 25 Apr 2018 10:43:16 +0200 Subject: [PATCH 2/3] add dismiss buttons back --- app/assets/javascripts/application.js.erb | 7 +++++-- app/assets/stylesheets/themes/scinote.scss | 19 +++++++++++++++++++ app/views/shared/_flash_alerts.html.erb | 9 ++++++--- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/application.js.erb b/app/assets/javascripts/application.js.erb index 5f5a27d09..95af7f8d6 100644 --- a/app/assets/javascripts/application.js.erb +++ b/app/assets/javascripts/application.js.erb @@ -200,7 +200,7 @@ var HelperModule = (function(){ flash.fadeTo(500, 0).slideUp(500, function () { $(this).remove(); }); - }, 5000); + }, 3000); } } @@ -229,7 +229,10 @@ var HelperModule = (function(){ } var htmlSnippet = '
' + - '
' + + '
' + + '' + ' ' + '' + message + '' + '
' + diff --git a/app/assets/stylesheets/themes/scinote.scss b/app/assets/stylesheets/themes/scinote.scss index b6cf057ca..00c59c3f9 100644 --- a/app/assets/stylesheets/themes/scinote.scss +++ b/app/assets/stylesheets/themes/scinote.scss @@ -1714,3 +1714,22 @@ th.custom-field .modal-tooltiptext { .parse-records-table { max-height: 200px; } + +#alert-flash { + button { + margin-right: 400px; + } + + .glyphicon { + margin-left: 100px; + } + + @media(max-width:768px) { + button { + display: none; + } + .glyphicon { + margin-left: 10px; + } + } + } diff --git a/app/views/shared/_flash_alerts.html.erb b/app/views/shared/_flash_alerts.html.erb index c47040588..ec84827e6 100644 --- a/app/views/shared/_flash_alerts.html.erb +++ b/app/views/shared/_flash_alerts.html.erb @@ -1,7 +1,8 @@
<% if flash[:success] %>
-
+
+ <%= sanitize_input(flash[:success]) %>
@@ -9,7 +10,8 @@ <% end %> <% if notice %>
-
+
+ <%= notice %>
@@ -17,7 +19,8 @@ <% end %> <% if alert and !alert.empty? or flash[:error]%>
-
+
+ <%= alert || sanitize_input(flash[:error]) %>
From abbc0995f2f7e0ee0982d0e44ac2502264d2ce04 Mon Sep 17 00:00:00 2001 From: zmagod Date: Thu, 3 May 2018 14:51:49 +0200 Subject: [PATCH 3/3] fix css --- app/assets/stylesheets/themes/scinote.scss | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/assets/stylesheets/themes/scinote.scss b/app/assets/stylesheets/themes/scinote.scss index 0a42681e1..f34e12402 100644 --- a/app/assets/stylesheets/themes/scinote.scss +++ b/app/assets/stylesheets/themes/scinote.scss @@ -1728,6 +1728,7 @@ th.custom-field .modal-tooltiptext { } #alert-flash { + button { margin-right: 400px; } @@ -1737,9 +1738,11 @@ th.custom-field .modal-tooltiptext { } @media(max-width:768px) { + button { display: none; } + .glyphicon { margin-left: 10px; }