fix(e-taxes-settings): stop page freeze after reference data loading
The data loading dialog was opened via frappe.msgprint, which reuses the shared frappe.msg_dialog. We then rewrote .modal-body via $.html(...) on each progress tick, destroying the DOM that frappe.show_progress also relies on. After hide(), Bootstrap left a modal-backdrop behind and the whole page became unclickable until reload. Switch to the dedicated show_loading_dialog_settings / update_loading_message_settings / hide_loading_dialog_settings dialog that already exists in this file, so msg_dialog is never touched. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
08e31c6815
commit
69f2acec86
|
|
@ -2186,17 +2186,17 @@ function start_staged_invoice_loading(frm, values) {
|
||||||
};
|
};
|
||||||
|
|
||||||
window.cancelReferenceLoading = false;
|
window.cancelReferenceLoading = false;
|
||||||
|
|
||||||
// ВОЗВРАЩАЕМ: Модальное окно в центре экрана
|
// Используем выделенный диалог вместо frappe.msgprint, чтобы не модифицировать
|
||||||
const loading_dialog = frappe.msgprint({
|
// shared frappe.msg_dialog (который также используется frappe.show_progress).
|
||||||
title: __('Loading Data'),
|
// Прямая правка .modal-body у msg_dialog приводила к "залипшему" backdrop
|
||||||
message: __('Fetching invoices from E-Taxes, please wait...'),
|
// после завершения загрузки и блокировала всю страницу.
|
||||||
indicator: 'blue'
|
show_loading_dialog_settings(
|
||||||
});
|
__('Loading Data'),
|
||||||
|
__('Fetching invoices from E-Taxes, please wait...'),
|
||||||
// Сохраняем ссылку на диалог в состоянии
|
''
|
||||||
loading_state.loading_dialog = loading_dialog;
|
);
|
||||||
|
|
||||||
// Начинаем загрузку inbox
|
// Начинаем загрузку inbox
|
||||||
load_invoice_batch(loading_state, 'inbox', frm);
|
load_invoice_batch(loading_state, 'inbox', frm);
|
||||||
}
|
}
|
||||||
|
|
@ -2204,10 +2204,7 @@ function start_staged_invoice_loading(frm, values) {
|
||||||
// НОВАЯ ФУНКЦИЯ: Загрузка одной порции инвойсов
|
// НОВАЯ ФУНКЦИЯ: Загрузка одной порции инвойсов
|
||||||
function load_invoice_batch(loading_state, source, frm) {
|
function load_invoice_batch(loading_state, source, frm) {
|
||||||
if (window.cancelReferenceLoading) {
|
if (window.cancelReferenceLoading) {
|
||||||
// Закрываем диалог при отмене
|
hide_loading_dialog_settings();
|
||||||
if (loading_state.loading_dialog && loading_state.loading_dialog.hide) {
|
|
||||||
loading_state.loading_dialog.hide();
|
|
||||||
}
|
|
||||||
frappe.show_alert({
|
frappe.show_alert({
|
||||||
message: __('Loading cancelled'),
|
message: __('Loading cancelled'),
|
||||||
indicator: 'red'
|
indicator: 'red'
|
||||||
|
|
@ -2229,10 +2226,7 @@ function load_invoice_batch(loading_state, source, frm) {
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
if (!r.message || !r.message.success) {
|
if (!r.message || !r.message.success) {
|
||||||
if (source === 'inbox') {
|
if (source === 'inbox') {
|
||||||
// Если inbox не удался - закрываем диалог и показываем ошибку
|
hide_loading_dialog_settings();
|
||||||
if (loading_state.loading_dialog && loading_state.loading_dialog.hide) {
|
|
||||||
loading_state.loading_dialog.hide();
|
|
||||||
}
|
|
||||||
frappe.msgprint(__('Failed to load invoices: ') + (r.message?.message || 'Unknown error'));
|
frappe.msgprint(__('Failed to load invoices: ') + (r.message?.message || 'Unknown error'));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -2267,22 +2261,12 @@ function load_invoice_batch(loading_state, source, frm) {
|
||||||
(source === 'outbox' && loading_state.last_update_count === 0) // Первое сообщение для outbox
|
(source === 'outbox' && loading_state.last_update_count === 0) // Первое сообщение для outbox
|
||||||
);
|
);
|
||||||
|
|
||||||
if (should_update && loading_state.loading_dialog && loading_state.loading_dialog.$wrapper) {
|
if (should_update) {
|
||||||
const progress_text = source === 'inbox' ?
|
const progress_text = source === 'inbox' ?
|
||||||
__('Finding purchase invoices: {0} found...', [loading_state.total_loaded]) :
|
__('Finding purchase invoices: {0} found...', [loading_state.total_loaded]) :
|
||||||
__('Finding sales invoices: {0} total found...', [loading_state.total_loaded]);
|
__('Finding sales invoices: {0} total found...', [loading_state.total_loaded]);
|
||||||
|
|
||||||
// Пробуем обновить текст в модальном окне
|
update_loading_message_settings(progress_text, '');
|
||||||
try {
|
|
||||||
const $wrapper = loading_state.loading_dialog.$wrapper;
|
|
||||||
const $modal_body = $wrapper.find('.modal-body');
|
|
||||||
if ($modal_body.length > 0) {
|
|
||||||
$modal_body.html(`<p>${progress_text}</p>`);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log('Could not update modal text:', e);
|
|
||||||
}
|
|
||||||
|
|
||||||
loading_state.last_update_count = loading_state.total_loaded;
|
loading_state.last_update_count = loading_state.total_loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2306,10 +2290,7 @@ function load_invoice_batch(loading_state, source, frm) {
|
||||||
},
|
},
|
||||||
error: function(r) {
|
error: function(r) {
|
||||||
if (source === 'inbox') {
|
if (source === 'inbox') {
|
||||||
// Закрываем диалог при ошибке
|
hide_loading_dialog_settings();
|
||||||
if (loading_state.loading_dialog && loading_state.loading_dialog.hide) {
|
|
||||||
loading_state.loading_dialog.hide();
|
|
||||||
}
|
|
||||||
frappe.msgprint(__('Error loading invoices: ') + (r.message || 'Network error'));
|
frappe.msgprint(__('Error loading invoices: ') + (r.message || 'Network error'));
|
||||||
} else {
|
} else {
|
||||||
// Ошибка outbox - продолжаем без него
|
// Ошибка outbox - продолжаем без него
|
||||||
|
|
@ -2324,11 +2305,8 @@ function load_invoice_batch(loading_state, source, frm) {
|
||||||
// НОВАЯ ФУНКЦИЯ: Проверка завершения загрузки
|
// НОВАЯ ФУНКЦИЯ: Проверка завершения загрузки
|
||||||
function check_loading_completion(loading_state, frm) {
|
function check_loading_completion(loading_state, frm) {
|
||||||
if (loading_state.inbox_completed && loading_state.outbox_completed) {
|
if (loading_state.inbox_completed && loading_state.outbox_completed) {
|
||||||
// ИСПРАВЛЕНО: Закрываем диалог загрузки
|
hide_loading_dialog_settings();
|
||||||
if (loading_state.loading_dialog && loading_state.loading_dialog.hide) {
|
|
||||||
loading_state.loading_dialog.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (loading_state.all_invoices.length === 0) {
|
if (loading_state.all_invoices.length === 0) {
|
||||||
frappe.msgprint(__('No invoices found for the selected period.'));
|
frappe.msgprint(__('No invoices found for the selected period.'));
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue