mirror of
https://github.com/colymba/GridFieldBulkEditingTools.git
synced 2024-10-22 11:05:57 +02:00
Merge pull request #73 from purplespider/62-squashed-2
NEW: Allow setting of canAttachExisting and canPreviewFolder
This commit is contained in:
commit
e41282b3d2
@ -23,6 +23,8 @@ The available configuration options are:
|
||||
* 'folderName' : name of the folder where the images or files should be uploaded
|
||||
* 'maxFileSize' : integer, maximum upload file size in bytes
|
||||
* 'sequentialUploads' : boolean, if true files will be uploaded one by one
|
||||
* 'canAttachExisting' : boolean, if false the "From files" button will not be displayed in the UploadField (default: true)
|
||||
* 'canPreviewFolder' : boolean, if false the upload location will not be displayed in the UploadField (default: true)
|
||||
|
||||
## Bulk Editing
|
||||
To get a quick edit shortcut to all the newly upload files, please also add the `GridFieldBulkManager` component to your `GridFieldConfig`.
|
@ -15,13 +15,17 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
||||
* 'folderName' => where to upload the files
|
||||
* 'maxFileSize' => maximum file size allowed per upload
|
||||
* 'sequentialUploads' => process uploads 1 after the other rather than all at once
|
||||
* 'canAttachExisting' => displays "From files" button in the UploadField
|
||||
* 'canPreviewFolder' => displays the upload location in the UploadField
|
||||
* @var array
|
||||
*/
|
||||
protected $config = array(
|
||||
'fileRelationName' => null,
|
||||
'folderName' => 'bulkUpload',
|
||||
'maxFileSize' => null,
|
||||
'sequentialUploads' => false
|
||||
'sequentialUploads' => false,
|
||||
'canAttachExisting' => true,
|
||||
'canPreviewFolder' => true
|
||||
);
|
||||
|
||||
|
||||
@ -60,10 +64,22 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
||||
$value = null;
|
||||
}
|
||||
|
||||
//sequentialUploads true/false
|
||||
if ( $reference == 'sequentialUploads' && !is_bool($value) )
|
||||
//sequentialUploads true/false
|
||||
if ( $reference == 'sequentialUploads' && !is_bool($value) )
|
||||
{
|
||||
$value = false;
|
||||
$value = false;
|
||||
}
|
||||
|
||||
//canAttachExisting true/false
|
||||
if ( $reference == 'canAttachExisting' && !is_bool($value) )
|
||||
{
|
||||
$value = true;
|
||||
}
|
||||
|
||||
//canPreviewFolder true/false
|
||||
if ( $reference == 'canPreviewFolder' && !is_bool($value) )
|
||||
{
|
||||
$value = true;
|
||||
}
|
||||
|
||||
$this->config[$reference] = $value;
|
||||
@ -159,7 +175,9 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
||||
->setConfig('previewMaxWidth', 20)
|
||||
->setConfig('previewMaxHeight', 20)
|
||||
->setConfig('changeDetection', false)
|
||||
|
||||
->setConfig('canPreviewFolder', $this->getConfig('canPreviewFolder'))
|
||||
->setConfig('canAttachExisting', $this->getConfig('canAttachExisting'))
|
||||
|
||||
->setRecord(DataObject::create()) // avoid UploadField to get auto-config from the Page (e.g fix allowedMaxFileNumber)
|
||||
|
||||
->setTemplate('GridFieldBulkUploadField')
|
||||
|
Loading…
Reference in New Issue
Block a user