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
This commit is contained in:
Ingo Schommer 2009-07-16 23:58:01 +00:00
parent 1f19dcdfad
commit cc11d6e2d4
2 changed files with 9 additions and 2 deletions

View File

@ -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){

View File

@ -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);