mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +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(
|
||||||
|
$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)));
|
||||||
|
|
||||||
if ($results) {
|
// implemented as a form to enable further actions on the resultset
|
||||||
$output .= "<table class=\"results\">";
|
// (serverside sorting, export as CSV, etc)
|
||||||
foreach($results as $row) {
|
$form = new Form(
|
||||||
$uri = Director::absoluteBaseUrl();
|
$this,
|
||||||
$output .= "<tr title=\"{$uri}admin/crm/{$this->modelClass}/{$row->ID}/edit\">";
|
'ResultsForm',
|
||||||
foreach($model->searchable_fields() as $key=>$val) {
|
new FieldSet(
|
||||||
$output .= "<td>";
|
new HeaderField(_t('ModelAdmin.SEARCHRESULTS','Search Results'), 2),
|
||||||
$output .= $row->$key;
|
$tf
|
||||||
$output .= "</td>";
|
),
|
||||||
}
|
new FieldSet()
|
||||||
$output .= "</tr>";
|
);
|
||||||
}
|
|
||||||
$output .= "</table>";
|
return $form->forTemplate();
|
||||||
} else {
|
|
||||||
$output .= "<p>No results found</p>";
|
|
||||||
}
|
|
||||||
return $output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -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(){
|
||||||
@ -124,3 +125,9 @@ function fixHeight_left() {
|
|||||||
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