mirror of
https://github.com/colymba/GridFieldBulkEditingTools.git
synced 2024-10-22 11:05:57 +02:00
Clean up
This commit is contained in:
parent
5437424b7e
commit
38d05df2ec
@ -9,16 +9,20 @@
|
|||||||
class GridFieldBulkActionDeleteHandler extends GridFieldBulkActionHandler
|
class GridFieldBulkActionDeleteHandler extends GridFieldBulkActionHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* List of action handling methods
|
* RequestHandler allowed actions
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $allowed_actions = array('delete');
|
private static $allowed_actions = array('delete');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URL handling rules.
|
* RequestHandler url => action map
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $url_handlers = array(
|
private static $url_handlers = array(
|
||||||
'delete' => 'delete'
|
'delete' => 'delete'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the selected records passed from the delete bulk action
|
* Delete the selected records passed from the delete bulk action
|
||||||
|
@ -9,13 +9,15 @@
|
|||||||
class GridFieldBulkActionEditHandler extends GridFieldBulkActionHandler
|
class GridFieldBulkActionEditHandler extends GridFieldBulkActionHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* List of action handling methods
|
* RequestHandler allowed actions
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $allowed_actions = array('edit', 'update');
|
private static $allowed_actions = array('edit', 'update');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URL handling rules.
|
* RequestHandler url => action map
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $url_handlers = array(
|
private static $url_handlers = array(
|
||||||
'bulkedit/update' => 'update',
|
'bulkedit/update' => 'update',
|
||||||
|
@ -9,17 +9,21 @@
|
|||||||
class GridFieldBulkActionUnlinkHandler extends GridFieldBulkActionHandler
|
class GridFieldBulkActionUnlinkHandler extends GridFieldBulkActionHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* List of action handling methods
|
* RequestHandler allowed actions
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $allowed_actions = array('unlink');
|
private static $allowed_actions = array('unlink');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URL handling rules.
|
* RequestHandler url => action map
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $url_handlers = array(
|
private static $url_handlers = array(
|
||||||
'unlink' => 'unlink'
|
'unlink' => 'unlink'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unlink the selected records passed from the unlink bulk action
|
* Unlink the selected records passed from the unlink bulk action
|
||||||
*
|
*
|
||||||
|
@ -11,7 +11,6 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
|||||||
/**
|
/**
|
||||||
* component configuration
|
* component configuration
|
||||||
*
|
*
|
||||||
* 'imageFieldName' => field name of the $has_one Model Image relation
|
|
||||||
* 'editableFields' => fields editable on the Model
|
* 'editableFields' => fields editable on the Model
|
||||||
* 'readOnlyFieldClasses' => field types that will be converted to readonly
|
* 'readOnlyFieldClasses' => field types that will be converted to readonly
|
||||||
* 'fieldsNameBlacklist' => fields that will be removed from the automatic form generation
|
* 'fieldsNameBlacklist' => fields that will be removed from the automatic form generation
|
||||||
@ -34,6 +33,12 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
|||||||
protected $readOnlyFieldClasses = array('GridField', 'UploadField');
|
protected $readOnlyFieldClasses = array('GridField', 'UploadField');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GridFieldBulkManager component constructor
|
||||||
|
*
|
||||||
|
* @param array $editableFields List of editable fields
|
||||||
|
* @param boolean $defaultActions Use default actions list. False to start fresh.
|
||||||
|
*/
|
||||||
public function __construct($editableFields = null, $defaultActions = true)
|
public function __construct($editableFields = null, $defaultActions = true)
|
||||||
{
|
{
|
||||||
if ( $editableFields != null ) $this->setConfig ( 'editableFields', $editableFields );
|
if ( $editableFields != null ) $this->setConfig ( 'editableFields', $editableFields );
|
||||||
@ -112,6 +117,7 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns one $config parameter of the full $config
|
* Returns one $config parameter of the full $config
|
||||||
@ -125,6 +131,7 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
|||||||
else return $this->config;
|
else return $this->config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a field to the editable fields blacklist
|
* Add a field to the editable fields blacklist
|
||||||
*
|
*
|
||||||
@ -135,6 +142,7 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
|||||||
{
|
{
|
||||||
return array_push( $this->config['fieldsNameBlacklist'], $fieldName);
|
return array_push( $this->config['fieldsNameBlacklist'], $fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a class to the readonly list
|
* Add a class to the readonly list
|
||||||
@ -146,6 +154,7 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
|||||||
{
|
{
|
||||||
return array_push( $this->config['readOnlyFieldClasses'], $className);
|
return array_push( $this->config['readOnlyFieldClasses'], $className);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a field to the editable fields blacklist
|
* Remove a field to the editable fields blacklist
|
||||||
@ -161,6 +170,7 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a class to the readonly list
|
* Remove a class to the readonly list
|
||||||
@ -269,6 +279,7 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
|||||||
{
|
{
|
||||||
if(!in_array('BulkSelect', $columns)) $columns[] = 'BulkSelect';
|
if(!in_array('BulkSelect', $columns)) $columns[] = 'BulkSelect';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Which columns are handled by the component
|
* Which columns are handled by the component
|
||||||
@ -280,6 +291,7 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
|||||||
{
|
{
|
||||||
return array('BulkSelect');
|
return array('BulkSelect');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the column's content
|
* Sets the column's content
|
||||||
@ -296,6 +308,7 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
|||||||
->setAttribute('data-record', $record->ID);
|
->setAttribute('data-record', $record->ID);
|
||||||
return $cb->Field();
|
return $cb->Field();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the column's HTML attributes
|
* Set the column's HTML attributes
|
||||||
@ -310,6 +323,7 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
|||||||
return array('class' => 'col-bulkSelect');
|
return array('class' => 'col-bulkSelect');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the column's meta data
|
* Set the column's meta data
|
||||||
*
|
*
|
||||||
@ -401,6 +415,7 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
|||||||
'bulkaction' => 'handlebulkaction'
|
'bulkaction' => 'handlebulkaction'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass control over to the RequestHandler
|
* Pass control over to the RequestHandler
|
||||||
@ -436,4 +451,4 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
|||||||
|
|
||||||
user_error("Unable to find matching bulk action handler for ".$request->remaining().'.', E_USER_ERROR);
|
user_error("Unable to find matching bulk action handler for ".$request->remaining().'.', E_USER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,7 +24,9 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
|||||||
'sequentialUploads' => false
|
'sequentialUploads' => false
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Component constructor
|
||||||
*
|
*
|
||||||
* @param string $fileRelationName
|
* @param string $fileRelationName
|
||||||
* @param string/array $editableFields
|
* @param string/array $editableFields
|
||||||
@ -68,6 +70,7 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
|||||||
$this->config[$reference] = $value;
|
$this->config[$reference] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns one $config parameter of the full $config
|
* Returns one $config parameter of the full $config
|
||||||
*
|
*
|
||||||
@ -118,6 +121,7 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
|||||||
return $configFileRelationName ? $configFileRelationName : $this->getDefaultFileRelationName($gridField);
|
return $configFileRelationName ? $configFileRelationName : $this->getDefaultFileRelationName($gridField);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the ClassName of the fileRelation
|
* Return the ClassName of the fileRelation
|
||||||
* i.e. 'MyImage' => 'Image' will return 'Image'
|
* i.e. 'MyImage' => 'Image' will return 'Image'
|
||||||
@ -279,6 +283,7 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass control over to the RequestHandler
|
* Pass control over to the RequestHandler
|
||||||
*
|
*
|
||||||
@ -293,5 +298,4 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
|||||||
|
|
||||||
return $handler->handleRequest($request, DataModel::inst());
|
return $handler->handleRequest($request, DataModel::inst());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,11 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Handles request from the GridFieldBulkUpload component
|
* Handles request from the GridFieldBulkUpload component
|
||||||
*
|
|
||||||
* Handles:
|
|
||||||
* * Form creation
|
|
||||||
* * file upload
|
|
||||||
* * editing and cancelling records
|
|
||||||
*
|
*
|
||||||
* @author colymba
|
* @author colymba
|
||||||
* @package GridFieldBulkEditingTools
|
* @package GridFieldBulkEditingTools
|
||||||
@ -14,46 +9,47 @@
|
|||||||
class GridFieldBulkUpload_Request extends RequestHandler
|
class GridFieldBulkUpload_Request extends RequestHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
* Gridfield instance
|
||||||
* @var GridField
|
* @var GridField
|
||||||
*/
|
*/
|
||||||
protected $gridField;
|
protected $gridField;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Bulk upload component
|
||||||
* @var GridField_URLHandler
|
* @var GridFieldBulkUpload
|
||||||
*/
|
*/
|
||||||
protected $component;
|
protected $component;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Gridfield Form controller
|
||||||
* @var Controller
|
* @var Controller
|
||||||
*/
|
*/
|
||||||
protected $controller;
|
protected $controller;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache the records FieldList from getCMSfields()
|
* RequestHandler allowed actions
|
||||||
*
|
* @var array
|
||||||
* @var FieldList
|
|
||||||
*/
|
|
||||||
protected $recordCMSFieldList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private static $allowed_actions = array(
|
private static $allowed_actions = array(
|
||||||
'upload', 'select', 'attach', 'fileexists'
|
'upload', 'select', 'attach', 'fileexists'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* RequestHandler url => action map
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $url_handlers = array(
|
private static $url_handlers = array(
|
||||||
'$Action!' => '$Action'
|
'$Action!' => '$Action'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Handler's constructor
|
||||||
|
*
|
||||||
* @param GridFIeld $gridField
|
* @param GridFIeld $gridField
|
||||||
* @param GridField_URLHandler $component
|
* @param GridField_URLHandler $component
|
||||||
* @param Controller $controller
|
* @param Controller $controller
|
||||||
|
@ -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($) {
|
||||||
@ -74,17 +69,6 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Track completed uploads
|
|
||||||
*//*
|
|
||||||
$('li.ss-uploadfield-item.done').entwine({
|
|
||||||
onmatch: function(){
|
|
||||||
this.parents('ul.ss-uploadfield-files').trackProgress();
|
|
||||||
},
|
|
||||||
onunmatch: function(){},
|
|
||||||
});*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update buttons state and progress info...
|
* Update buttons state and progress info...
|
||||||
*/
|
*/
|
||||||
@ -282,4 +266,4 @@
|
|||||||
}); // colymba namespace
|
}); // colymba namespace
|
||||||
|
|
||||||
}); // ss namespace
|
}); // ss namespace
|
||||||
}(jQuery));
|
}(jQuery));
|
@ -23,10 +23,8 @@ window.tmpl.cache['colymba-bulkuploaddownloadtemplate'] = tmpl(
|
|||||||
'<div class="ss-uploadfield-item-cancel ss-uploadfield-item-cancelfailed delete"><button class="icon icon-16" data-icon="delete" title="' + ss.i18n._t('UploadField.CANCELREMOVE', 'Cancel/Remove') + '">' + ss.i18n._t('UploadField.CANCELREMOVE', 'Cancel/Remove') + '</button></div>' +
|
'<div class="ss-uploadfield-item-cancel ss-uploadfield-item-cancelfailed delete"><button class="icon icon-16" data-icon="delete" title="' + ss.i18n._t('UploadField.CANCELREMOVE', 'Cancel/Remove') + '">' + ss.i18n._t('UploadField.CANCELREMOVE', 'Cancel/Remove') + '</button></div>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'{% } else { %}' +
|
'{% } else { %}' +
|
||||||
//'<div class="ss-uploadfield-item-actions">{% print(file.buttons, true); %}</div>' +
|
|
||||||
'{% } %}' +
|
'{% } %}' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</li>' +
|
'</li>' +
|
||||||
'{% } %}'
|
'{% } %}'
|
||||||
);
|
);
|
||||||
//'<div class="ss-uploadfield-item-editform loading"><iframe frameborder="0" src="{%=file.edit_url%}"></iframe></div>' +
|
|
Loading…
Reference in New Issue
Block a user