goellner / statamic-assets-organized

Organizes Statamic assets in subdirectories
MIT License
1 stars 1 forks source link

Error on Statamic 2.10.2 with fieldtype.js #2

Open roberttolton opened 6 years ago

roberttolton commented 6 years ago

Hi,

Have just installed this addon into a fresh Statamic 2.10.2 site, and am seeing this error in the JS console along with no fields rendered on the page:

fieldtype.js:56 Uncaught (in promise) TypeError: Cannot read property '0' of undefined

My Image field is setup like so:

image:
  type: assets_organized
  display: Image
  container: post_images
  folder: original
goellner commented 6 years ago

I just tested the addon with the newest Statamic version 2.10.3 and there is indeed a bug, when saving to another container.

Can't fix the bug right now, but will take a look in the next few days.

In the meantime you can try the addon within your main assets container, this should work fine.

roberttolton commented 6 years ago

Hi @goellner, I only have one assets container, which I guess would be the main one?

goellner commented 6 years ago

Following up after checking whats wrong:

You have setup your asset container as a private asset container and the addon doesn't work with private asset containers at the moment.

I don't know if you need to have a private asset container or not, but in case you don't need it, you can add a url to your asset container yaml.

In site/content/assets/ should be your post_images.yaml. In there add one extra line: url: /post_images if your asset folder is in the root of your directory and is named post_images of course.

Additional info about private asset containers: https://docs.statamic.com/assets#private-assets

mikemartin commented 5 years ago

@goellner I just ran into this same error when using the assets_organized field inside a grid.

Fieldset:

overview:
        display: false
        type: grid
        add_row: Add Image
        fields:
          images:
            display: Image
            type: assets_organized
            max_files: 1
            browse: true
            container: main
            folder: projects

Error:

Uncaught (in promise) TypeError: Cannot read property '0' of undefined
    at AssetsOrganizedFieldtype.ready (fieldtype.js:56)
    at AssetsOrganizedFieldtype.e._callHook (vue.common.js:8399)
    at AssetsOrganizedFieldtype.t (vue.common.js:9628)
    at AssetsOrganizedFieldtype.i (vue.common.js:9425)
    at AssetsOrganizedFieldtype.e.$emit (vue.common.js:9506)
    at AssetsOrganizedFieldtype.e._callHook (vue.common.js:8402)
    at a (vue.common.js:8361)
    at Array.forEach (<anonymous>)
    at GridFieldtype.i (vue.common.js:8349)
    at GridFieldtype.e.$emit (vue.common.js:9506)
mikemartin commented 5 years ago

@goellner I ran some tests with the assets_organized field inside the grid, it looks like it's saving the images but cannot display them.

Here's the Fieldset:

title: Organizer
fields:
  images:
    display: Images
    type: assets_organized
    container: main
    folder: organizer
  image:
    display: Single Image
    type: assets_organized
    max_files: 1
    folder: organizer
    container: main
  grid:
    display: Grid
    type: grid
    fields:
      grid_images:
        display: Images
        type: assets_organized
        container: main
        folder: organizer
      grid_image:
        display: Single Image
        type: assets_organized
        max_files: 1
        folder: organizer
        container: main

And the saved data

images:
  - /assets/img/organizer/test-with-grid/img_9156.jpg
image: /assets/img/organizer/test-with-grid/img_9123.jpg
grid:
  - 
    grid_images:
      - /assets/img/organizer/test-with-grid/img_8956.jpg
      - /assets/img/organizer/test-with-grid/img_8937.jpg
    grid_image: /assets/img/organizer/test-with-grid/img_8941.jpg
title: Test with Grid
id: ec2d5861-bcc8-484e-b443-b3321fb50859

Screenshot

screenshot 2018-11-05 20 58 51

Statamic version: 2.10.7 Local environment: Valet Browser: Chrome 70

andyra commented 5 years ago

I'm getting this same error with Statamic 2.11.9. I only have one asset container using the S3 driver. What other info can I provide that would help diagnose this? Thanks!

dannyuk1982 commented 4 years ago

Changing line 60 of the fieldtype.js to this should fix it if( this.data === undefined ) {

There seem to be some major bugs at least using with replicator fields though, I've spent a few hours today trying to fix but I'm not that sure what's going on with some of the code, especially :data.sync="data.assets" in the vue component I can't get my head around, and this seems to be causing some of the problems. Until/if the author can support this again I'm not sure it's usable sadly.

andrew-ireland commented 4 years ago

Also having trouble using the assets_organised field-type within a grid. The images are saved in the correct folder, but nothing is shown within the Control Panel.

Currently unusable for me as result, but I'll keep an eye out to see if this changes in the future.