colymba / gridfieldbulkeditingtools Goto Github PK
View Code? Open in Web Editor NEWSilverStripe GridField Components set for bulk upload and bulk record edit, unlink & delete :package::boom:
License: BSD 3-Clause "New" or "Revised" License
SilverStripe GridField Components set for bulk upload and bulk record edit, unlink & delete :package::boom:
License: BSD 3-Clause "New" or "Revised" License
here you are the error log when uploading 2 files:
[04-Jul-2013 15:19:07] Error at framework/core/Core.php line 366: singleton() Called without a class (http://sstest.zk/admin/pages/edit/EditForm/field/Gallery/bulkimageupload/upload?locale=it_IT)
[04-Jul-2013 15:19:07] Error at framework/core/Core.php line 368: singleton() passed bad class_name: NULL (http://sstest.zk/admin/pages/edit/EditForm/field/Gallery/bulkimageupload/upload?locale=it_IT)
[04-Jul-2013 15:19:07] Error at framework/control/injector/Injector.php line 847: Uncaught ReflectionException: Class does not exist (http://sstest.zk/admin/pages/edit/EditForm/field/Gallery/bulkimageupload/upload?locale=it_IT)
[04-Jul-2013 15:19:08] Error at framework/core/Core.php line 366: singleton() Called without a class (http://sstest.zk/admin/pages/edit/EditForm/field/Gallery/bulkimageupload/upload?locale=it_IT)
[04-Jul-2013 15:19:08] Error at framework/core/Core.php line 368: singleton() passed bad class_name: NULL (http://sstest.zk/admin/pages/edit/EditForm/field/Gallery/bulkimageupload/upload?locale=it_IT)
[04-Jul-2013 15:19:08] Error at framework/control/injector/Injector.php line 847: Uncaught ReflectionException: Class does not exist (http://sstest.zk/admin/pages/edit/EditForm/field/Gallery/bulkimageupload/upload?locale=it_IT)
My code is:
class ZkGallery extends DataExtension {
public static $has_many = array('Images' => 'ZkGalleryImage');
public function updateCMSFields(FieldList $fields) {
parent::updateCMSFields($fields);
$name = Config::inst()->get('ZkGallery', 'gallery_name');
// var_dump($name); exit;
if ($this->owner->ID > 0) {
$gridFieldConfig = GridFieldConfig_RecordEditor::create();
// $gridFieldConfig->addComponent(new GridFieldBulkImageUpload());
// $gridFieldConfig->addComponent(new GFBIUploadField('BulkGallery'));
$gridFieldConfig->addComponent(new GridFieldBulkImageUpload('Images', array('Title')));
$gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder'));
$gridfield = new GridField("Gallery", $name, $this->owner->Images()->sort("SortOrder"), $gridFieldConfig);
$fields->addFieldToTab('Root.'.$name, $gridfield);
}
return $fields;
}
public function ZkGalleryGetImages() {
return $this->owner->Images()->sort("SortOrder");
}
}
Hi,
i have an extended ImageClass and wnat to show gridfield_relatioeditor in the uploadview for every uploade item... i it possible?
Hi, how about transifex support?
Can you check if the Edit all button for GridFieldBulkUpload is actually working? I've tried everything, but when clicking on the button, absolutely nothing appears to happen.
Tried it on a fresh SS 3.1.5 install too with no joy.
Here is my test code: http://www.sspaste.com/paste/show/5373600e2f5bf
At least bare minimum....
Default back to "ClassName ID" for records without a title in bulk editing
Add a note about BulkAction's URL are strtolower(name)
.
Related to silverstripe/silverstripe-comments#79 (comment)
GridFieldBulkManager_Request.php $url_handlers
to static
as per #21
As in subject, if the OP press Enter instead of Tab or clicking "Save all" he's redirected to /update (404 not found)
Silverstripe 3.0.5
[Fri Jun 14 16:33:00 2013] [error] [client 81.62.232.166] PHP Fatal error: Access level to GridFieldBulkImageUpload_Request::$url_handlers must be public (as in class RequestHandler) in /var/www/vhosts/probiermau.ch/subdomains/hottrail/GridFieldBulkEditingTools/code/GridFieldBulkImageUpload_Request.php on line 491, referer: http://hottrail.probiermau.ch/admin/pages/edit/EditForm/field/MonkeeBlogEntries/item/7/ItemEditForm/field/GalleryImages/bulkimageupload?flush=1
I get that error in every uploadbar of a completly uploaded image.
Can't edit image details.
Have to go back to page via breadcrump
All images are displaed in gridfield and i can edit them
ss 3.0.2
It would be nice if the bulk upload could be limited to a certain number of concurrent uploads and if the bulk uploading would occur in the correct order (i.e. ordering by filenames).
Background: I'm using it for photo galleries, where it is a problem if a) the browser goes crazy trying to do all at once and b) uploads are placed more or less randomly (i.e. I have to order them all manually afterwards) when uploading, say, a few dozen photos.
Shouldn't GridFieldBulkImageUpload_Request.php, line 108 read:
$recordHasOneFields = Config::inst()->get($recordClass, 'has_one', Config::INHERITED);
Hello,
When I try to bulk upload files from exiting folder I get the popup but once I click on folder dropdown to select files from a different location I receive a 404 error with response:
"I can't handle sub-URLs of a CMSForm object."
Any idea why this is caused? Are you also experiencing this?
Thanks in advance!
dani quilez
Attempts to add a bulk manager to asset admin using the following code has some issues.
<?php
class AssetAdminExtension extends Extension {
public function updateEditForm(Form $form) {
$grid = $form->Fields()->dataFieldByName('File');
$config = $grid->getConfig();
$config->addComponent(new GridFieldBulkManager());
}
}
When editing a file, the "Folder" dropdown doesn't seem to work, with a 404 when attempting to ajax load foldernames. The 404 seems to come from the request to http://ss31test.loc/admin/assets/EditForm/field/File/bulkediting/BulkEditingForm/field/record_15_ParentID/tree
Is this a bug or a limitation of this module?
Hi folks,
i got some strange behaviour when using this module (latest version), when deploying it to live servers. Locally eveything works fine. Have you expierienced the same or someone has a clue whats going on. Thanks for help.
Here is theerrors stack trace:
Uncaught exception
TypeError
in onmatch on
Both Internet Explorer 10 & 11 fail when trying to upload more than one file using GridFieldBulkUpload:
SCRIPT5007: Unable to get property 'id' of undefined or null reference
It would seem that GridFieldBulkUpload doesn't work with any of the latest 4 IE versions. The file (or files) is added "From your computer", followed by the progress bar of the uploads which progresses all the way across but never completes. The user is also presented with a "Do you want to open or save [random-uploaded-filename] from [servername]?" which I suspect if related directly to the issue. Have tested on IE 8 (XP), 9 (Win 7), 10 (Win 7) and 11 (Win 8).
Only the first of any of the queued files is actually uploaded (seen only when clicking "Finish" button etc).
Tested with latest master as well as v2.0.1, both on SilverStripe 3.1.5 & 3.1.6. Works perfectly in Firefox & Chrome.
Hello There ! First of all Thank you so much for this module.
I am facing one strange issue with this module. Bulk upload is working fine on my local/staging server but when I am trying to use this on Live server it always showing "Please wait ... Upload in progress" (see screenshot). I can guess it may be something about server configurations but don't know what. Tested on Chrome/Firefox and same result. Can you please help me with this. I am sorry If its a wrong place to ask this question but couldn't find any other way and site have to go live today :(
Hi, i am using the latest SS branch (3.1) with translatable and the latest branch from GridFieldBulkEditingTools.
Bulk uploading is working fine. But the image ID's won't be saved to the DB field. The hidden field looks always like
the relations are set correctely. Any suggestions?
page.php:
private static $has_many = array(
'Seitenkopfbilder' => 'Seitenkopfbilder
);
$seitenkopfbildergridFieldConfig = GridFieldConfig_RecordEditor::create();
$seitenkopfbildergridFieldConfig->addComponent(new GridFieldBulkEditingTools());
$seitenkopfbildergridFieldConfig->addComponent(new GridFieldSortableRows('Sort'));
$seitenkopfbildergridFieldConfig->addComponent(new GridFieldBulkImageUpload());
$seitenkopfbildergridfield = new GridField("Seitenkopfbilder", "Seitenkopfbilder für den Content", $this->Seitenkopfbilder()->sort("Sort"), $seitenkopfbildergridFieldConfig);
Seitenkopfbilder.php:
'Varchar(100)', 'Sort' => 'Int' ); ``` static $has_one = array ( 'Seitenkopfbilder' => 'Image', 'Pagelink' => 'SiteTree', 'Page' => 'SiteTree' ); ``` public static $summary_fields = array( 'Thumbnail' => 'Thumbnail' ); static $searchable_fields = array( ); public function getThumbnail() { return $this->Seitenkopfbilder()->CMSThumbnail(); } public function getCMSFields() { ``` $KopfbildField = new UploadField( $name = 'Seitenkopfbilder', $Title = 'Seitenkopfbilder (642 * 335px)' ); $KopfbildField->allowedExtensions = array('jpg', 'png', 'gif'); $KopfbildField->setConfig('allowedMaxFileNumber', 1); $KopfbildField->setFolderName('Seitenkopfbilder'); $KopfbildField->setConfig('previewMaxWidth', 100); $KopfbildField->setConfig('previewMaxHeight', 100); $KopfbildField->setConfig('autoUpload', false); return new FieldList( $KopfbildField, new TextareaField('SEOalttext', 'ALT Text für das Bild. Sollte einen Bezug zum Inhalt der Seite haben.') ); ``` } }I have just updated to the latest version using composer, which has also updated CMS/Framework etc.
If I do a bulk upload, the images go into the assets/bulk-upload folder, they are added to Files properly, but on the actual CustomImage class I have made the 'BaseImageID' which is a has_one to Image always comes up as a '0', and on my gridfield the row has no thumbnail.
Any idea why this is happening? If I use the standard add button everything works as expected.
When adding the Bulk editing tools for the comment module requirements the following error is displayed in the admin section:
GridFieldBulkManager::addBulkAction() must be an instance of string, string given, called in /public_html/comments/code/CommentAdmin.php on line 60
A quick fix was to change line 184 in GridFieldBulkManager.php from:
function addBulkAction( string $name, $label = null, $handler = null, $config = null)
to:
function addBulkAction($name, $label = null, $handler = null, $config = null)
It needs further testing but got the modules working together for me...
This errors are fired uploading files:
[30-May-2013 12:34:50] Error at framework/forms/UploadField.php line 511: UploadField->setConfig called with invalid option: 'sequentialUploads' (http://aaa.zk/admin/pages/edit/EditForm/field/GalleryImages/bulkimageupload?flush=all)
[30-May-2013 12:34:50] Error at framework/forms/UploadField.php line 511: UploadField->setConfig called with invalid option: 'url' (http://aaa.zk/admin/pages/edit/EditForm/field/GalleryImages/bulkimageupload?flush=all)
There seems to be a problem with using several GridFieldBulkEditingTools on one page - I can't get bulk editing/delete to work. My guess is that the javascript and PHP code assumes there's only one active instance at one time, since it creates buttons etc with non-unique IDs, which it then uses to hook up events and actions to. The "doBulkActionButton" button is one example. If I create two or more GriedFieldBulkEditingTools on a page, there will be several elements with the same IDs, which the javascript code doesn't seem to take into account. Is there a fix for this?
bulk upload/manager do not seem to work when the relation managed by the GridField is of type $many_many
Looks like a really interesting module, but I suspect that I would get a much better idea of how it works by looking at a screenshot or two :)
At example when trying to add the GridFieldBulkManager to Comments:
$commentsConfig = GridFieldConfig::create()->addComponents(
...
new GridFieldBulkEditingTools(),
new GridFieldBulkManager()
);
$needs = new GridField(
'Comments',
_t('CommentsAdmin.NeedsModeration', 'Needs Moderation'),
Comment::get()->where('Moderated = 0'), // only Moderated records!
$commentsConfig
);
This code will show only 'Moderated=0' records but checking the 'Select all' will mark 'Moderated=1' as well.
Unfortunately I don't have a workaround now.
Got an error when saving bulk editing tool:
[18-Jun-2014 12:08:46] Error at framework/model/DataObject.php line 2367: DataObject::setCastedField: Called without a fieldName
The problem seems to come from GridFieldBulkActionEditHandler.php, line 199.
I changed $field->Name = 'record_' . $id . '' . $name;
for $field->Name = 'record' . $id . '_' . $field->getName();
Seems to work for now, any ideas?
I have a GridFieldBulkUploadField with a GridFieldBulkManager that manages uploading pdf files. Each file when uploaded has to be assigned to a particular user. I see the checkboxes for available users but when I click the checkbox it is not saved. I can see in the Firebug console that the data being sent to the server only includes the ID of the File and the Title. The File Object has a $belongs_many_many relationship to the Member subclass that has the $many_many defined on it. Granted I have made my own version of GridFieldBulkUploadField to add 'allowedExtensions' to the config so I can pass it into the UploadField class instance. Is there a callback that I can use to write code to save my custom relation?
I think, for a lot of people, adding the old names, like GridFieldBulkImageUpload() back, would save a lot of people some headaches.
You probably broke a few websites by renaming it, thus a fallback to catch those (optionally, with a warning in dev-mode) could save lives ;)
I am running with 3.1beta3 and the current master of this module. I have run into a problem where the method setDownloadTemplateName cannot be found. Grepping the entire codebase of SilverStripe including your module, it only appears once
grep -rIn setDownloadTemplateName .
./gridfieldbulkeditingtools/code/GridFieldBulkImageUpload_Request.php:216: $uploadField->setDownloadTemplateName('colymba-gfbiu-uploadfield-downloadtemplate');
when uploading images in combination with sortablegridfield
i get this text:
Please wait… upload in progress
followed this tutorial:
http://www.silverstriperesources.com/articles/how-to-make-a-photo-gallery-in-silverstripe-3/
also note that the title textifelds are not nicely aligned:
http://postimage.org/image/eo1hfzpeb/
See http://semver.org. It makes it unnecessarily hard to include the module because of the non-numeric branch name, which composer doesn't like. Logical branch name would be 0.4, or maybe even the 3.0 compatible master merged into the existing 0.3 branch
Latest git version does not support "bulk" upload (it is possible upload files only one by one). Problem is hidden in UploadField injection where is not possible control how many files user is able to upload (? missing settings?), when you manually add ->setConfig('allowedMaxFileNumber', 5) (https://github.com/colymba/GridFieldBulkEditingTools/blob/master/bulkUpload/code/GridFieldBulkUpload.php#L162) to function bulkUploadField you are able to upload multiple files.
Template looks OK (there is inherited variable $multiple).
Add UploadField's allowedExtensions
config as an option.
Or find a way to expose the UploadField's configs...
My getCMSFields() function returns dropdowns for a $has_one relationship and checkboxes for a $many_many, but all I get are the text fields for the $db fields.
Is there a way to get the file edit form to just return the getCMSFields() FieldList?
Hi,
Updated the dutch language awhile ago, any chance to merge those from transifex?
Thanks in advance!
If I add a GridFieldBulkImageUpload to a gridfield it will often get stuck on the loading stage when I click on the button, or will go to a screen without the drag and drop, see picture:
What seems to cure this problem is to either add an UploadField to the same page, or view a different page with an UploadField beforehand during the session.
I am using MAMP, but have also seen this issue on a remote server.
I installed https://github.com/OpticBlaze/ss3Gallery in order to test the bulk uploading facilities that this module provides. As the website I am doing is in Thai locale, I set it to Thai by default. However saving fails with this error:
ERROR [User Error]: Uncaught InvalidArgumentException: Invalid locale "th_TH?cacheBuster=1358328497853_BIUUF_8"
IN POST /admin/pages/edit/EditForm/field/GalleryImages/bulkimageupload/update?locale=th_TH?cacheBuster=1358328497853_BIUUF_8
Line 319 in /home/gordon/work/git/weboftalent/proudbags/www/translatable/code/model/Translatable.php
The addition of the cachebuster paramater does not take into account the possible existence of a locale parameter
DataObject
public function getCMSFields() {
$thumbField = new UploadField('Image', 'Gallery Image');
$thumbField->allowedExtensions = array('jpg', 'png', 'gif', 'bmp', 'jpeg');
return new FieldList(
new TextField('Caption', 'Caption'),
new TreeDropdownField('Link', 'Page to link to', 'SiteTree'),
$thumbField
);
}
Gives a JSON error.
Very nice module!
Though i'm having some trouble when using it together with Translatable.
Downloaded and installed GridFieldBulkEditingTools version from today, just now.
I have translated Pages with untranslated Dataobjects.
In backend when using the bulk editor i get an "Internal Server Error".
Refreshing the page with the generated URL gives this error:
Uncaught InvalidArgumentException: Invalid locale "de_DE/edit?records[]=1".
The generated URL seems looks like this:
http://mydomain.com/admin/pages/edit/EditForm/field/CampaignImages/bulkediting?locale=de_DE/edit?records[]=1&records[]=2&records[]=3
Other modules using previous branches of GridFieldBulkEditingTools reference class GridFieldBulkEditingTools. for example the SS3 gallery module: http://www.silverstriperesources.com/articles/silverstripe-3-gallery-plugin-module/
As this is now missing from the latest branch these other dependant modules no longer function... Is the GridFieldBulkEditingTools.php supposed to be missing and if so should the code include deprecated methods to allow for other older dependant modules...
Please see Silverstripe Forum enquiry: http://www.silverstripe.org/all-other-modules/show/20465?start=56
Hi,
I try to use your module to add attach multiple images to a DataObject and make it managable via ModelAdmin. Here is my summarized model code:
class Client extends DataObject {
private static $db = array();
private static $has_many = array(
"Pictures" => "Image"
);
function getCMSFields($params = null) {
$conf = GridFieldConfig_RelationEditor::create();
$conf->getComponentByType('GridFieldPaginator')->setItemsPerPage(20);
$conf->addComponent(new GridFieldBulkImageUpload());
$gridField = new GridField('Pictures', 'Pictures', $this->SortedPictures(), $conf);
$dataColumns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
$dataColumns->setDisplayFields(array(
'Title' => 'Title',
'LastEdited' => 'Changed',
'CMSThumbnail' => 'Preview',
));
$fields->addFieldsToTab('Root.Pictures', array(
$gridField,
));
return $fields;
}
function SortedPictures() {
return $this->Pictures()->sort("Sort", "ASC");
}
}
Image
is extended with:
class ClientImageExtension extends DataExtension {
private static $belongs_to = array(
"Client" => "Client",
);
private static $has_one = array(
"Client" => "Client",
);
}
The pictures are uploaded correctly to the given folder, but not attached to the record (Client). The upload response is:
ERROR [Notice]: Undefined index: id
IN POST /…/admin/studio/Client/EditForm/field/Client/item/5/ItemEditForm/field/Pictures/bulkimageupload/upload
Line 365 in /…/gridfield-bulk-editing-tools/code/GridFieldBulkImageUpload_Request.php
Source
======
356: $uploadField = $this->uploadForm()->Fields()->fieldByName($fileRelationName);
357: $uploadField->setRecord($record);
358: $uploadResponse = $uploadField->upload( $request );
359:
360: //get uploaded File response datas
361: $uploadResponse = Convert::json2array( $uploadResponse->getBody() );
362: $uploadResponse = array_shift( $uploadResponse );
363:
364: // Attach the file to record.
* 365: $record->{"{$fileRelationName}ID"} = $uploadResponse['id'];
366: $record->write();
367:
368: // attached record to gridField relation
369: $this->gridField->list->add($record->ID);
370:
371: //get record's CMS Fields
What am I doing wrong? Did I miss to declare a relationship type in one of these models or is there a lack of configuration? Or is it not possible to handle has_many
relations with bulk upload (I couldn't find s.th. related in the docs)?
Best regards
Philipp
When a user has uploaded several images via GridFieldBulkUpload, and then clicked the Edit All button to update a field such as a caption for all the images, upon then clicking the Save All button, it would be nice to return the user back to the gridfield. As the current workflow for this doesn't seem very streamlined.
In my newsmodule, enabling the Image-editor gives me errors. It breaks when I try
$gridFieldConfig->addComponent(new GridFieldBulkImageUpload());
Giving the error "Error at framework/model/UnsavedRelationList.php line 290: Uncaught LogicException: alterDataQuery can't be called on an UnsavedRelationList. (admin/news/News/EditForm/field/News/item/new)"
Do you have any clue what might cause this? I can occasionally reproduce this, seems to be related to another module (maybe?)
I've had a few clients click the 'Finish' button before uploading has completed, due to a couple of reasons:
To solve these issues, and make it instantly obvious at a glance what's happening, I suggest:
When batch uploading several images, they seem to display in alphabetical order while they are uploading, but upon clicking "Finish" they end up being saved in a random order.
Ideally the precise order would be a config option, but alphabetical by name seems good default, and certainly better than the current (random?) order.
Thanks.
Hi,
I'm considering bulk editing for the commenting module and would love to build on top of your work rather than reimplement bulk editing just for comments. The only thing I need to do is provide custom actions to bulkActionName (i.e Mark as Spam, Mark as Moderation) along with the respective backend functionality for those.
Wondering if that is on the cards for the module, can't imagine a 'nice' API for it rather than subclassing request, bulk manager and the JS. GridFieldBulkManager()->addBulkAction($name, $title, function($action) { });
Keen to check on your approach / thoughts.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.