diff --git a/app/assets/javascripts/application.js.erb b/app/assets/javascripts/application.js.erb index bd6c65afd..9fdd4b3bd 100644 --- a/app/assets/javascripts/application.js.erb +++ b/app/assets/javascripts/application.js.erb @@ -45,6 +45,7 @@ //= require activestorage //= require global_activities/side_pane //= require protocols/header +//= require protocols/print //= require marvinjslauncher //= require jstree.min //= require_tree ./repositories/renderers @@ -56,7 +57,6 @@ //= require sidebar //= require turbolinks - // Initialize links for submitting forms. This is useful for submitting // forms with clicking on links outside form in cases when other than // GET method is used. diff --git a/app/assets/javascripts/protocols/print.js b/app/assets/javascripts/protocols/print.js new file mode 100644 index 000000000..12c026b24 --- /dev/null +++ b/app/assets/javascripts/protocols/print.js @@ -0,0 +1,3 @@ +$(document).on('submit', '#print-protocol-form', function() { + $('#print-protocol-modal').modal('hide'); +}); diff --git a/app/assets/stylesheets/print_protocol.scss b/app/assets/stylesheets/print_protocol.scss new file mode 100644 index 000000000..7e0330d49 --- /dev/null +++ b/app/assets/stylesheets/print_protocol.scss @@ -0,0 +1,191 @@ +@import "shared_styles/constants/*"; +@import "constants"; + +@page { + size: A4; + margin: 8mm; +} + +body { + font-family: Lato, "Open Sans", Arial, Helvetica, sans-serif; + font-size: 16px; + -webkit-print-color-adjust: exact; + print-color-adjust: exact; +} + +.print-protocol-header { + font-size: .8em; + + img { + height: .8em; + } +} + +h1 { + font-size: 1.5em; +} + +h2 { + font-size: 1.3em; + + .fa-check-circle { + color: $brand-success; + font-size: 1.3em; + } +} + +h3 { + font-size: 1em; +} + +hr { + background-color: $color-alto; + border-width: 0; + height: 1px; +} + +.print-step { + margin: 5em 0; +} + +.step-check-circle { + border-radius: 50%; + border: .15em solid $color-alto; + color: $color-white; + display: inline-block; + height: 1.1em; + text-align: center; + vertical-align: text-bottom; + width: 1.1em; + + &.checked { + background-color: $brand-success; + border-color: $brand-success; + } +} + +.print-checklist-item { + margin-bottom: 1em; + + span { + display: inline-block; + vertical-align: top; + } +} + +.checklist-checkbox { + border: .15em solid $color-alto; + border-radius: .2em; + display: inline-block; + height: 1em; + text-align: center; + width: 1em; + + &.checked { + background-color: $brand-primary; + border-color: $brand-primary; + color: $color-white; + font-size: 1em; + } +} + +.print-table { + border-collapse: collapse; + text-align: center; + width: 100%; + + &, + td, + th { + border: 1px solid $color-silver-chalice; + } + + th { + font-weight: normal; + } + + th, + td:first-child { + background: $color-concrete; + } + + td { + padding: .15em .3em; + } +} + +.print-asset { + margin: 1em; + + p { + font-style: italic; + } + + &.thumbnail { + float: left; + padding: 1em; + } + + &.thumbnail, + &.list { + border: 1px solid $color-silver-chalice; + } + + &.list { + padding: .5em 1em; + } + + &.inline { + margin: 5em 0; + text-align: center; + + img { + max-width: 100%; + } + } +} + +.print-thumbnails { + clear: both; + overflow: hidden; +} + +.print-asset-icon { + display: inline-block; + font-size: $font-size-h2; + text-align: center; + width: 24px; + + .fa-file-pdf { + color: $pdf-color; + } + + .fa-image { + color: $brand-primary; + } +} + +.print-comments { + margin-bottom: 5em; +} + +.print-comment-container { + margin-bottom: 1em; +} + +.print-comment-header { + .user-avatar { + float: left; + margin-right: 1em; + } + + .user-name { + color: $color-silver-chalice; + } +} + +.print-comment-footer { + color: $color-silver-chalice; + font-size: .8em; + text-align: right; +} diff --git a/app/assets/stylesheets/shared_styles/elements/checkboxes.scss b/app/assets/stylesheets/shared_styles/elements/checkboxes.scss index 12e31c49c..608661686 100644 --- a/app/assets/stylesheets/shared_styles/elements/checkboxes.scss +++ b/app/assets/stylesheets/shared_styles/elements/checkboxes.scss @@ -8,6 +8,7 @@ display: inline-block; height: var(--sci-checkbox-size); position: relative; + vertical-align: middle; width: var(--sci-checkbox-size); } diff --git a/app/controllers/protocols_controller.rb b/app/controllers/protocols_controller.rb index 245537a65..52a1e5781 100644 --- a/app/controllers/protocols_controller.rb +++ b/app/controllers/protocols_controller.rb @@ -11,6 +11,8 @@ class ProtocolsController < ApplicationController include TeamsHelper include CommentHelper + layout 'protocols/print', only: :print + before_action :check_create_permissions, only: %i( create_new_modal create @@ -108,6 +110,11 @@ class ProtocolsController < ApplicationController end end + def print + @protocol = Protocol.find(params[:id]) + render_403 && return unless @protocol.my_module.blank? || can_read_protocol_in_module?(@protocol) + end + def linked_children respond_to do |format| format.json do diff --git a/app/views/layouts/protocols/print.html.erb b/app/views/layouts/protocols/print.html.erb new file mode 100644 index 000000000..1e6f38d0c --- /dev/null +++ b/app/views/layouts/protocols/print.html.erb @@ -0,0 +1,14 @@ + + +
++ <%= t('.header.printed_from') %> + + <%= image_tag 'logo.png' %> + + <%= t('.header.print_info', datetime: l(DateTime.current, format: :full), full_name: current_user.full_name) %> +
+ ++ <% col = "A" %> + <% table_data[0].length.times do %> + | <%= col %> | + <% col.succ! %> + <% end %> +
---|---|
<%= row + 1 %> | + <% tr.each do |td| %> +<%= td %> | + <% end %> +
<%= asset.blob.filename %>
+<%= asset.blob.filename %>
+
<%= t('Comments') %>:
+ <% step.step_comments.each do |comment| %> +