mirror of
https://github.com/colymba/GridFieldBulkEditingTools.git
synced 2024-10-22 11:05:57 +02:00
Clean up and formatting
This commit is contained in:
parent
ec7df6712e
commit
fad9121dd1
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* Bulk action handler for deleting records.
|
||||
*
|
||||
* @author colymba
|
||||
* @package GridFieldBulkEditingTools
|
||||
* @subpackage BulkManager
|
||||
*/
|
||||
class GridFieldBulkActionDeleteHandler extends GridFieldBulkActionHandler
|
||||
{
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* Bulk action handler for editing records.
|
||||
*
|
||||
* @author colymba
|
||||
* @package GridFieldBulkEditingTools
|
||||
* @subpackage BulkManager
|
||||
*/
|
||||
class GridFieldBulkActionEditHandler extends GridFieldBulkActionHandler
|
||||
{
|
||||
@ -16,7 +18,6 @@ class GridFieldBulkActionEditHandler extends GridFieldBulkActionHandler
|
||||
* URL handling rules.
|
||||
*/
|
||||
private static $url_handlers = array(
|
||||
//'$Action!' => '$Action'
|
||||
'bulkedit/update' => 'update',
|
||||
'bulkedit' => 'edit'
|
||||
);
|
||||
|
@ -1,8 +1,12 @@
|
||||
<?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
|
||||
* @package GridFieldBulkEditingTools
|
||||
* @subpackage BulkManager
|
||||
*/
|
||||
class GridFieldBulkActionHandler extends RequestHandler
|
||||
{
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* Bulk action handler for unlinking records.
|
||||
*
|
||||
* @author colymba
|
||||
* @package GridFieldBulkEditingTools
|
||||
* @subpackage BulkManager
|
||||
*/
|
||||
class GridFieldBulkActionUnlinkHandler extends GridFieldBulkActionHandler
|
||||
{
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
* @author colymba
|
||||
* @package GridFieldBulkEditingTools
|
||||
* @subpackage BulkManager
|
||||
*/
|
||||
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
|
||||
*
|
||||
@ -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
|
||||
* @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
|
||||
* @return boolean
|
||||
@ -246,19 +253,42 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
$cb = CheckboxField::create('bulkSelect_'.$record->ID)
|
||||
@ -267,19 +297,38 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if($columnName == 'BulkSelect') {
|
||||
return array('title' => 'Select');
|
||||
}
|
||||
}
|
||||
|
||||
/* // GridField_ColumnProvider */
|
||||
|
||||
|
||||
|
||||
/* **********************************************************************
|
||||
* GridField_HTMLProvider
|
||||
* */
|
||||
|
||||
/**
|
||||
*
|
||||
@ -334,9 +383,16 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
||||
'header' => $templateData->renderWith('BulkManagerButtons')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* **********************************************************************
|
||||
* GridField_URLHandler
|
||||
* */
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns an action => handler list
|
||||
*
|
||||
* @param GridField $gridField
|
||||
* @return array
|
||||
*/
|
||||
|
@ -1,10 +1,5 @@
|
||||
(function($) {
|
||||
$.entwine('ss', function($) {
|
||||
|
||||
// start SS namespace overrides
|
||||
|
||||
// end SS namespace overrides
|
||||
|
||||
$.entwine('ss', function($) {
|
||||
|
||||
$.entwine('colymba', function($) {
|
||||
|
||||
@ -41,7 +36,10 @@
|
||||
onunmatch: function(){}
|
||||
});
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Bulkselect table cell behaviours
|
||||
*/
|
||||
$('td.col-bulkSelect').entwine({
|
||||
onmatch: function(){
|
||||
},
|
||||
@ -62,7 +60,11 @@
|
||||
else $(cb).prop('checked', false);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Individual select checkbox behaviour
|
||||
*/
|
||||
$('td.col-bulkSelect input').entwine({
|
||||
onmatch: function(){
|
||||
},
|
||||
@ -73,6 +75,10 @@
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Bulkselect checkbox behaviours
|
||||
*/
|
||||
$('input.bulkSelectAll').entwine({
|
||||
onmatch: function(){
|
||||
},
|
||||
@ -95,7 +101,11 @@
|
||||
.get();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Bulk action dropdown behaviours
|
||||
*/
|
||||
$('select.bulkActionName').entwine({
|
||||
onmatch: function(){
|
||||
},
|
||||
@ -131,6 +141,10 @@
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* bulk action button behaviours
|
||||
*/
|
||||
$('.doBulkActionButton').entwine({
|
||||
onmatch: function(){
|
||||
},
|
||||
|
@ -4,9 +4,10 @@
|
||||
*
|
||||
* @author colymba
|
||||
* @package GridFieldBulkEditingTools
|
||||
* @subpackage BulkUpload
|
||||
*/
|
||||
class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandler {
|
||||
|
||||
class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandler
|
||||
{
|
||||
/**
|
||||
* component configuration
|
||||
*
|
||||
@ -33,6 +34,12 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
||||
if ( $fileRelationName != null ) $this->setConfig ( 'fileRelationName', $fileRelationName );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* **********************************************************************
|
||||
* Components settings and custom methodes
|
||||
* */
|
||||
|
||||
/**
|
||||
* Set a component configuration parameter
|
||||
*
|
||||
@ -73,7 +80,6 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
||||
else return $this->config;
|
||||
}
|
||||
|
||||
/* ******************************************************************************** */
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the name of the Image/File field name from the managed record
|
||||
* Either as set in the component config or the default one
|
||||
@ -132,9 +139,7 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
||||
return 'File';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ******************************************************************************** */
|
||||
|
||||
|
||||
/**
|
||||
* Returned a configured UploadField instance
|
||||
@ -181,7 +186,12 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
||||
return $uploadField;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* **********************************************************************
|
||||
* GridField_HTMLProvider
|
||||
* */
|
||||
|
||||
/**
|
||||
* HTML to be embedded into the GridField
|
||||
*
|
||||
@ -251,6 +261,11 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* **********************************************************************
|
||||
* GridField_URLHandler
|
||||
* */
|
||||
|
||||
/**
|
||||
* Component URL handlers
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Handles request from the GridFieldBulkImageUpload component
|
||||
* Handles request from the GridFieldBulkUpload component
|
||||
*
|
||||
* Handles:
|
||||
* * Form creation
|
||||
@ -9,9 +9,10 @@
|
||||
*
|
||||
* @author colymba
|
||||
* @package GridFieldBulkEditingTools
|
||||
* @subpackage BulkUpload
|
||||
*/
|
||||
class GridFieldBulkUpload_Request extends RequestHandler {
|
||||
|
||||
class GridFieldBulkUpload_Request extends RequestHandler
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var GridField
|
||||
@ -57,7 +58,8 @@ class GridFieldBulkUpload_Request extends RequestHandler {
|
||||
* @param GridField_URLHandler $component
|
||||
* @param Controller $controller
|
||||
*/
|
||||
public function __construct($gridField, $component, $controller) {
|
||||
public function __construct($gridField, $component, $controller)
|
||||
{
|
||||
$this->gridField = $gridField;
|
||||
$this->component = $component;
|
||||
$this->controller = $controller;
|
||||
@ -93,7 +95,6 @@ class GridFieldBulkUpload_Request extends RequestHandler {
|
||||
$record->write();
|
||||
|
||||
// passes the current gridfield-instance to a call-back method on the new object
|
||||
//$record->extend("onBulkImageUpload", $this->gridField);
|
||||
$record->extend("onBulkFileUpload", $this->gridField);
|
||||
|
||||
//get uploadField and process upload
|
||||
|
Loading…
Reference in New Issue
Block a user