Ticket #2531877 (closed enhancement)
ReporterBrad Kusnir |
Opened: 03/9/12 Last modified: 08/1/12 Status: closed Type: enhancement Resolution: fixed |
Owner Allen Rabinovich |
Target Release: 3.6.0 Priority: P3 (normal) |
|---|---|---|---|
| Summary: | File List Manipulation | ||
| Description: | There is no mechanism to control and manipulate the built in (multiple) file list that the uploader control uses. You can add files, but you cannot remove them. It is pretty easy to add an event to |
||
| Type: | enhancement | Observed in Version: | 3.5.0pr2 |
| Component: | Uploader | Severity: | S3 (normal) |
| Assigned To: | Allen Rabinovich | Target Release: | 3.6.0 |
| Location: | Priority: | P3 (normal) | |
| Tags: | Relates To: | ||
| Browsers: | N/A | ||
| URL: | |||
| Test Information: | /*
// event listener to watch if file list changes /*
myuploader.before("fileListChange", function (ev) { /*
Y.one("#clearAllButton").on("click", function () { /*
// returns number of files being uploaded so backend aggregator knows when all files have been received via async XHR xfer |
||
Change History
|
Posted: 03/27/12
|
|
Posted: 03/30/12
|
|
Posted: 04/7/12
Hey Allen sorry for the delayed response - I am just getting to this now. I am very close to replacing my previous HTML4/CSS2/POJO solution with the YUI 3.5pr2 HTML5 uploader control (with Flash fallback). As for your suggestion I think that could work. Would be nice to have a method you can call to basically just say "remove element with fileID X" or maybe include a simple file number attribute that could be referenced similarly? The requirement I am struggling with is that if before a user submits a batch for upload, if they decide they want to remove one of the files in the list this is not easily accomplished. It would be very nice if there was a built in facility to accomplish this - right now the only thing that's easy to do is clear the array entirely: // clear file list array But perhaps I just need to look into handling this within my own code but not sure how to reference the file list object directly... I assume there is a corresponding get method that I can call, copy to an array var, work with it, and then use the set method again. I also find myself using the before/after list change function to perform validations (i.e. iterating through to count number of total files, parse extensions, file sizes). I don't think this is the proper / most efficient way to go about this... |
|
Posted: 05/8/12
This will become either a property instead of an attribute, or we'll add convenience methods for managing the attribute (removeFiles, get items at index, etc.). |
|
Posted: 05/8/12
|
|
Posted: 05/10/12
Awesome! Here is what I ended up doing to implement this: // clear a single file // draw file list // clear file list output Y.each(myuploader.get("fileList"), function (value, fileNum) { // TO DO: consider adding TOTAL filesize //// event listeners // event delegate for "Clear" link |
|
Posted: 06/9/12
There's now a private property _fileList which, if strictly necessary, can be manipulated directly. It's still recommended to retrieve the fileList by calling get("fileList"), manage it directly as an array, and then set("fileList") back, but a direct manipulation option is also available. Additional array manipulation helper methods will be added in future releases. |
|
Posted: 08/1/12
Shipped in 3.6.0. Marking closed/fixed. |
Brad, it sounds like the best and easiest way to go about this is to make fileList a property, rather than an attribute? What do you think? I can have the attribute shadow the property, but otherwise you'd be able to directly manipulate the property like a regular array.