Clean up and formatting

This commit is contained in:
Thierry Francois 2014-05-04 17:12:05 +03:00
parent ec7df6712e
commit fad9121dd1
8 changed files with 126 additions and 31 deletions

View File

@ -1,8 +1,10 @@
<?php <?php
/** /**
* * Bulk action handler for deleting records.
*
* @author colymba * @author colymba
* @package GridFieldBulkEditingTools * @package GridFieldBulkEditingTools
* @subpackage BulkManager
*/ */
class GridFieldBulkActionDeleteHandler extends GridFieldBulkActionHandler class GridFieldBulkActionDeleteHandler extends GridFieldBulkActionHandler
{ {

View File

@ -1,8 +1,10 @@
<?php <?php
/** /**
* * Bulk action handler for editing records.
*
* @author colymba * @author colymba
* @package GridFieldBulkEditingTools * @package GridFieldBulkEditingTools
* @subpackage BulkManager
*/ */
class GridFieldBulkActionEditHandler extends GridFieldBulkActionHandler class GridFieldBulkActionEditHandler extends GridFieldBulkActionHandler
{ {
@ -16,7 +18,6 @@ class GridFieldBulkActionEditHandler extends GridFieldBulkActionHandler
* URL handling rules. * URL handling rules.
*/ */
private static $url_handlers = array( private static $url_handlers = array(
//'$Action!' => '$Action'
'bulkedit/update' => 'update', 'bulkedit/update' => 'update',
'bulkedit' => 'edit' 'bulkedit' => 'edit'
); );

View File

@ -1,8 +1,12 @@
<?php <?php
/** /**
* * Base class to extend for all custom bulk action handlers
* Gives access to the GridField, Component and Controller
* and implements useful functions like {@link getRecordIDList()} and {@link getRecords()}
*
* @author colymba * @author colymba
* @package GridFieldBulkEditingTools * @package GridFieldBulkEditingTools
* @subpackage BulkManager
*/ */
class GridFieldBulkActionHandler extends RequestHandler class GridFieldBulkActionHandler extends RequestHandler
{ {

View File

@ -1,8 +1,10 @@
<?php <?php
/** /**
* * Bulk action handler for unlinking records.
*
* @author colymba * @author colymba
* @package GridFieldBulkEditingTools * @package GridFieldBulkEditingTools
* @subpackage BulkManager
*/ */
class GridFieldBulkActionUnlinkHandler extends GridFieldBulkActionHandler class GridFieldBulkActionUnlinkHandler extends GridFieldBulkActionHandler
{ {

View File

@ -4,6 +4,7 @@
* *
* @author colymba * @author colymba
* @package GridFieldBulkEditingTools * @package GridFieldBulkEditingTools
* @subpackage BulkManager
*/ */
class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnProvider, GridField_URLHandler class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnProvider, GridField_URLHandler
{ {
@ -72,6 +73,12 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
} }
} }
/* **********************************************************************
* Components settings and custom methodes
* */
/** /**
* Sets the component configuration parameter * Sets the component configuration parameter
* *
@ -130,7 +137,7 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
} }
/** /**
* Add a class to the editable fields blacklist * Add a class to the readonly list
* *
* @param string $className * @param string $className
* @return boolean * @return boolean
@ -156,7 +163,7 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
} }
/** /**
* Remove a class to the editable fields blacklist * Remove a class to the readonly list
* *
* @param string $className * @param string $className
* @return boolean * @return boolean
@ -246,19 +253,42 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
return $this; return $this;
} }
/* **********************************************************************
* GridField_ColumnProvider
* */
/* GridField_ColumnProvider */ /**
* Add bulk select column
*
* @param GridField $gridField Current GridField instance
* @param array $columns Columns list
*/
function augmentColumns($gridField, &$columns) function augmentColumns($gridField, &$columns)
{ {
if(!in_array('BulkSelect', $columns)) $columns[] = 'BulkSelect'; if(!in_array('BulkSelect', $columns)) $columns[] = 'BulkSelect';
} }
/**
* Which columns are handled by the component
*
* @param GridField $gridField Current GridField instance
* @return array List of handled column names
*/
function getColumnsHandled($gridField) function getColumnsHandled($gridField)
{ {
return array('BulkSelect'); return array('BulkSelect');
} }
/**
* Sets the column's content
*
* @param GridField $gridField Current GridField instance
* @param DataObject $record Record intance for this row
* @param string $columnName Column's name for which we need content
* @return mixed Column's field content
*/
function getColumnContent($gridField, $record, $columnName) function getColumnContent($gridField, $record, $columnName)
{ {
$cb = CheckboxField::create('bulkSelect_'.$record->ID) $cb = CheckboxField::create('bulkSelect_'.$record->ID)
@ -267,19 +297,38 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
return $cb->Field(); return $cb->Field();
} }
/**
* Set the column's HTML attributes
*
* @param GridField $gridField Current GridField instance
* @param DataObject $record Record intance for this row
* @param string $columnName Column's name for which we need attributes
* @return array List of HTML attributes
*/
function getColumnAttributes($gridField, $record, $columnName) function getColumnAttributes($gridField, $record, $columnName)
{ {
return array('class' => 'col-bulkSelect'); return array('class' => 'col-bulkSelect');
} }
/**
* Set the column's meta data
*
* @param GridField $gridField Current GridField instance
* @param string $columnName Column's name for which we need meta data
* @return array List of meta data
*/
function getColumnMetadata($gridField, $columnName) function getColumnMetadata($gridField, $columnName)
{ {
if($columnName == 'BulkSelect') { if($columnName == 'BulkSelect') {
return array('title' => 'Select'); return array('title' => 'Select');
} }
} }
/* // GridField_ColumnProvider */
/* **********************************************************************
* GridField_HTMLProvider
* */
/** /**
* *
@ -334,9 +383,16 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
'header' => $templateData->renderWith('BulkManagerButtons') 'header' => $templateData->renderWith('BulkManagerButtons')
); );
} }
/* **********************************************************************
* GridField_URLHandler
* */
/** /**
* * Returns an action => handler list
*
* @param GridField $gridField * @param GridField $gridField
* @return array * @return array
*/ */

View File

@ -1,10 +1,5 @@
(function($) { (function($) {
$.entwine('ss', function($) { $.entwine('ss', function($) {
// start SS namespace overrides
// end SS namespace overrides
$.entwine('colymba', function($) { $.entwine('colymba', function($) {
@ -41,7 +36,10 @@
onunmatch: function(){} onunmatch: function(){}
}); });
/**
* Bulkselect table cell behaviours
*/
$('td.col-bulkSelect').entwine({ $('td.col-bulkSelect').entwine({
onmatch: function(){ onmatch: function(){
}, },
@ -62,7 +60,11 @@
else $(cb).prop('checked', false); else $(cb).prop('checked', false);
} }
}); });
/**
* Individual select checkbox behaviour
*/
$('td.col-bulkSelect input').entwine({ $('td.col-bulkSelect input').entwine({
onmatch: function(){ onmatch: function(){
}, },
@ -73,6 +75,10 @@
} }
}); });
/**
* Bulkselect checkbox behaviours
*/
$('input.bulkSelectAll').entwine({ $('input.bulkSelectAll').entwine({
onmatch: function(){ onmatch: function(){
}, },
@ -95,7 +101,11 @@
.get(); .get();
} }
}); });
/**
* Bulk action dropdown behaviours
*/
$('select.bulkActionName').entwine({ $('select.bulkActionName').entwine({
onmatch: function(){ onmatch: function(){
}, },
@ -131,6 +141,10 @@
} }
}); });
/**
* bulk action button behaviours
*/
$('.doBulkActionButton').entwine({ $('.doBulkActionButton').entwine({
onmatch: function(){ onmatch: function(){
}, },

View File

@ -4,9 +4,10 @@
* *
* @author colymba * @author colymba
* @package GridFieldBulkEditingTools * @package GridFieldBulkEditingTools
* @subpackage BulkUpload
*/ */
class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandler { class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandler
{
/** /**
* component configuration * component configuration
* *
@ -33,6 +34,12 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
if ( $fileRelationName != null ) $this->setConfig ( 'fileRelationName', $fileRelationName ); if ( $fileRelationName != null ) $this->setConfig ( 'fileRelationName', $fileRelationName );
} }
/* **********************************************************************
* Components settings and custom methodes
* */
/** /**
* Set a component configuration parameter * Set a component configuration parameter
* *
@ -73,7 +80,6 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
else return $this->config; else return $this->config;
} }
/* ******************************************************************************** */
/** /**
* Get the first has_one Image/File relation from the GridField managed DataObject * Get the first has_one Image/File relation from the GridField managed DataObject
@ -99,6 +105,7 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
return $imageField; return $imageField;
} }
/** /**
* Returns the name of the Image/File field name from the managed record * Returns the name of the Image/File field name from the managed record
* Either as set in the component config or the default one * Either as set in the component config or the default one
@ -132,9 +139,7 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
return 'File'; return 'File';
} }
} }
/* ******************************************************************************** */
/** /**
* Returned a configured UploadField instance * Returned a configured UploadField instance
@ -181,7 +186,12 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
return $uploadField; return $uploadField;
} }
/* **********************************************************************
* GridField_HTMLProvider
* */
/** /**
* HTML to be embedded into the GridField * HTML to be embedded into the GridField
* *
@ -251,6 +261,11 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
); );
} }
/* **********************************************************************
* GridField_URLHandler
* */
/** /**
* Component URL handlers * Component URL handlers

View File

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Handles request from the GridFieldBulkImageUpload component * Handles request from the GridFieldBulkUpload component
* *
* Handles: * Handles:
* * Form creation * * Form creation
@ -9,9 +9,10 @@
* *
* @author colymba * @author colymba
* @package GridFieldBulkEditingTools * @package GridFieldBulkEditingTools
* @subpackage BulkUpload
*/ */
class GridFieldBulkUpload_Request extends RequestHandler { class GridFieldBulkUpload_Request extends RequestHandler
{
/** /**
* *
* @var GridField * @var GridField
@ -57,7 +58,8 @@ class GridFieldBulkUpload_Request extends RequestHandler {
* @param GridField_URLHandler $component * @param GridField_URLHandler $component
* @param Controller $controller * @param Controller $controller
*/ */
public function __construct($gridField, $component, $controller) { public function __construct($gridField, $component, $controller)
{
$this->gridField = $gridField; $this->gridField = $gridField;
$this->component = $component; $this->component = $component;
$this->controller = $controller; $this->controller = $controller;
@ -93,7 +95,6 @@ class GridFieldBulkUpload_Request extends RequestHandler {
$record->write(); $record->write();
// passes the current gridfield-instance to a call-back method on the new object // passes the current gridfield-instance to a call-back method on the new object
//$record->extend("onBulkImageUpload", $this->gridField);
$record->extend("onBulkFileUpload", $this->gridField); $record->extend("onBulkFileUpload", $this->gridField);
//get uploadField and process upload //get uploadField and process upload