(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@60276 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-08-11 00:03:57 +00:00
parent 2ea27c63f9
commit c4651a2fda
7 changed files with 132 additions and 30 deletions

View File

@ -12,6 +12,7 @@ class CommentAdmin extends LeftAndMain {
'hammarked', 'hammarked',
'showtable', 'showtable',
'spammarked', 'spammarked',
'EditForm',
); );
public function init() { public function init() {

View File

@ -5,6 +5,8 @@
* *
* @package cms * @package cms
* @subpackage core * @subpackage core
*
* @deprecated Use {@link ModelAdmin} instead, it's much more advanced and does much more for you.
*/ */
abstract class GenericDataAdmin extends LeftAndMain { abstract class GenericDataAdmin extends LeftAndMain {
static $allowed_actions = array( static $allowed_actions = array(

View File

@ -37,6 +37,8 @@ class LeftAndMain extends Controller {
'show', 'show',
'Member_ProfileForm', 'Member_ProfileForm',
'EditorToolbar', 'EditorToolbar',
'EditForm',
); );
/** /**

View File

@ -43,7 +43,8 @@ abstract class ModelAdmin extends LeftAndMain {
'import', 'import',
'renderimportform', 'renderimportform',
'handleList', 'handleList',
'handleItem' 'handleItem',
'ImportForm'
); );
/** /**
@ -109,6 +110,7 @@ abstract class ModelAdmin extends LeftAndMain {
Requirements::javascript('jsparty/jquery/ui/ui.core.js'); Requirements::javascript('jsparty/jquery/ui/ui.core.js');
Requirements::javascript('jsparty/jquery/ui/ui.tabs.js'); Requirements::javascript('jsparty/jquery/ui/ui.tabs.js');
Requirements::javascript('jsparty/jquery/plugins/form/jquery.form.js'); Requirements::javascript('jsparty/jquery/plugins/form/jquery.form.js');
Requirements::javascript('jsparty/jquery/jquery_improvement.js');
Requirements::javascript('cms/javascript/ModelAdmin.js'); Requirements::javascript('cms/javascript/ModelAdmin.js');
} }
@ -390,9 +392,12 @@ class ModelAdmin_CollectionController extends Controller {
*/ */
public function SearchForm() { public function SearchForm() {
$context = singleton($this->modelClass)->getDefaultSearchContext(); $context = singleton($this->modelClass)->getDefaultSearchContext();
$fields = $context->getSearchFields();
$columnSelectionField = $this->ColumnSelectionField();
$fields->push($columnSelectionField);
$form = new Form($this, "SearchForm", $form = new Form($this, "SearchForm",
$context->getSearchFields(), $fields,
new FieldSet( new FieldSet(
new FormAction('search', _t('MemberTableField.SEARCH')) new FormAction('search', _t('MemberTableField.SEARCH'))
) )
@ -403,6 +408,33 @@ class ModelAdmin_CollectionController extends Controller {
return $form; return $form;
} }
/**
* Give the flexibilility to show variouse combination of columns in the search result table
*/
public function ColumnSelectionField() {
$model = singleton($this->modelClass);
$source = $model->summaryFields();
foreach ($source as $fieldName => $label){
$value[] = $fieldName;
}
$checkboxes = new CheckboxSetField("ResultAssembly", "Tick the box if you want it to be shown in the results", $source, $value);
$field = new CompositeField(
new LiteralField("ToggleResultAssemblyLink", "<a class=\"form_frontend_function toggle_result_assembly\" href=\"#\">+ choose columns</a>"),
$checkboxesBlock = new CompositeField(
$checkboxes,
new LiteralField("ClearDiv", "<div class=\"clear\"></div>"),
new LiteralField("TickAllAssemblyLink","<a class=\"form_frontend_function tick_all_result_assembly\" href=\"#\">select all</a>"),
new LiteralField("UntickAllAssemblyLink","<a class=\"form_frontend_function untick_all_result_assembly\" href=\"#\">select none</a>")
)
);
$field -> setExtraClass("ResultAssemblyBlock");
$checkboxesBlock -> setExtraClass("hidden");
return $field;
}
/** /**
* Action to render a data object collection, using the model context to provide filters * Action to render a data object collection, using the model context to provide filters
* and paging. * and paging.
@ -436,6 +468,12 @@ class ModelAdmin_CollectionController extends Controller {
function ResultsForm() { function ResultsForm() {
$model = singleton($this->modelClass); $model = singleton($this->modelClass);
$summaryFields = $model->summaryFields(); $summaryFields = $model->summaryFields();
$resultAssembly = $_REQUEST['ResultAssembly'];
foreach($summaryFields as $fieldname=>$label){
if(!$resultAssembly[$fieldname]){
unset($summaryFields[$fieldname]);
}
}
$tf = new TableListField( $tf = new TableListField(
$this->modelClass, $this->modelClass,
$this->modelClass, $this->modelClass,

View File

@ -1,3 +1,8 @@
.clear{
display: block;
clear: both;
}
body.ModelAdmin #left { body.ModelAdmin #left {
width: 250px; width: 250px;
} }
@ -26,6 +31,30 @@ body.ModelAdmin #SearchForm_holder {
margin-bottom:1em; margin-bottom:1em;
} }
body.ModelAdmin #SearchForm_holder div.ResultAssemblyBlock{
margin: 1.5em 0px;
}
body.ModelAdmin #SearchForm_holder form div.field.hidden{
display: none;
}
body.ModelAdmin #SearchForm_holder form div#ResultAssembly{
margin: 0;
display: block;
clear: both;
}
body.ModelAdmin #SearchForm_holder form div#ResultAssembly label{
width: auto;
clear: both;
margin: 0px;
}
body.ModelAdmin #SearchForm_holder form div#ResultAssembly ul.optionset li{
float: left;
width: 45%;
}
body.ModelAdmin #ResultTable_holder { body.ModelAdmin #ResultTable_holder {
overflow:auto; overflow:auto;
} }

View File

@ -22,8 +22,6 @@ jQuery(document).ready(function() {
jQuery('#right #ModelAdminPanel').html(result); jQuery('#right #ModelAdminPanel').html(result);
jQuery('#SearchForm_holder').tabs(); jQuery('#SearchForm_holder').tabs();
// TODO/SAM: It seems a bit of a hack to have to list all the little updaters here.
// Is livequery a solution?
Behaviour.apply(); // refreshes ComplexTableField Behaviour.apply(); // refreshes ComplexTableField
jQuery('#right ul.tabstrip').tabs(); jQuery('#right ul.tabstrip').tabs();
}); });
@ -82,6 +80,18 @@ jQuery(document).ready(function() {
return false; return false;
}); });
jQuery('#right #ModelAdminPanel tbody td a').livequery('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(){
jQuery(this).removeClass('over').siblings().removeClass('over')
});
/** /**
* Attach tabs plugin to the set of search filter and edit forms * Attach tabs plugin to the set of search filter and edit forms
*/ */
@ -102,18 +112,6 @@ jQuery(document).ready(function() {
jQuery('#right #ModelAdminPanel').html(result); jQuery('#right #ModelAdminPanel').html(result);
Behaviour.apply(); Behaviour.apply();
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(){
jQuery(this).removeClass('over').siblings().removeClass('over')
});
}); });
return false; return false;
@ -128,6 +126,37 @@ jQuery(document).ready(function() {
return false; return false;
}); });
jQuery('a.form_frontend_function.clear_search').click(function(e) {
//jQuery('#SearchForm_holder .tab form').clearForm();
var searchform = jQuery(this).parent().get(0);
jQuery(searchform).clearForm();
return false;
});
jQuery('a.form_frontend_function.toggle_result_assembly').click(function(){
var toggleElement = jQuery(this).next();
if(toggleElement.css('display') != 'none'){
jQuery(this).html('+ choose columns');
toggleElement.hide();
}else{
jQuery(this).html('- hide column choose');
toggleElement.show();
}
return false;
});
jQuery('a.form_frontend_function.tick_all_result_assembly').click(function(){
var resultAssembly = jQuery('div#ResultAssembly ul li input');
resultAssembly.attr('checked', 'checked');
return false;
});
jQuery('a.form_frontend_function.untick_all_result_assembly').click(function(){
var resultAssembly = jQuery('div#ResultAssembly ul li input');
resultAssembly.removeAttr('checked');
return false;
});
}); });
/** /**

View File

@ -1,4 +1,18 @@
<div id="LeftPane"> <div id="LeftPane">
<h2><% _t('SEARCHLISTINGS','Search Listings') %></h2>
<div id="SearchForm_holder" class="leftbottom">
<ul class="tabstrip">
<% control SearchForms %>
<li class="first"><a href="#{$Form.Name}_$ClassName">$Title</a></li>
<% end_control %>
</ul>
<% control SearchForms %>
<div class="tab" id="{$Form.Name}_$ClassName">
$Form
<a class="form_frontend_function clear_search" href="#">Clear Search</a>
</div>
<% end_control %>
</div>
<h2><% _t('ADDLISTING','Add Listing') %></h2> <h2><% _t('ADDLISTING','Add Listing') %></h2>
<div id="AddForm_holder" class="lefttop"> <div id="AddForm_holder" class="lefttop">
<ul class="tabstrip"> <ul class="tabstrip">
@ -14,19 +28,6 @@
</div> </div>
<% end_if %> <% end_if %>
</div> </div>
<h2><% _t('SEARCHLISTINGS','Search Listings') %></h2>
<div id="SearchForm_holder" class="leftbottom">
<ul class="tabstrip">
<% control SearchForms %>
<li class="first"><a href="#{$Form.Name}_$ClassName">$Title</a></li>
<% end_control %>
</ul>
<% control SearchForms %>
<div class="tab" id="{$Form.Name}_$ClassName">
$Form
</div>
<% end_control %>
</div>
<!-- <!--
<div id="ResultTable_holder" class="leftbottom"> <div id="ResultTable_holder" class="leftbottom">
</div> </div>