BUGFIX: Removed use of deprecated TableListField_Item::BaseLink() And TableListField::ajax_refresh() from CommentTableField and MemberTableField

BUGFIX: Fixed styling, searching, and pagination of CommentTableField

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@61686 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-08-28 04:26:59 +00:00
parent 9222af6829
commit b4e681dc83
4 changed files with 53 additions and 46 deletions

View File

@ -172,15 +172,15 @@ class CommentTableField_Item extends ComplexTableField_Item {
}
function SpamLink() {
return $this->BaseLink() . "&methodName=spam";
return Controller::join_links($this->Link(), "?methodName=spam");
}
function HamLink() {
return $this->BaseLink() . "&methodName=ham";
return Controller::join_links($this->Link(), "?methodName=ham");
}
function ApproveLink() {
return $this->BaseLink() . "&methodName=approve";
return Controller::join_links($this->Link(), "?methodName=approve");
}
}

View File

@ -14,13 +14,10 @@ CommentTableField.prototype = {
rules['#'+this.id+' table.data a.hamlink'] = {
onclick: this.removeRowAfterAjax.bind(this)
};
rules['#Form_EditForm div.CommentFilter input'] = {
onkeypress : this.prepareSearch.bind(this)
};
rules['#Form_EditForm'] = {
changeDetection_fieldsToIgnore : {
'ctf[start]' : true,
@ -76,7 +73,7 @@ CommentTableField.prototype = {
CommentTableField.applyTo('div.CommentTableField');
CommentFilterButton = Class.create();
CommentFilterButton.applyTo('#Form_EditForm #CommentFilterButton');
CommentFilterButton.applyTo('#CommentFilterButton');
CommentFilterButton.prototype = {
initialize: function() {
this.inputFields = new Array();
@ -107,28 +104,30 @@ CommentFilterButton.prototype = {
},
onclick: function(e) {
//if(!$('ctf-ID') || !$('CommentFieldName')) {
// return false;
//}
var updateURL = "";
updateURL += Event.findElement(e,"form").action;
// we can't set "fieldName" as a HiddenField because there might be multiple ComplexTableFields in a single EditForm-container
updateURL += "&fieldName="+$('CommentFieldName').value;
updateURL += "&action_callfieldmethod&&methodName=ajax_refresh&";
for( var index = 0; index < this.inputFields.length; index++ ) {
if( this.inputFields[index].tagName ) {
updateURL += this.inputFields[index].name + '=' + encodeURIComponent( this.inputFields[index].value ) + '&';
}
}
updateURL += 'ajax=1' + ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : '');
try {
var form = Event.findElement(e,"form");
var fieldName = $('CommentFieldName').value;
var fieldID = form.id + '_' + fieldName;
var updateURL = form.action + '/field/' + fieldName + '?ajax=1';
for( var index = 0; index < this.inputFields.length; index++ ) {
if( this.inputFields[index].tagName ) {
updateURL += '&' + this.inputFields[index].name + '=' + encodeURIComponent( this.inputFields[index].value );
}
}
updateURL += ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : '');
new Ajax.Request( updateURL, {
onSuccess: Ajax.Evaluator,
onFailure: function( response ) {
errorMessage('Could not filter results: ' + response.responseText );
}.bind(this)
});
new Ajax.Updater( fieldID, updateURL, {
onSuccess: function() {
Behaviour.apply(fieldID, true);
},
onFailure: function( response ) {
errorMessage('Could not filter results: ' + response.responseText );
}.bind(this)
});
} catch(er) {
errorMessage('Error searching');
}
return false;
}

View File

@ -243,24 +243,32 @@ MemberFilterButton.prototype = {
if(!$('ctf-ID') || !$('MemberFieldName')) {
return false;
}
var updateURL = "";
updateURL += Event.findElement(e,"form").action;
updateURL += '/field/' + $('MemberFieldName').value + '/ajax_refresh?ajax=1&';
for( var index = 0; index < this.inputFields.length; index++ ) {
if( this.inputFields[index].tagName ) {
updateURL += this.inputFields[index].name + '=' + encodeURIComponent( this.inputFields[index].value ) + '&';
}
}
updateURL += 'ajax=1' + ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : '');
new Ajax.Request( updateURL, {
onSuccess: Ajax.Evaluator,
onFailure: function( response ) {
errorMessage('Could not filter results: ' + response.responseText );
}.bind(this)
});
try {
var form = Event.findElement(e,"form");
var fieldName = $('MemberFieldName').value;
var fieldID = form.id + '_' + fieldName;
var updateURL = form.action + '/field/' + fieldName + '?ajax=1';
for( var index = 0; index < this.inputFields.length; index++ ) {
if( this.inputFields[index].tagName ) {
updateURL += '&' + this.inputFields[index].name + '=' + encodeURIComponent( this.inputFields[index].value );
}
}
updateURL += ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : '');
new Ajax.Updater( fieldID, updateURL, {
onSuccess: function() {
Behaviour.apply(fieldID, true);
},
onFailure: function( response ) {
errorMessage('Could not filter results: ' + response.responseText );
}.bind(this)
});
} catch(er) {
errorMessage('Error searching');
}
return false;
}
}

View File

@ -1,4 +1,4 @@
<div id="$id" class="$Classes">
<div id="$id" class="$CSSClasses">
<div class="CommentFilter">
$SearchForm
</div>