Fix label printing status modal [SCI-7271]

This commit is contained in:
Oleksii Kriuchykhin 2022-09-28 17:01:07 +02:00
parent 31554d0fd9
commit ac11d41359
2 changed files with 16 additions and 9 deletions

View file

@ -1,9 +1,15 @@
(function() {
var PrintProgressModal = (function() {
'use strict';
function updateProgressModal() {
var modal = $('.label-printing-progress-modal');
if (modal.length === 0) return;
$(document).on('click', '.label-printing-progress-modal .close', function() {
$(this).closest('.label-printing-progress-modal').remove();
});
$.getJSON(
modal.data('progress-url'), function(data) {
modal.replaceWith(data.html);
@ -15,11 +21,7 @@
);
}
$(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) {
function initialize(data) {
var modal = $('.label-printing-progress-modal');
if (modal.length) {
modal.replaceWith(data.html);
@ -27,7 +29,10 @@
$('body').append($(data.html));
}
updateProgressModal();
$('#modal-print-repository-row-label').modal('hide');
setTimeout(updateProgressModal, 3000);
}
return Object.freeze({
init: initialize
});
}());

View file

@ -199,8 +199,10 @@
label_printer_id: this.selectedPrinter.id,
label_template_id: this.selectedTemplate.id,
copies: this.copies
}, () => {
}, (data) => {
$(this.$refs.modal).modal('hide');
this.$emit('close');
PrintProgressModal.init(data);
})
}
},