silverstripe-asset-admin icon indicating copy to clipboard operation
silverstripe-asset-admin copied to clipboard

getMinimalistObjectFromData removed the "url" field

Open lekoala opened this issue 4 years ago • 5 comments

Would it be possible to add it back ?

it was removed here https://github.com/silverstripe/silverstripe-asset-admin/commit/bbe7c660cf40d4c942eaf6e76755eeaf46c63471

I was relying on that to make clickable thumbnails (if you click on the icon, it opens directly the file, without having to open the file manager modal). I don't see a good reason to NOT expose that information.

lekoala avatar Aug 31 '21 14:08 lekoala

or add an extension point that would work for me as well (would even be better actually)

lekoala avatar Aug 31 '21 14:08 lekoala

as a side note, injecting a custom instance of AssetAdmin like this

SilverStripe\Core\Injector\Injector:
  SilverStripe\AssetAdmin\Controller\AssetAdmin:
    class: LeKoala\Base\Admin\BaseAssetAdmin

Fails as well as it gives this js error

bundle.js?m=1624034376:1 Uncaught TypeError: Cannot read property 'url' of undefined

which points to

        var e = s.default.getSection("SilverStripe\\AssetAdmin\\Controller\\AssetAdmin");
            l.default.add({
                path: "/",
                routes: [{
-->                path: "/" + e.url + "/show/:folderId/:viewAction/:fileId",
                    component: u.default
                }, {

I expect it's because the class name is hardcoded there?

lekoala avatar Aug 31 '21 15:08 lekoala

In the meantime, this can be fixed by replacing the UploadField instance and adjust the getEncodedItems but still i'm a bit sad to discover this issue after upgrading to the new version

lekoala avatar Aug 31 '21 15:08 lekoala

Can you use getObjectFromData?

michalkleiner avatar Aug 31 '21 21:08 michalkleiner

@michalkleiner sure ! but it's not what is used by the UploadField by default.

https://github.com/silverstripe/silverstripe-asset-admin/blob/96b13878164ba6e25f449df7eb04f1aa61dea3f4/code/Forms/UploadField.php#L215

so i have to replace the uploadfield instance with a custom one that use getObjectFromData. So indeed, either we add back the url to getMinimalistObjectFromData (just reading the plain url should not be a big burden) or update the UploadField.

lekoala avatar Sep 01 '21 08:09 lekoala