Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish state of owned files/images not visible without reload #1294

Closed
MLindenhofer opened this issue Sep 27, 2022 · 7 comments
Closed

Publish state of owned files/images not visible without reload #1294

MLindenhofer opened this issue Sep 27, 2022 · 7 comments

Comments

@MLindenhofer
Copy link

MLindenhofer commented Sep 27, 2022

Hi everybody,

I'm using version 1.10.4 of the asset-admin module. There seems to be a bug, after uploading an image/file and hitting save the DRAFT state does not upload to PUBLISH in the CMS Backend, which should happen for fields which are list in the $owns-variable.

In this project we use Colymba\BulkUpload\BulkUploader, but the bug is also happening for common UploadFields too.

Here's how I set up my field and relation inside my class:

private static $has_many = [
        'Downloads' => DownloadItem::class
    ];

    private static $owns = [
        'Downloads'
    ];

//Field with BulkUploader 
 $bulkUploader = new BulkUploader();
            $bulkUploader->setUfSetup('setFolderName', $this->getBulkUploadFolderName());
            $downloadConfig->addComponent($bulkUploader);

DownloadItemClass-File:

private static $has_one = [
        'File' => File::class,
    ];

private static $owns = [
        'File'
    ];

Thank you

@GuySartorelli
Copy link
Member

GuySartorelli commented Sep 27, 2022

Note: this should have been resolved by #1263

How are you seeing up the upload field for these models?

@MLindenhofer
Copy link
Author

The field is created here https://github.com/colymba/GridFieldBulkEditingTools/blob/1c5ae8a047d7763cfd27b7f6c36289fc83865d35/src/BulkUploader/BulkUploader.php#L242

BulkUploadFIeld is just an Extension on the normal UploadFIeld:
https://github.com/colymba/GridFieldBulkEditingTools/blob/master/src/BulkUploader/BulkUploadField.php

Here is an example from another Project with a normal UploadField (asset-admin version 1.8.0):

   private static $has_one = [
        'Image' => Image::class,
        'Video' => File::class
    ];

    private static $owns = [
        'Image', 'Video'
    ];

   if($this->Type === "image") {

                $fields->insertAfter('Type',
                    UploadField::create('Image')
                        ->setIsMultiUpload(false)
                );

            } elseif($this->Type === "video") {

                $fields->insertAfter('Type',
                    UploadField::create('Video')
                        ->setIsMultiUpload(false)
                        ->setAllowedExtensions(['mpeg', 'mpg', 'mp4', 'avi', 'wmv'])
                );

@GuySartorelli
Copy link
Member

Hmm okay. You said this happens when you don't use bulk uploader, can you please give an example of that instead? It should be simpler and therefore reduce the number of possible causes of this bug.

@MLindenhofer
Copy link
Author

That's the example from a project where I don't use BulkUploader, but a common UploadField

Asset-Admin: 1.8.0
CMS: 4.8.0

We have to do a reload for the state shown correctly and this happens in nearly every project I've been working on in SS4.

 private static $has_one = [
        'Video' => File::class,
        'BackGroundImage' => Image::class
    ];

  private static $owns = [
        'Video',
        'BackGroundImage',
        'HeaderIcons'
    ];

//in getCMSFields():

  UploadField::create( 'BackGroundImage',
                    _t(
                    'CromaShop\Extensions\PageHeaderExtension.HeaderImage',
                    'Header Image'
                    ),
                ),

$fields->addFieldToTab(
                'Root.Main',
                UploadField::create(
                    'Video',
                    _t('CromaShop\Elements\VideoElement.VideoTitle', 'Video')
                )
                ->setFolderName('Videos')
                ->setAllowedExtensions('mp4');

@GuySartorelli
Copy link
Member

As mentioned, that should be fixed in asset-admin 1.10.3, and you've indicated that these examples are from an earlier version than that. Can you please try updating to asset-admin 1.10.3 or later and say whether that fixes the problem?

@MLindenhofer
Copy link
Author

Updated it to CMS 4.11 and assets-admin 1.11.2 and now it works. Thanks for your help :)

@GuySartorelli
Copy link
Member

Okay cool. I'm going to close this now.
If the bulkloader example is still not working please open an issue in that module's issue tracker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants