From 2683a5ae62bcbee834a724c37264f95d5537939a Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Sat, 21 Nov 2009 03:17:49 +0000 Subject: [PATCH] MINOR Making full result table rows in ModelAdmin selectable git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92773 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/ModelAdmin.php | 1 + css/ModelAdmin.css | 4 ++-- javascript/ModelAdmin.js | 14 +++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/code/ModelAdmin.php b/code/ModelAdmin.php index 1a327813..250f0ec5 100755 --- a/code/ModelAdmin.php +++ b/code/ModelAdmin.php @@ -606,6 +606,7 @@ class ModelAdmin_CollectionController extends Controller { $resultsForm = $this->ResultsForm(array_merge($form->getData(), $request)); // Before rendering, let's get the total number of results returned $tableField = $resultsForm->Fields()->dataFieldByName($this->modelClass); + $tableField->addExtraClass('resultsTable'); $numResults = $tableField->TotalCount(); if($numResults) { diff --git a/css/ModelAdmin.css b/css/ModelAdmin.css index 6022043a..2bc9253b 100644 --- a/css/ModelAdmin.css +++ b/css/ModelAdmin.css @@ -61,8 +61,8 @@ body.ModelAdmin #SearchForm_holder form div#ResultAssembly{ width: 45%; } -body.ModelAdmin #ResultTable_holder { - overflow:auto; +body.ModelAdmin .resultsTable tbody td { + cursor: pointer; } body.ModelAdmin #right{ diff --git a/javascript/ModelAdmin.js b/javascript/ModelAdmin.js index 4b3e5d4d..e9df325d 100644 --- a/javascript/ModelAdmin.js +++ b/javascript/ModelAdmin.js @@ -19,12 +19,12 @@ */ $('#ModelClassSelector select').concrete({ onmatch: function() { + var self = this; // Set up an onchange function to show the applicable form and hide all others this.bind('change', function(e) { - var $selector = $(this); - this.find('option').each(function() { + self.find('option').each(function() { var $form = $('#'+$(this).val()); - if($selector.val() == $(this).val()) $form.show(); + if(self.val() == $(this).val()) $form.show(); else $form.hide(); }); }); @@ -96,13 +96,13 @@ /** * Table record handler for search result record */ - $('form[name=Form_ResultsForm] tbody td a').concrete({ + $('.resultsTable tbody td').concrete({ onmatch: function() { // TODO Replace with concrete event handler this.bind('click', function(e) { - if($(this).hasClass('deletelink downloadlink')) return true; - - $('#Form_EditForm').concrete('ss').loadForm($(this).attr('href')); + var firstLink = $(this).find('a[href]'); + if(!firstLink) return; + $('#Form_EditForm').concrete('ss').loadForm(firstLink.attr('href')); return false; }); }