mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-27 02:04:33 +08:00
Add print label button to repository toolbar (#3453)
This commit is contained in:
parent
be777a8919
commit
d373c174ee
8 changed files with 25 additions and 7 deletions
|
@ -65,6 +65,7 @@ var RepositoryDatatable = (function(global) {
|
|||
$('#restoreRepositoryRecords').prop('disabled', true);
|
||||
$('#deleteRepositoryRecords').prop('disabled', true);
|
||||
$('#editDeleteCopy').hide();
|
||||
$('#toolbarPrintLabel').hide();
|
||||
} else {
|
||||
if (rowsSelected.length === 1) {
|
||||
$('#editRepositoryRecord').prop('disabled', false);
|
||||
|
@ -82,6 +83,7 @@ var RepositoryDatatable = (function(global) {
|
|||
$('#archiveRepositoryRecordsButton').prop('disabled', true);
|
||||
}
|
||||
$('#editDeleteCopy').show();
|
||||
$('#toolbarPrintLabel').show();
|
||||
}
|
||||
} else if (currentMode === 'editMode') {
|
||||
$(TABLE_WRAPPER_ID).addClass('editing');
|
||||
|
@ -100,6 +102,8 @@ var RepositoryDatatable = (function(global) {
|
|||
$('.repository-row-selector').prop('disabled', true);
|
||||
$('.dataTables_filter input').prop('disabled', true);
|
||||
}
|
||||
|
||||
$('#toolbarPrintLabel').data('rows', JSON.stringify(rowsSelected));
|
||||
}
|
||||
|
||||
function clearRowSelection() {
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
$.ajax({
|
||||
method: 'GET',
|
||||
url: $(this).data('url'),
|
||||
data: { rows: JSON.parse($(this).data('rows')) },
|
||||
dataType: 'json'
|
||||
}).done(function(xhr, settings, data) {
|
||||
$('body').append($.parseHTML(data.responseJSON.html));
|
||||
|
|
|
@ -5,7 +5,7 @@ class RepositoryRowsController < ApplicationController
|
|||
include MyModulesHelper
|
||||
|
||||
before_action :load_repository, except: :show
|
||||
before_action :load_repository_row, only: %i(update assigned_task_list print_modal)
|
||||
before_action :load_repository_row, only: %i(update assigned_task_list)
|
||||
before_action :check_read_permissions, except: %i(show create update delete_records copy_records)
|
||||
before_action :check_snapshotting_status, only: %i(create update delete_records copy_records)
|
||||
before_action :check_create_permissions, only: :create
|
||||
|
@ -72,6 +72,7 @@ class RepositoryRowsController < ApplicationController
|
|||
end
|
||||
|
||||
def print_modal
|
||||
@repository_rows = @repository.repository_rows.where(id: params[:rows])
|
||||
@printers = ['test1', 'test2', 'test3']
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
|
|
|
@ -4,10 +4,14 @@
|
|||
<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">
|
||||
<%= t('repository_row.modal_print_label.head_title', repository_row: @repository_row.name) %>
|
||||
<span class="id-label">
|
||||
<%= t('repository_row.modal_print_label.id_label', repository_row_id: @repository_row.id) %>
|
||||
</span>
|
||||
<% 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>
|
||||
|
|
|
@ -107,7 +107,7 @@
|
|||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal"><%= t('general.close')%></button>
|
||||
<button type="button" class="btn btn-primary print-label-button" data-dismiss="modal" data-url="<%= print_modal_repository_repository_row_path(@repository_row.repository, @repository_row) %>"><%= t('repository_row.modal_print_label.print_label') %></button>
|
||||
<button type="button" class="btn btn-primary print-label-button" data-dismiss="modal" data-url="<%= print_modal_repository_repository_rows_path(@repository_row.repository) %>" data-rows="[<%= @repository_row.id %>]"><%= t('repository_row.modal_print_label.print_label') %></button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -64,6 +64,11 @@
|
|||
<p class="view-only-label"><%= t('repositories.index.view_only_permission_label') %></p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<button type="button" id="toolbarPrintLabel" class="btn btn-light print-label-button" data-dismiss="modal" data-url="<%= print_modal_repository_repository_rows_path(@repository) %>" data-rows="[]" style="display: none">
|
||||
<span class="fas fa-print"></span>
|
||||
<%= t('repository_row.modal_print_label.print_label') %>
|
||||
|
||||
</button>
|
||||
<div class="archived-label" data-view-mode="archived">
|
||||
<% if @repository.active? %>
|
||||
<%= t('repositories.show.archived_view_label.active', repository_name: @repository.name) %>
|
||||
|
|
|
@ -1609,6 +1609,7 @@ en:
|
|||
no_tasks: "This item in not assigned to any task."
|
||||
modal_print_label:
|
||||
head_title: "Print label - %{repository_row}"
|
||||
head_title_multiple: "Print label - %{repository_rows} rows"
|
||||
id_label: "ID: %{repository_row_id}"
|
||||
printer: "Printer"
|
||||
number_of_copies: "Number of copies"
|
||||
|
|
|
@ -560,8 +560,10 @@ Rails.application.routes.draw do
|
|||
|
||||
resources :repository_columns, only: %i(index new edit destroy)
|
||||
resources :repository_rows, only: %i(create show update) do
|
||||
member do
|
||||
collection do
|
||||
get :print_modal
|
||||
end
|
||||
member do
|
||||
get :assigned_task_list
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue