From c7e8c70ced6c63da158a6e65d3ecdd8ee1f9320e Mon Sep 17 00:00:00 2001 From: Benjamin Dalsass Date: Thu, 4 May 2023 10:34:37 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B06124=20-=20Workaround=20performance=20pr?= =?UTF-8?q?oblem=20on=20the=20modification=20of=20an=20object=20with=20an?= =?UTF-8?q?=20n:n=20relation=20having=20a=20large=20volume?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/links/links_widget.js | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/js/links/links_widget.js b/js/links/links_widget.js index d14be2f78..eb70fe1d3 100644 --- a/js/links/links_widget.js +++ b/js/links/links_widget.js @@ -67,7 +67,7 @@ function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix, bDuplicates, oWizH this.RemoveSelected = function () { let my_id = '#'+me.id; $('#linkedset_'+me.id+' .selection:checked').closest('tr').each(function () { - me.Remove($(this)); + me.Remove($(this), false); }); // N°6124 Only draw table once for performance reasons $('#datatable_'+me.id).DataTable().draw(); @@ -84,25 +84,30 @@ function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix, bDuplicates, oWizH this.UpdateButtons(); }; - this.Remove = function(oRowElement){ + this.Remove = function(oRowElement, bForceTableRefresh = true){ $('#datatable_'+me.id).DataTable().row($(oRowElement)).remove(); var oCheckbox = $(oRowElement).find('.selection'); - let iLink = $(oCheckbox).attr('data-link-id'); - if (iLink > 0) { - me.aRemoved.push(iLink); - if (me.aModified.hasOwnProperty(iLink)) { - delete me.aModified[iLink]; - } + let iLink = $(oCheckbox).attr('data-link-id'); + if (iLink > 0) { + me.aRemoved.push(iLink); + if (me.aModified.hasOwnProperty(iLink)) { + delete me.aModified[iLink]; } - else + } + else + { + let iUniqueId = $(oCheckbox).attr('data-unique-id'); + if (iUniqueId < 0) { - let iUniqueId = $(oCheckbox).attr('data-unique-id'); - if (iUniqueId < 0) - { - iUniqueId = -iUniqueId; - } - me.aAdded[iUniqueId] = null; + iUniqueId = -iUniqueId; } + me.aAdded[iUniqueId] = null; + } + + // N°6124 Only draw table once for performance reasons + if(bForceTableRefresh){ + $('#datatable_'+me.id).DataTable().draw(); + } this.UpdateButtons(); }