mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-11 01:44:34 +08:00
Merge pull request #3531 from aignatov-bio/ai-sci-6034-change-printing-status-modal-logic
Change printing status modal logic [SCI-6034]
This commit is contained in:
commit
41e41f790b
5 changed files with 41 additions and 36 deletions
|
@ -1,32 +1,33 @@
|
|||
function updateProgressModal() {
|
||||
var status;
|
||||
var modal = $(document).find('.label-printing-progress-modal');
|
||||
(function() {
|
||||
function updateProgressModal() {
|
||||
var modal = $('.label-printing-progress-modal');
|
||||
|
||||
if (modal.length === 0) {
|
||||
return;
|
||||
}
|
||||
if (modal.length === 0) return;
|
||||
|
||||
$.getJSON(
|
||||
`/label_printers/${modal.data('labelPrinterId')}/update_progress_modal`
|
||||
+ `?starting_item_count=${modal.data('startingItemCount')}`,
|
||||
function(data) {
|
||||
modal.replaceWith(data.html);
|
||||
|
||||
status = modal.data('label-printer-status');
|
||||
if (status !== 'done' && status !== 'error') {
|
||||
setTimeout(updateProgressModal, 3000);
|
||||
$.getJSON(
|
||||
modal.data('progress-url'), function(data) {
|
||||
modal.replaceWith(data.html);
|
||||
let status = modal.data('label-printer-status');
|
||||
if (!['done', 'error'].includes(status)) {
|
||||
setTimeout(updateProgressModal, 3000);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$(document).on('click', '.label-printing-progress-modal .close', function() {
|
||||
$(this).closest('.label-printing-progress-modal').remove();
|
||||
});
|
||||
|
||||
$(document).on('turbolinks:load', function() {
|
||||
var modal = $(document).find('.label-printing-progress-modal');
|
||||
if (modal.length > 0) {
|
||||
updateProgressModal();
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.label-printing-progress-modal .close', function() {
|
||||
$(this).closest('.label-printing-progress-modal').remove();
|
||||
});
|
||||
|
||||
$(document).on('ajax:success', '.print-label-form', function(e, data) {
|
||||
var modal = $('.label-printing-progress-modal');
|
||||
if (modal.length) {
|
||||
modal.replaceWith(data.html);
|
||||
} else {
|
||||
$('body').append($(data.html));
|
||||
}
|
||||
|
||||
updateProgressModal();
|
||||
$('#modal-print-repository-row-label').modal('hide');
|
||||
});
|
||||
}());
|
||||
|
|
|
@ -109,7 +109,13 @@ class RepositoryRowsController < ApplicationController
|
|||
|
||||
label_printer.update!(current_print_job_ids: job_ids * params[:copies].to_i)
|
||||
|
||||
redirect_to repository_path(@repository)
|
||||
render json: {
|
||||
html: render_to_string(
|
||||
partial: 'label_printers/print_progress_modal.html.erb',
|
||||
locals: { starting_item_count: label_printer.current_print_job_ids.length,
|
||||
label_printer: label_printer }
|
||||
)
|
||||
}
|
||||
end
|
||||
|
||||
def update
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<div class="label-printing-progress-modal" data-label-printer-status="<%= label_printer.printing_status %>" data-label-printer-id="<%= label_printer.id %>" data-starting-item-count="<%= starting_item_count %>">
|
||||
<div class="label-printing-progress-modal"
|
||||
data-label-printer-status="<%= label_printer.printing_status %>" data-label-printer-id="<%= label_printer.id %>"
|
||||
data-starting-item-count="<%= starting_item_count %>"
|
||||
data-progress-url="<%= update_progress_modal_label_printer_path(label_printer, starting_item_count: starting_item_count) %>">
|
||||
<div class="modal-header">
|
||||
<div class="title">
|
||||
<%= label_printer.name %>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<% if @printers.size > 0 %>
|
||||
<%= form_tag print_repository_repository_rows_path do %>
|
||||
<%= form_tag print_repository_repository_rows_path, { class: 'print-label-form', data: { remote: true } } do %>
|
||||
<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">
|
||||
|
|
|
@ -159,11 +159,6 @@
|
|||
<%= render partial: 'repositories/import_repository_records_modal',
|
||||
locals: { repository: @repository } %>
|
||||
|
||||
<% if @busy_printer %>
|
||||
<%= render(
|
||||
partial: 'label_printers/print_progress_modal',
|
||||
locals: { starting_item_count: @busy_printer.current_print_job_ids.length, label_printer: @busy_printer }) %>
|
||||
<% end %>
|
||||
|
||||
<%= render partial: "repositories/delete_record_modal" %>
|
||||
<%= render partial: 'repositories/export_repository_modal',
|
||||
|
|
Loading…
Reference in a new issue