diff --git a/README.md b/README.md index ad2e077..fbd93c3 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ GridFieldBulkImageUpload ======================== SilverStripe 3 GridField component for uploading images in bulk into the managed DataObject relation, with option to edit fields on the fly. -This component is built around the CMSFileAddController editForm, it overrides and adds some behaviors, templates and styles. +This component takes bit and pieces around from CMSFileAddController, GridFieldDetailForm_ItemRequest, UploadField, and it overrides and adds some behaviors, templates and styles. ## Requirments * SilverStripe 3.0 @@ -20,8 +20,8 @@ Simplest usage, add the component to your GridField as below. The component will ## Usage 2 Same as 1 but you can specify which Image field to use and which fields are editable -$imageField: The name of the image field to use (should have 'ID' at the end: If your relation is set has 'MyImage' => 'Image', the parameter should be 'MyImageID') -$editableFields: An array of db fields name that will be editable like array('myTextField', 'myVarcharField', 'myEnumField') +$imageField: string: The name of the image field to use (should have 'ID' at the end: If your relation is set has 'MyImage' => 'Image', the parameter should be 'MyImageID') +$editableFields: array: list of db fields name as string that will be editable like: array('myTextField', 'myVarcharField', 'myEnumField') :::php $config->addComponent(new GridFieldBulkImageUpload( $imageField, $editableFields )); @@ -30,5 +30,8 @@ $editableFields: An array of db fields name that will be editable like array('my * The HTML form fields for each editable fields are taken from the DataObject's getCMSFields() method * Only (HTML)Text/Varchar and Enum fields are picked up by the automatic config -## TODO -* Add option to specify upload folder \ No newline at end of file +## @TODO +* Add option to specify upload folder +* Styles: fade back progress to blue once updated +* Handle and display errors better for: creation, update, cancel +* Make it work not only for images -> might need to rename this component then? \ No newline at end of file diff --git a/code/GridFieldBulkImageUpload.php b/code/GridFieldBulkImageUpload.php index d90dcfd..ffa066b 100644 --- a/code/GridFieldBulkImageUpload.php +++ b/code/GridFieldBulkImageUpload.php @@ -1,23 +1,27 @@ gridField->Link(), 'bulkimageupload', $action); @@ -108,7 +118,7 @@ class GridFieldBulkImageUpload_Request extends RequestHandler { } /** - * Return a list of the GridField managed DataObject (HTML)Text, (HTML)Varchar and Enum fields + * Return a list of the GridField managed DataObject's editable fields: (HTML)Text, (HTML)Varchar and Enum fields * * @return array */ @@ -130,6 +140,7 @@ class GridFieldBulkImageUpload_Request extends RequestHandler { /** * Return the CMS edit field for a given name. As set in the GridField managed DataObject getCMSFields method + * * @param string $fieldName * @return FormField */ @@ -145,7 +156,8 @@ class GridFieldBulkImageUpload_Request extends RequestHandler { /** * Default and main action that returns the upload form etc... - * @return String Form HTML ??? + * + * @return string Form's HTML */ public function index() { @@ -229,8 +241,14 @@ class GridFieldBulkImageUpload_Request extends RequestHandler { * Create new DataObject and add image relation * returns Image data and editable Fields forms * + * Overides UploadField's upload method by Zauberfisch + * Kept original file upload/processing but removed unessesary processing + * and adds DataObject creation and editableFields processing + * + * @author Zauberfisch original upload() method + * @see UploadField->upload() * @param SS_HTTPRequest $request - * @return \SS_HTTPResponse + * @return string json */ public function upload(SS_HTTPRequest $request) { @@ -315,7 +333,7 @@ class GridFieldBulkImageUpload_Request extends RequestHandler { * Update a record with the newly edited fields * * @param SS_HTTPRequest $request - * @return String + * @return string */ public function update(SS_HTTPRequest $request) { @@ -339,7 +357,7 @@ class GridFieldBulkImageUpload_Request extends RequestHandler { * according to the ID sent from the form * * @param SS_HTTPRequest $request - * @return String JSON + * @return string json */ public function cancel(SS_HTTPRequest $request) { @@ -366,7 +384,7 @@ class GridFieldBulkImageUpload_Request extends RequestHandler { } /** - * Simple function taht replace the 'record_XX_' off of the ID field name + * Simple function that replace the 'record_XX_' off of the ID field name * prefix needed since it was taken for a pageID if sent as is as well as fixing other things * * @param array $data @@ -401,10 +419,15 @@ class GridFieldBulkImageUpload_Request extends RequestHandler { } /** + * Edited version of the GridFieldEditForm function + * adds the 'Bulk Upload' at the end of the crums + * * CMS-specific functionality: Passes through navigation breadcrumbs * to the template, and includes the currently edited record (if any). * see {@link LeftAndMain->Breadcrumbs()} for details. * + * @author SilverStripe original Breadcrumbs() method + * @see GridFieldDetailForm_ItemRequest * @param boolean $unlinked * @return ArrayData */