mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
(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:
parent
649ff87aec
commit
3fe17e9649
@ -355,26 +355,31 @@ class ModelAdmin_CollectionController extends Controller {
|
|||||||
$searchKeys = array_intersect_key($request->getVars(), $model->searchable_fields());
|
$searchKeys = array_intersect_key($request->getVars(), $model->searchable_fields());
|
||||||
$context = $model->getDefaultSearchContext();
|
$context = $model->getDefaultSearchContext();
|
||||||
$results = $context->getResults($searchKeys, null, array('start'=>0, 'limit'=>$this->parentController->stat('page_length')));
|
$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();
|
||||||
|
|
||||||
|
$tf = new TableListField(
|
||||||
if ($results) {
|
$this->modelClass,
|
||||||
$output .= "<table class=\"results\">";
|
$this->modelClass,
|
||||||
foreach($results as $row) {
|
$summaryFields
|
||||||
$uri = Director::absoluteBaseUrl();
|
);
|
||||||
$output .= "<tr title=\"{$uri}admin/crm/{$this->modelClass}/{$row->ID}/edit\">";
|
$tf->setCustomSourceItems($results);
|
||||||
foreach($model->searchable_fields() as $key=>$val) {
|
$tf->setPermissions(array('view'));
|
||||||
$output .= "<td>";
|
$url = '<a href=\"' . Director::absoluteBaseURL() . 'admin/crm/' . $this->modelClass . '/$ID/edit\">$value</a>';
|
||||||
$output .= $row->$key;
|
$tf->setFieldFormatting(array_combine(array_keys($summaryFields), array_fill(0,count($summaryFields), $url)));
|
||||||
$output .= "</td>";
|
|
||||||
}
|
// implemented as a form to enable further actions on the resultset
|
||||||
$output .= "</tr>";
|
// (serverside sorting, export as CSV, etc)
|
||||||
}
|
$form = new Form(
|
||||||
$output .= "</table>";
|
$this,
|
||||||
} else {
|
'ResultsForm',
|
||||||
$output .= "<p>No results found</p>";
|
new FieldSet(
|
||||||
}
|
new HeaderField(_t('ModelAdmin.SEARCHRESULTS','Search Results'), 2),
|
||||||
return $output;
|
$tf
|
||||||
|
),
|
||||||
|
new FieldSet()
|
||||||
|
);
|
||||||
|
|
||||||
|
return $form->forTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -464,7 +469,7 @@ class ModelAdmin_RecordController extends Controller {
|
|||||||
$validator = ($this->currentRecord->hasMethod('getCMSValidator')) ? $this->currentRecord->getCMSValidator() : null;
|
$validator = ($this->currentRecord->hasMethod('getCMSValidator')) ? $this->currentRecord->getCMSValidator() : null;
|
||||||
|
|
||||||
$actions = new FieldSet(
|
$actions = new FieldSet(
|
||||||
new FormAction("goBack", "Back"),
|
//new FormAction("goBack", "Back"),
|
||||||
new FormAction("doSave", "Save")
|
new FormAction("doSave", "Save")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -99,11 +99,12 @@ jQuery(document).ready(function() {
|
|||||||
data = formData(form);
|
data = formData(form);
|
||||||
jQuery.get(form.attr('action'), data, function(result){
|
jQuery.get(form.attr('action'), data, function(result){
|
||||||
jQuery('#right #ModelAdminPanel').html(result);
|
jQuery('#right #ModelAdminPanel').html(result);
|
||||||
jQuery('#right #ModelAdminPanel td').click(function(){
|
jQuery('#right #ModelAdminPanel tbody td a').click(function(){
|
||||||
td = jQuery(this);
|
var el = jQuery(this);
|
||||||
showRecord(td.parent().attr('title'));
|
showRecord(el.attr('href'));
|
||||||
td.parent().parent().find('td').removeClass('active');
|
//el.parent().parent().find('td').removeClass('active');
|
||||||
td.addClass('active').siblings().addClass('active');
|
//el.addClass('active').siblings().addClass('active');
|
||||||
|
return false;
|
||||||
}).hover(function(){
|
}).hover(function(){
|
||||||
jQuery(this).addClass('over').siblings().addClass('over')
|
jQuery(this).addClass('over').siblings().addClass('over')
|
||||||
}, function(){
|
}, function(){
|
||||||
@ -123,4 +124,10 @@ function fixHeight_left() {
|
|||||||
fitToParent('LeftPane');
|
fitToParent('LeftPane');
|
||||||
fitToParent('Search_holder',12);
|
fitToParent('Search_holder',12);
|
||||||
fitToParent('ResultTable_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;
|
||||||
}
|
}
|
5
templates/Includes/ModelAdmin_Results.ss
Normal file
5
templates/Includes/ModelAdmin_Results.ss
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<% if Results %>
|
||||||
|
$Form
|
||||||
|
<% else %>
|
||||||
|
<p><% sprintf(_t('GenericDataAdmin.NORESULTS'), $ModelPluralName) %></p>
|
||||||
|
<% end_if %>
|
Loading…
Reference in New Issue
Block a user