From cc11d6e2d4c8c1f154367bf19a444514bdcc6a16 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 16 Jul 2009 23:58:01 +0000 Subject: [PATCH] BUGFIX: TableField? delete link should not trigger a ajax request if the record row is not a real record. (merged from branches/2.3-nzct) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@82066 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- javascript/TableField.js | 5 +++-- javascript/TableListField.js | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/javascript/TableField.js b/javascript/TableField.js index c41c620f3..9040a955e 100755 --- a/javascript/TableField.js +++ b/javascript/TableField.js @@ -51,12 +51,13 @@ TableField.prototype = { var row = Event.findElement(e,"tr"); var params = link.getAttribute("href").toQueryParams(); var isEmpty = true; + var recordID = row.getRecordId(); // Check to see if there is a dataobject to delete first, otherwise remove the row. // or: Check if a childID is set (not present on new items) if( (this.hasNoValues(row,"input") && this.hasNoValues(row,"select") && this.hasNoValues(row,"textarea")) - || params["childID"] <= 0 + || params["childID"] <= 0 || (recordID <= 0 || recordID == false) ){ if( row.parentNode.getElementsByTagName('tr').length > 1 ) { try { Effect.FadeOut(row); } catch (e) { @@ -73,7 +74,7 @@ TableField.prototype = { Event.stop(e); return false; } - + return false; // TODO ajaxErrorHandler and loading-image are dependent on cms, but formfield is in sapphire var confirmed = confirm(ss.i18n._t('TABLEFIELD.DELETECONFIRMMESSAGE', 'Are you sure you want to delete this record?')); if(confirmed){ diff --git a/javascript/TableListField.js b/javascript/TableListField.js index 576c29581..24fdfff1e 100755 --- a/javascript/TableListField.js +++ b/javascript/TableListField.js @@ -290,6 +290,12 @@ TableListRecord.prototype = { }); }, + getRecordId: function(){ + parts = this.id.match( /.*[\-]{1}(\d+)$/ ); + if(parts) return parts[1]; + else return false; + }, + select_success : function(response) { Element.removeClassName(this, 'loading'); this.subform.loadNewPage(response.responseText);