From e645e9b00625680af30db024d4f2ef652179407c Mon Sep 17 00:00:00 2001 From: Benjamin Dalsass Date: Mon, 17 Apr 2023 07:53:34 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B04148=20-=20LinkedSet=201:n=20in=20place?= =?UTF-8?q?=20edition,=20created=20then=20removed=20object=20are=20still?= =?UTF-8?q?=20created?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/links/links_direct_widget.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/js/links/links_direct_widget.js b/js/links/links_direct_widget.js index a343bdca8..1f53344b0 100644 --- a/js/links/links_direct_widget.js +++ b/js/links/links_direct_widget.js @@ -464,7 +464,7 @@ $(function() for (k in this.toBeCreated) { nextIdx++; } - nextIdx++; + oValues['id'] = -nextIdx; // we stored temp id to allow removal with _CreatedArrayRemove function this.toBeCreated[nextIdx] = oValues; this.inputToBeCreated.val(JSON.stringify(this.toBeCreated)); this.oDlg.dialog('close'); @@ -524,7 +524,7 @@ $(function() else { // Object to be created, just remove it from the "to be created" list - this.toBeCreated = this._ArrayRemove(this.toBeCreated, iObjKey); + this.toBeCreated = this._CreatedArrayRemove(iObjKey); this.inputToBeCreated.val(JSON.stringify(this.toBeCreated)); } // Now remove the row from the table @@ -542,7 +542,7 @@ $(function() _removeRow: function(oCheckbox) { var iObjKey = parseInt(oCheckbox.val(), 10); // Number in base 10 - + if (iObjKey > 0) { // Existing objet: add it to the "to be removed" list @@ -561,7 +561,7 @@ $(function() else { // Object to be created, just remove it from the "to be created" list - this.toBeCreated = this._ArrayRemove(this.toBeCreated, iObjKey); + this.toBeCreated = this._CreatedArrayRemove(iObjKey); this.inputToBeCreated.val(JSON.stringify(this.toBeCreated)); } // Now remove the row from the table @@ -594,6 +594,18 @@ $(function() } return aRes; }, + _CreatedArrayRemove: function(needle) + { + aRes = []; + for(k in this.toBeCreated) + { + if (this.toBeCreated[k].id != needle) + { + aRes.push(this.toBeCreated[k]); + } + } + return aRes; + }, Remove: function(oCheckbox) // for public access { this._removeRow(oCheckbox);