Merge pull request #1921 from mlorb/ml-sci-3641

Fix page redirect and add success flash msg after protocols.io import [SCI-3641]
This commit is contained in:
mlorb 2019-07-12 15:52:40 +02:00 committed by GitHub
commit 5bc8eb7392
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 22 additions and 10 deletions

View file

@ -1,4 +1,5 @@
/* global animateSpinner PerfectSb initHandsOnTable */
/* global HelperModule */
/* eslint-disable no-use-before-define, no-alert */
function applyClickCallbackOnProtocolCards() {
@ -194,7 +195,8 @@ function handleFormSubmit(modal) {
data: form.serialize(), // serializes the form's elements.
success: function(data) {
animateSpinner(modal, false);
window.location.replace(data.redirect_url);
modal.modal('hide');
HelperModule.flashAlertMsg(data.message, 'success');
},
error: function(data) {
showFormErrors(modal, data.responseJSON.errors);
@ -246,7 +248,7 @@ function initLoadProtocolModalPreview() {
handleFormSubmit(modal);
},
error: function() {
alert('Server error');
HelperModule.flashAlertMsg('Server error', 'danger');
},
complete: function() {
animateSpinner(null, false);

View file

@ -12,6 +12,10 @@ body,
min-width: 320px;
}
#content-wrapper .container #notifications {
margin-left: -15px;
}
// Word wrapping everywhere, except for table header of "datatables.js"
body,
table.dataTable td {

View file

@ -89,9 +89,11 @@ class ExternalProtocolsController < ApplicationController
if service_call.succeed?
protocol_type = service_call.protocol.in_repository_public? ? 'public' : 'private'
message = t('protocols.index.external_protocols.import.success_flash',
name: service_call.protocol.name,
type: t("protocols.index.external_protocols.import.#{protocol_type}"))
render json: { protocol: service_call.protocol,
redirect_url: protocols_path(type: protocol_type) }
message: message }
else
render json: { errors: service_call.errors }, status: 400
end

View file

@ -45,7 +45,7 @@
<%= render "shared/file_preview_modal.html.erb" %>
<%= render "shared/file_edit_modal.html.erb" %>
<%= render "shared/navigation" %>
<% if user_signed_in? && flash[:system_notification_modal] && current_user.show_login_system_notification? %>
<%= render partial: "/system_notifications/system_notification_modal", locals: { notification: current_user.user_system_notifications.show_on_login(true) } %>
<% else %>
@ -67,7 +67,6 @@
<p data-hook="general-no-teams-text"><%=t 'general.no_teams.text' %></p>
</div>
<% else %>
<%= yield :flash_messages_div %>
<%= yield :content %>
<% end %>
</div>

View file

@ -1,5 +1,9 @@
<% content_for :content do %>
<div class="container <%= yield :container_class %>">
<% if user_signed_in? %>
<%= render partial: 'shared/flash_alerts',
locals: { flash: flash, notice: notice, alert: alert } %>
<% end %>
<%= yield %>
</div>
<% end %>

View file

@ -5,7 +5,6 @@
<% provide(:head_title, t("projects.reports.new.head_title", project: h(@project.name)).html_safe) %>
<div id="notifications"></div>
<%= render partial: "reports/new/report_navigation" %>
<div class="content-pane" id="report-new">

View file

@ -1,7 +1,5 @@
<% provide(:head_title, t('libraries.repository_columns.head_title', repository: @repository.name)) %>
<% provide(:flash_messages_div) do %>
<div id="notifications"></div>
<% end %>
<div class="content-pane">
<div class="repository-columns-header container">
<div class="row">

View file

@ -1761,6 +1761,10 @@ en:
empty_title: 'PROTOCOL PREVIEW'
empty_subtext: 'Click on the protocol in the list to preview it here'
banner_text: 'Protocol Preview'
import:
public: "Team protocols"
private: "My protocols"
success_flash: 'Protocol <strong>%{name}</strong> successfully imported to %{type}.'
steps:
completed: 'Completed'