diff --git a/app/assets/images/printers/no_available_printers.png b/app/assets/images/printers/no_available_printers.png new file mode 100644 index 000000000..b514cbaf0 Binary files /dev/null and b/app/assets/images/printers/no_available_printers.png differ diff --git a/app/assets/stylesheets/repository/repository_print_label_modal.scss b/app/assets/stylesheets/repository/repository_print_label_modal.scss index fe07f69c5..643b7f16f 100644 --- a/app/assets/stylesheets/repository/repository_print_label_modal.scss +++ b/app/assets/stylesheets/repository/repository_print_label_modal.scss @@ -18,4 +18,14 @@ .modal-footer { text-align: center; } + + .no-printers-container { + padding: 2em; + text-align: center; + + .no-printer-title { + @include font-h3; + margin-top: 1em; + } + } } diff --git a/app/controllers/repository_rows_controller.rb b/app/controllers/repository_rows_controller.rb index bf285b3cc..d876012e7 100644 --- a/app/controllers/repository_rows_controller.rb +++ b/app/controllers/repository_rows_controller.rb @@ -73,7 +73,7 @@ class RepositoryRowsController < ApplicationController def print_modal @repository_rows = @repository.repository_rows.where(id: params[:rows]) - @printers = ['test1', 'test2', 'test3'] + @printers = [] respond_to do |format| format.json do render json: { diff --git a/app/views/repositories/_print_label_modal.html.erb b/app/views/repositories/_print_label_modal.html.erb index 344f7e93a..e9421ce14 100644 --- a/app/views/repositories/_print_label_modal.html.erb +++ b/app/views/repositories/_print_label_modal.html.erb @@ -1,33 +1,48 @@ <div class="modal fade" id="modal-print-repository-row-label" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> - <div class="modal-header"> - <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> - <h4 class="modal-title"> - <% if @repository_rows.size == 1 %> - <%= t('repository_row.modal_print_label.head_title', repository_row: @repository_rows.first.name) %> - <span class="id-label"> - <%= t('repository_row.modal_print_label.id_label', repository_row_id: @repository_rows.first.id) %> - </span> - <% else %> - <%= t('repository_row.modal_print_label.head_title_multiple', repository_rows: @repository_rows.size) %> - <% end %> - </h4> - </div> - <div class="modal-body"> - <div class=printers-container> - <label><%= t('repository_row.modal_print_label.printer') %></label> - <%= select_tag "printers", options_for_select(@printers) %> + <% if @printers.size > 0 %> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> + <h4 class="modal-title"> + <% if @repository_rows.size == 1 %> + <%= t('repository_row.modal_print_label.head_title', repository_row: @repository_rows.first.name) %> + <span class="id-label"> + <%= t('repository_row.modal_print_label.id_label', repository_row_id: @repository_rows.first.id) %> + </span> + <% else %> + <%= t('repository_row.modal_print_label.head_title_multiple', repository_rows: @repository_rows.size) %> + <% end %> + </h4> </div> - <p class="sci-input-container"> - <label><%= t('repository_row.modal_print_label.number_of_copies') %></label> - <%= number_field_tag :copies, 1, min: 1, class: 'sci-input-field print-copies-input' %> - </p> - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-primary" data-dismiss="modal"><%= t('repository_row.modal_print_label.print_label') %></button> - </div> + <div class="modal-body"> + <div class=printers-container> + <label><%= t('repository_row.modal_print_label.printer') %></label> + <%= select_tag "printers", options_for_select(@printers) %> + </div> + <p class="sci-input-container"> + <label><%= t('repository_row.modal_print_label.number_of_copies') %></label> + <%= number_field_tag :copies, 1, min: 1, class: 'sci-input-field print-copies-input' %> + </p> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-primary" data-dismiss="modal"><%= t('repository_row.modal_print_label.print_label') %></button> + </div> + <% else %> + <div class="modal-body no-printers-container"> + <%= image_tag 'printers/no_available_printers' %> + <p class="no-printer-title"> + <%= t('repository_row.modal_print_label.no_printers.title') %> + </p> + <p class="no-printer-body"> + <%= t('repository_row.modal_print_label.no_printers.description') %> + </p> + </div> + <div class="modal-footer"> + <%= link_to t('repository_row.modal_print_label.no_printers.visit_blog'), '', class: "btn btn-primary" %> + </div> + <% end %> </div> </div> </div> diff --git a/config/locales/en.yml b/config/locales/en.yml index fe8ededda..7ca120229 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1626,6 +1626,10 @@ en: printer: "Printer" number_of_copies: "Number of copies" print_label: "Print label" + no_printers: + title: "There seems to be no printer available" + description: "To learn more about printing labels and label printers please visit our blog." + visit_blog: "Visit blog" activities: index: global_activities_title: "Global activities"