This seems like it was far too easy... but everything in my initial testing works. Uploading works, “From files” works, editing an inserted link works, the UploadField edit form works.
Still need to do some more cross-browser testing, but wanted to get this on here now in case I’ve missed something glaringly obvious which would explain why it’s almost too simple 😉.
Sorry for the stupidly large screenshots.
Okay, so the glaringly obvious thing that I missed is that editing an existing link doesn’t work. Not sure of the best approach though, attaching the file to the UploadField after the dialog has loaded results in an extra delay. Ideally, we’d post the file ID when loading the dialog (LinkForm), but then we’d need to AJAX load the form again every time the dialog is opened.
If #2914 is merged we could trigger an attach and show the loading indicator after opening the form. There would be a slight delay, but as mentioned above: we're not ajax loading the LinkForm each time so I can't see any way around this. Anyone else have any bright ideas? :)
I'd prefer to have the UploadField loaded once the dialog opens, rather than the whole form. Not sure if its possible to pass through an ID to a ajax request to UploadField->FieldHolder yet though
That makes sense, but I think you’re right in that it’s not currently possible to pass in an ID like that. Do you have any feedback on this vs. #2976? You can insert any file with any extension using the MediaForm, which seems wrong to me, but could we make use of that existing AssetUploadField functionality for this somehow?
bump. With #2914 merged this looks a bit nicer now. Does this seem like a good solution? Also, can anyone spot a way of ensuring the UploadField has initialised without using setTimeout (I hate myself for submitting a pull request with that in).
Looks like this feature is getting quite a few votes on uservoice: http://silverstripe.uservoice.com/forums/251266-new-features/filters/top
So it is! I’ll take another look at this soon and try to get it cleaned up ready for merging.
Just to clarify: the PR in its current form will show either the empty UploadField or, if a file has already been added, the ‘attaching’ indicator from #2914 until the details of that file have been loaded in.
This is what users will see when picking an item from the CMS, or editing an existing file link (while it loads the info):
There’s another issue in that users can insert links such as [file_link,id=undefined], but the same issue applies to editing any other links too: inserting a blank/empty link still adds an anchor, it should probably just discard it.
Also, the “Remove link” button (inside the link dialog) doesn’t appear to be working for any links. That’s a separate issue though.
NEW: Files can be uploaded directly in the 'Insert Link' form
Rebased this, tests are passing now but there were one or two other changes that crept in during the rebase. I think I rooted them out properly, but I’m yet to double check. Kinda need other devs to review the functionality and see what they think - not sure if the delay while the file loads is too intrusive.
hey @kinglozzer are you still actively looking at this feature? I'm keen to set the flag on UserVoice for this one officially to "Started" given your awesome amount of work on this so far :)
Hey @camfindlay. I’m still happy to work on it, but I’m not sure there’s anything else I can do for now. I’m just really waiting to see whether people think that the delay while the file is attached to the UploadField is acceptable!
ok cool, so you are looking for a big of peer review? Might be good if you go update the mention about it on UserVoice given it has a good number of votes you might get some traction 👍
I've just had a good play with this and I think it works great! I've got no issues with the very slight delay when editing an existing link, and as it displays a loading indicator it's clear what's it's doing.
This looks great—is it better merged into 3.1 or master?
I’m thinking this might be better in master. It shouldn’t be a BC-breaking change, but I guess if someone applied an extension to HtmlEditorField_Toolbar expecting to encounter a TreeDropdownField it could cause some issues. Heck, it could probably be merged into master and broken out as a module for 3.1 for anyone desperate for it :)
One note is that '/Uploads' might not be where I want the file to upload. Is it possible to change this folder to point to somewhere else via the CMS? A drop down could help here?
That’s a fair point @mandrew, it should be fairly easy to integrate the selectupload module to handle this, though I haven’t tested it. The module already adds a dropdown for “insert media”, which also defaults to /Uploads for uploading images :)
I’ve packaged this up into a module for 3.1: https://github.com/kinglozzer/htmleditoruploadfield. When I get round it it I’ll reopen this against master, unless anyone else fancies taking this on or has any other ideas for how to approach this :)
Would love for this to get into the new 3.2 beta! :)
See #4249 (comment)