From ac11d41359cd69aed1692281246022d81453f7a6 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Wed, 28 Sep 2022 17:01:07 +0200 Subject: [PATCH] Fix label printing status modal [SCI-7271] --- .../sitewide/print_progress_modal.js | 21 ++++++++++++------- .../vue/repository_print_modal/container.vue | 4 +++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/sitewide/print_progress_modal.js b/app/assets/javascripts/sitewide/print_progress_modal.js index 68e972d94..0b134ba39 100644 --- a/app/assets/javascripts/sitewide/print_progress_modal.js +++ b/app/assets/javascripts/sitewide/print_progress_modal.js @@ -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 }); }()); diff --git a/app/javascript/vue/repository_print_modal/container.vue b/app/javascript/vue/repository_print_modal/container.vue index bdc2a057e..c80d41a62 100644 --- a/app/javascript/vue/repository_print_modal/container.vue +++ b/app/javascript/vue/repository_print_modal/container.vue @@ -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); }) } },