From 9ce95470b37bf02f4fa297538a6066498dcdaace Mon Sep 17 00:00:00 2001 From: zmagod Date: Tue, 28 Mar 2017 15:14:05 +0200 Subject: [PATCH] fixes alert messages in samples [fixes SCI-1135] --- app/assets/javascripts/application.js.erb | 3 +++ .../javascripts/samples/sample_datatable.js.erb | 6 +++--- app/controllers/application_controller.rb | 14 +++++++------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/application.js.erb b/app/assets/javascripts/application.js.erb index 56bf2fb5f..be79110f3 100644 --- a/app/assets/javascripts/application.js.erb +++ b/app/assets/javascripts/application.js.erb @@ -234,6 +234,9 @@ var HelperModule = (function(){ } else if (type === 'danger') { alertType = ' alert-danger '; glyphSign = ' glyphicon-exclamation-sign '; + } else if (type === 'info') { + alertType = ' alert-info '; + glyphSign = ' glyphicon-exclamation-sign '; } var htmlSnippet = '
' + diff --git a/app/assets/javascripts/samples/sample_datatable.js.erb b/app/assets/javascripts/samples/sample_datatable.js.erb index 0dd4b21e7..d492cf4ba 100644 --- a/app/assets/javascripts/samples/sample_datatable.js.erb +++ b/app/assets/javascripts/samples/sample_datatable.js.erb @@ -504,7 +504,7 @@ function onClickEdit() { error: function (e, data, status, xhr) { if (e.status == 403) { HelperModule.flashAlertMsg( - I18n.t('samples.js.permission_error'), 'danger' + I18n.t('samples.js.permission_error'), e.responseJSON.style ); changeToViewMode(); updateButtons(); @@ -1245,7 +1245,7 @@ function changeToEditMode() { renderFormError(undefined, $(li).find('.text-edit'), - Object.keys(msg)[0] + ' ' + msg.name.toString()); + msg.name.toString()); var verticalHeight = $(li).offset().top; dropdownList.scrollTo(verticalHeight,0); setTimeout(function() { @@ -1332,7 +1332,7 @@ function changeToEditMode() { renderFormError(undefined, $(li).find('.text-edit'), - Object.keys(msg)[0] + ' ' + msg.name.toString()); + msg.name.toString()); var verticalHeight = $(li).offset().top; dropdownList.scrollTo(verticalHeight,0); setTimeout(function() { diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f0314e07a..b3fcb0de1 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -44,16 +44,16 @@ class ApplicationController < ActionController::Base end end - def render_403 + def render_403(style = 'danger') respond_to do |format| - format.html { + format.html do render file: 'public/403.html', status: :forbidden, layout: false - } - format.json { - render json: {}, status: :forbidden - } + end + format.json do + render json: { style: style }, status: :forbidden + end end - return true + true end def render_404