fix(bt-import): swap show_progress for freeze to avoid stuck backdrop
Importing Bank Transactions via "Import From → Load from Excel" left
the screen darkened and unresponsive after the job finished. Root cause
was the show_progress Bootstrap modal: closing it from JS (we had a
hand-rolled _closeProgress that called .modal('hide').remove() and then
removed .modal-backdrop manually) interrupted Bootstrap's hide animation
mid-flight, leaving the dimmed overlay stuck. Opening a msgprint right
after made it worse — the two modals fought over the same backdrop
node.
Switched to frappe.dom.freeze / unfreeze: a single full-page overlay
managed by Frappe core, with no Bootstrap modal/backdrop juggling. The
freeze message is updated in place as progress events arrive (writes
to #freeze .freeze-message directly to avoid stacking the freeze
counter, which would break unfreeze pairing). unfreeze on completion
cleans up reliably, so the msgprint that opens immediately after lands
on a clean page.
Removed the now-unused _closeProgress helper.
This commit is contained in:
parent
a7686eadc6
commit
89bb5dd1f0
|
|
@ -221,18 +221,22 @@ const BIExcelImport = {
|
||||||
|
|
||||||
_runImport(selected, values, listview) {
|
_runImport(selected, values, listview) {
|
||||||
const total = selected.length;
|
const total = selected.length;
|
||||||
frappe.show_progress(__('Importing'), 0, total, __('Starting import...'));
|
// Freeze the page instead of using show_progress. show_progress relies
|
||||||
|
// on a Bootstrap modal whose backdrop reliably gets stuck when we then
|
||||||
|
// open a msgprint on completion; freeze is a simple full-page overlay
|
||||||
|
// that unfreeze() always cleans up.
|
||||||
|
frappe.dom.freeze(__('Starting import…'));
|
||||||
|
|
||||||
frappe.realtime.off('bi_bt_import_progress');
|
frappe.realtime.off('bi_bt_import_progress');
|
||||||
frappe.realtime.on('bi_bt_import_progress', function (d) {
|
frappe.realtime.on('bi_bt_import_progress', function (d) {
|
||||||
frappe.show_progress(__('Importing'), d.current, d.total, __('{0} of {1}', [d.current, d.total]));
|
BIExcelImport._setFreezeMessage(__('Importing {0} of {1}…', [d.current, d.total]));
|
||||||
});
|
});
|
||||||
|
|
||||||
frappe.realtime.off('bi_bt_import_complete');
|
frappe.realtime.off('bi_bt_import_complete');
|
||||||
frappe.realtime.on('bi_bt_import_complete', function (d) {
|
frappe.realtime.on('bi_bt_import_complete', function (d) {
|
||||||
frappe.realtime.off('bi_bt_import_progress');
|
frappe.realtime.off('bi_bt_import_progress');
|
||||||
frappe.realtime.off('bi_bt_import_complete');
|
frappe.realtime.off('bi_bt_import_complete');
|
||||||
BIExcelImport._closeProgress();
|
frappe.dom.unfreeze();
|
||||||
|
|
||||||
const ok = d.imported || 0;
|
const ok = d.imported || 0;
|
||||||
const errCount = (d.errors || []).length;
|
const errCount = (d.errors || []).length;
|
||||||
|
|
@ -273,7 +277,7 @@ const BIExcelImport = {
|
||||||
error() {
|
error() {
|
||||||
frappe.realtime.off('bi_bt_import_progress');
|
frappe.realtime.off('bi_bt_import_progress');
|
||||||
frappe.realtime.off('bi_bt_import_complete');
|
frappe.realtime.off('bi_bt_import_complete');
|
||||||
BIExcelImport._closeProgress();
|
frappe.dom.unfreeze();
|
||||||
frappe.msgprint({
|
frappe.msgprint({
|
||||||
title: __('Error'), indicator: 'red',
|
title: __('Error'), indicator: 'red',
|
||||||
message: __('Network error starting import'),
|
message: __('Network error starting import'),
|
||||||
|
|
@ -282,6 +286,15 @@ const BIExcelImport = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Replace the message on the active freeze overlay without re-freezing
|
||||||
|
// (re-freezing stacks counter and breaks unfreeze pairing).
|
||||||
|
_setFreezeMessage(msg) {
|
||||||
|
const $msg = $('#freeze .freeze-message');
|
||||||
|
if ($msg.length) {
|
||||||
|
$msg.text(msg);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
_showDateParseHelp(droppedCount, bankIntegrationName) {
|
_showDateParseHelp(droppedCount, bankIntegrationName) {
|
||||||
const openForm = function () {
|
const openForm = function () {
|
||||||
frappe.set_route('Form', 'Bank Statement Importer', bankIntegrationName);
|
frappe.set_route('Form', 'Bank Statement Importer', bankIntegrationName);
|
||||||
|
|
@ -352,20 +365,6 @@ const BIExcelImport = {
|
||||||
d.show();
|
d.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
_closeProgress() {
|
|
||||||
try {
|
|
||||||
if (frappe.cur_progress) {
|
|
||||||
frappe.cur_progress.$wrapper.modal('hide');
|
|
||||||
frappe.cur_progress.$wrapper.remove();
|
|
||||||
frappe.cur_progress = null;
|
|
||||||
}
|
|
||||||
} catch (e) { /* ignore */ }
|
|
||||||
if ($('.modal:visible').length === 0) {
|
|
||||||
$('.modal-backdrop').remove();
|
|
||||||
$('body').removeClass('modal-open');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
_showErrorDetails() {
|
_showErrorDetails() {
|
||||||
const errs = BIExcelImport._lastErrors || [];
|
const errs = BIExcelImport._lastErrors || [];
|
||||||
if (!errs.length) {
|
if (!errs.length) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue