Improve refreshRow to handle overlapping AJAX responses
Playwright Tests / test (push) Canceled after 0s
Playwright Tests / test (push) Canceled after 0s
Refactored refreshRow in fis.usr.de.js to look up the row node by id inside the AJAX response handler, ensuring correct replacement even with overlapping calls (e.g., rapid checkbox toggles). This prevents errors when a previous call detaches the node before a later response arrives. Enhanced fallback to full reload for robustness. Updated fis.usr.de.min.js accordingly. Reformatted tools.js with no content changes.
This commit is contained in:
@@ -95,14 +95,18 @@ let $usr = {
|
||||
},
|
||||
/* Re-fetches a single user and swaps its grid row in place, keeping selection + ribbon
|
||||
(used after changes that only affect that one row: email, group membership). Falls back
|
||||
to a full reload when the row is no longer in the grid. */
|
||||
to a full reload when the row is no longer in the grid. Looks up the current row node by
|
||||
id inside the response handler (not before the request) so two overlapping calls — e.g.
|
||||
two quick checkbox toggles in groupsDlg — each replace whatever row is live at the time
|
||||
their own response arrives, instead of the second call operating on a node the first
|
||||
already detached via replaceWith. */
|
||||
refreshRow: function (rw) {
|
||||
let old = $('#usr' + rw.useraccount_id);
|
||||
if (old.length === 0) { $usr.renderLst(); return; }
|
||||
if ($('#usr' + rw.useraccount_id).length === 0) { $usr.renderLst(); return; }
|
||||
$ocms.postXT({
|
||||
url: $ocms.url('usr/list'), data: { useraccount_id: rw.useraccount_id }, success: function (r) {
|
||||
let fresh = (r.users || [])[0];
|
||||
if (!fresh) { $usr.renderLst(); return; }
|
||||
let old = $('#usr' + rw.useraccount_id);
|
||||
if (!fresh || old.length === 0) { $usr.renderLst(); return; }
|
||||
let selected = old.is('.selected');
|
||||
let row = $usr.buildRow(fresh).toggleClass('selected', selected);
|
||||
old.replaceWith(row);
|
||||
|
||||
Reference in New Issue
Block a user