From 1ccabf62b3848e2dbefdd549e353386df04b13a0 Mon Sep 17 00:00:00 2001 From: Jure Grabnar Date: Fri, 28 Jun 2019 01:38:33 +0200 Subject: [PATCH] Add preview banner in external protocols --- .../protocols/external_protocols_tab.js | 12 ++++-- .../stylesheets/protocol_management.scss | 40 +++++++++++++++---- .../_protocol_card.html.erb | 2 +- .../index/_external_protocols_tab.html.erb | 16 +++++++- config/locales/en.yml | 1 + 5 files changed, 58 insertions(+), 13 deletions(-) diff --git a/app/assets/javascripts/protocols/external_protocols_tab.js b/app/assets/javascripts/protocols/external_protocols_tab.js index 5564aae24..b194d920d 100644 --- a/app/assets/javascripts/protocols/external_protocols_tab.js +++ b/app/assets/javascripts/protocols/external_protocols_tab.js @@ -6,22 +6,26 @@ function applyClickCallbackOnProtocolCards() { $(this).removeClass('active'); } else { + var curr_protocol_card = $(this); $('.protocol-card').removeClass('active'); - $(this).addClass('active'); + curr_protocol_card.addClass('active'); $.ajax({ - url: $(this).data('show-url'), + url: $(curr_protocol_card).data('show-url'), type: 'GET', dataType: 'json', data: { - protocol_source: $(this).data('protocol-source'), - protocol_id: $(this).data('show-protocol-id') + protocol_source: $(curr_protocol_card).data('protocol-source'), + protocol_id: $(curr_protocol_card).data('show-protocol-id') }, beforeSend: animateSpinner($('.protocol-preview-panel'), true), success: function(data) { $('.empty-preview-panel').hide(); $('.full-preview-panel').show(); + $('.btn-holder').html($(curr_protocol_card).find('.external-import-btn').clone()); $('.preview-iframe').contents().find('body').html(data.html); + + initLoadProtocolModalPreview(); animateSpinner($('.protocol-preview-panel'), false); }, error: function(_error) { diff --git a/app/assets/stylesheets/protocol_management.scss b/app/assets/stylesheets/protocol_management.scss index 272d2ae1b..f750b75f1 100644 --- a/app/assets/stylesheets/protocol_management.scss +++ b/app/assets/stylesheets/protocol_management.scss @@ -184,13 +184,6 @@ padding-right: 0px; } - .external-import-btn { - background-color: $brand-primary; - color: $color-white; - font-size: 12px; - padding-bottom: 3px; - padding-top: 3px; - } } .protocol-preview-panel { @@ -230,10 +223,35 @@ } .full-preview-panel { + height: 100%; + } + + .preview-banner { + align-items: center; + background-color: $color-white; + border-bottom: 1px solid $color-alto; + color: $color-dove-gray; + display: flex; + font-size: 16px; + height: 40px; + padding-left: 21px; + + .txt-holder { + padding-left: 0; + } + + .btn-holder { + padding-right: 21px; + } + } + + + .preview-holder { display: flex; flex-direction: column; height: 100%; overflow: hidden; + padding-bottom: 40px; padding-left: 21px; padding-right: 21px; width: 100%; @@ -246,4 +264,12 @@ } } } + + .external-import-btn { + background-color: $brand-primary; + color: $color-white; + font-size: 12px; + padding-bottom: 3px; + padding-top: 3px; + } } diff --git a/app/views/protocol_importers/_protocol_card.html.erb b/app/views/protocol_importers/_protocol_card.html.erb index 10ba053f2..f7a28ae88 100644 --- a/app/views/protocol_importers/_protocol_card.html.erb +++ b/app/views/protocol_importers/_protocol_card.html.erb @@ -16,7 +16,7 @@ <%= t('protocol_importers.card.views_and_steps', nr_of_views: protocol[:nr_of_views], nr_of_steps: protocol[:nr_of_steps]) %>
- +
diff --git a/app/views/protocols/index/_external_protocols_tab.html.erb b/app/views/protocols/index/_external_protocols_tab.html.erb index ccf5c7fe8..dc85ed439 100644 --- a/app/views/protocols/index/_external_protocols_tab.html.erb +++ b/app/views/protocols/index/_external_protocols_tab.html.erb @@ -58,14 +58,17 @@
+
<%= t('protocols.index.external_protocols.preview_panel.empty_title') %>
+

+
<%= t('protocols.index.external_protocols.preview_panel.empty_subtext') %> @@ -74,7 +77,18 @@
diff --git a/config/locales/en.yml b/config/locales/en.yml index 1fd112ddb..26145a01f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1749,6 +1749,7 @@ en: preview_panel: empty_title: 'PROTOCOL PREVIEW' empty_subtext: 'Click on the protocol in the list to preview it here' + banner_text: 'Protocol Preview' steps: completed: 'Completed'