(merged from branches/roa. use "svn log -c <changeset> -g <module-svn-path>" for detailed commit message)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@60231 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-08-09 06:29:50 +00:00
parent 649ff87aec
commit 3fe17e9649
3 changed files with 42 additions and 25 deletions

View File

@ -355,26 +355,31 @@ class ModelAdmin_CollectionController extends Controller {
$searchKeys = array_intersect_key($request->getVars(), $model->searchable_fields());
$context = $model->getDefaultSearchContext();
$results = $context->getResults($searchKeys, null, array('start'=>0, 'limit'=>$this->parentController->stat('page_length')));
$output = "<h2>" . _t('ModelAdmin.SEARCHRESULTS','Search Results') . "</h2>\n";
$summaryFields = $model->summaryFields();
if ($results) {
$output .= "<table class=\"results\">";
foreach($results as $row) {
$uri = Director::absoluteBaseUrl();
$output .= "<tr title=\"{$uri}admin/crm/{$this->modelClass}/{$row->ID}/edit\">";
foreach($model->searchable_fields() as $key=>$val) {
$output .= "<td>";
$output .= $row->$key;
$output .= "</td>";
}
$output .= "</tr>";
}
$output .= "</table>";
} else {
$output .= "<p>No results found</p>";
}
return $output;
$tf = new TableListField(
$this->modelClass,
$this->modelClass,
$summaryFields
);
$tf->setCustomSourceItems($results);
$tf->setPermissions(array('view'));
$url = '<a href=\"' . Director::absoluteBaseURL() . 'admin/crm/' . $this->modelClass . '/$ID/edit\">$value</a>';
$tf->setFieldFormatting(array_combine(array_keys($summaryFields), array_fill(0,count($summaryFields), $url)));
// implemented as a form to enable further actions on the resultset
// (serverside sorting, export as CSV, etc)
$form = new Form(
$this,
'ResultsForm',
new FieldSet(
new HeaderField(_t('ModelAdmin.SEARCHRESULTS','Search Results'), 2),
$tf
),
new FieldSet()
);
return $form->forTemplate();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -464,7 +469,7 @@ class ModelAdmin_RecordController extends Controller {
$validator = ($this->currentRecord->hasMethod('getCMSValidator')) ? $this->currentRecord->getCMSValidator() : null;
$actions = new FieldSet(
new FormAction("goBack", "Back"),
//new FormAction("goBack", "Back"),
new FormAction("doSave", "Save")
);

View File

@ -99,11 +99,12 @@ jQuery(document).ready(function() {
data = formData(form);
jQuery.get(form.attr('action'), data, function(result){
jQuery('#right #ModelAdminPanel').html(result);
jQuery('#right #ModelAdminPanel td').click(function(){
td = jQuery(this);
showRecord(td.parent().attr('title'));
td.parent().parent().find('td').removeClass('active');
td.addClass('active').siblings().addClass('active');
jQuery('#right #ModelAdminPanel tbody td a').click(function(){
var el = jQuery(this);
showRecord(el.attr('href'));
//el.parent().parent().find('td').removeClass('active');
//el.addClass('active').siblings().addClass('active');
return false;
}).hover(function(){
jQuery(this).addClass('over').siblings().addClass('over')
}, function(){
@ -123,4 +124,10 @@ function fixHeight_left() {
fitToParent('LeftPane');
fitToParent('Search_holder',12);
fitToParent('ResultTable_holder',12);
}
function prepareAjaxActions(actions, formName, tabName) {
// @todo HACK Overwrites LeftAndMain.js version of this method to avoid double form actions
// (by new jQuery and legacy prototype)
return false;
}

View File

@ -0,0 +1,5 @@
<% if Results %>
$Form
<% else %>
<p><% sprintf(_t('GenericDataAdmin.NORESULTS'), $ModelPluralName) %></p>
<% end_if %>