(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@60227 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-08-09 05:57:44 +00:00
parent 39f7ba95bf
commit 689c34400b
8 changed files with 58 additions and 18 deletions

View File

@ -35,6 +35,7 @@ class AssetAdmin extends LeftAndMain {
'save',
'savefile',
'uploadiframe',
'UploadForm',
'deleteUnusedThumbnails' => 'ADMIN'
);

View File

@ -14,6 +14,9 @@ abstract class GenericDataAdmin extends LeftAndMain {
'getResults',
'save',
'show',
'CreationForm',
'ExportForm',
'SearchForm',
);
public $filter;

View File

@ -35,7 +35,8 @@ class LeftAndMain extends Controller {
'printable',
'save',
'show',
'Member_ProfileForm'
'Member_ProfileForm',
'EditorToolbar',
);
/**
@ -120,7 +121,9 @@ class LeftAndMain extends Controller {
Requirements::javascript('jsparty/tree/tree.js');
Requirements::css('jsparty/tree/tree.css');
/*
Requirements::javascript('jsparty/tabstrip/tabstrip.js');
*/
Requirements::css('jsparty/tabstrip/tabstrip.css');
Requirements::css('cms/css/TinyMCEImageEnhancement.css');

View File

@ -354,16 +354,18 @@ class ModelAdmin_CollectionController extends Controller {
$model = singleton($this->modelClass);
$searchKeys = array_intersect_key($request->getVars(), $model->searchable_fields());
$context = $model->getDefaultSearchContext();
$results = $context->getResults($searchKeys, 0, $this->parentController->stat('page_length'));
$output = "";
$results = $context->getResults($searchKeys, null, array('start'=>0, 'limit'=>$this->parentController->stat('page_length')));
$output = "<h2>" . _t('ModelAdmin.SEARCHRESULTS','Search Results') . "</h2>\n";
if ($results) {
$output .= "<table>";
$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->getField($key);
$output .= $row->$key;
$output .= "</td>";
}
$output .= "</tr>";
@ -374,6 +376,23 @@ class ModelAdmin_CollectionController extends Controller {
}
return $output;
}
/**
* Action to render results for an autocomplete filter.
*
* @param unknown_type $request
* @return unknown
*/
function filter($request) {
$model = singleton($this->modelClass);
$context = $model->getDefaultSearchContext();
$value = $request->getVar('q');
$results = $context->getResults(array("Name"=>$value));
header("Content-Type: text/plain");
foreach($results as $result) {
echo $result->Name . "\n";
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -461,7 +480,10 @@ class ModelAdmin_RecordController extends Controller {
$validator = ($this->currentRecord->hasMethod('getCMSValidator')) ? $this->currentRecord->getCMSValidator() : null;
$actions = new FieldSet(new FormAction("doSave", "Save"));
$actions = new FieldSet(
new FormAction("goBack", "Back"),
new FormAction("doSave", "Save")
);
$form = new Form($this, "EditForm", $fields, $actions, $validator);
$form->loadDataFrom($this->currentRecord);

View File

@ -30,26 +30,25 @@ body.ModelAdmin #ResultTable_holder {
overflow:auto;
}
body.ModelAdmin #ResultTable_holder table {
body.ModelAdmin #right table.results {
margin:6px;
padding:0;
border-spacing:0 2px;
width:230px;
}
body.ModelAdmin #ResultTable_holder table td {
font-size:11px;
body.ModelAdmin #right table.results td {
font-size:12px;
font-weight:bold;
background-color:#fff;
padding:2px;
}
body.ModelAdmin #ResultTable_holder table td.over {
body.ModelAdmin #right table.results td.over {
background-color:#bbb;
cursor:pointer;
}
body.ModelAdmin #ResultTable_holder table td.active {
body.ModelAdmin #right table.results td.active {
background-color:#555;
color:#fff;
}

View File

@ -141,7 +141,7 @@ window.ontabschanged = function() {
}
}*/
if( _TAB_DIVS_ON_PAGE ) {
if(typeof _TAB_DIVS_ON_PAGE != 'undefined') {
for(i = 0; i < _TAB_DIVS_ON_PAGE.length; i++ ) {
fitToParent(_TAB_DIVS_ON_PAGE[i], 30);
}

View File

@ -9,6 +9,10 @@
* @todo alias the $ function instead of literal jQuery
*/
jQuery(document).ready(function() {
/**
* Stores a jQuery reference to the last submitted search form.
*/
__lastSearch = null;
/**
* GET a fragment of HTML to display in the right panel
@ -22,6 +26,11 @@ jQuery(document).ready(function() {
// Is livequery a solution?
Behaviour.apply(); // refreshes ComplexTableField
jQuery('#right ul.tabstrip').tabs();
jQuery('#Form_EditForm_action_goBack').click(function() {
if(__lastSearch) __lastSearch.trigger('submit');
return false;
});
});
}
@ -73,9 +82,9 @@ jQuery(document).ready(function() {
});
/**
* Attach tabs plugin to the set of search filter forms
* Attach tabs plugin to the set of search filter and edit forms
*/
jQuery('#SearchForm_holder').tabs();
jQuery('ul.tabstrip').tabs();
/**
* Submits a search filter query and attaches event handlers
@ -84,11 +93,13 @@ jQuery(document).ready(function() {
* @todo use livequery to manage ResultTable click handlers
*/
jQuery('#SearchForm_holder .tab form').submit(function(){
__lastSearch = jQuery(this);
form = jQuery(this);
data = formData(form);
jQuery.get(form.attr('action'), data, function(result){
jQuery('#ResultTable_holder').html(result);
jQuery('#ResultTable_holder td').click(function(){
jQuery('#right').html(result);
jQuery('#right td').click(function(){
td = jQuery(this);
showRecord(td.parent().attr('title'));
td.parent().parent().find('td').removeClass('active');

View File

@ -25,7 +25,8 @@
</div>
<% end_control %>
</div>
<h2><% _t('SEARCHRESULTS','Search Results') %></h2>
<!--
<div id="ResultTable_holder" class="leftbottom">
</div>
-->
</div>