prismicio / slice-machine

A series of tools for developing and deploying website sections with Prismic
https://prismic.io/docs
Apache License 2.0
287 stars 53 forks source link

Group field has no config.repeat value in Slicemachine UI #1255

Closed stefan-garofalo closed 9 months ago

stefan-garofalo commented 10 months ago

Versions

Steps to reproduce

instantiating a group field in a document's static zone

What is expected?

when editing the field to set things like placeholder and label, there should also be a repeatable value, since as stated in the docs it holds a config.repeatable https://prismic.io/docs/field#group

What is actually happening?

I want to group my static fields and organise them in a better structure, but currently I am limited to arrays only in the slicemachine UI, and cant create objects

image
stefan-garofalo commented 10 months ago

Also I want to add that:

as stated in the docs

image

I tried modifying the index.json inside customtypes

      "grid": {
        "type": "Group",
        "config": {
          "label": "Grid",
          "fields": { ... },
          "repeat": false
        }
      },

but when i pushed the changes i still could see the add item button in prismic.io builder

xrutayisire commented 9 months ago

Hi, sorry for the delay.

Thank you for the detailed issue. Good catch, it's a missing feature for Slice Machine and also the new Page Builder. What you did by modifying the model works and when the fix on the Page Builder is done, you will not have the Add button anymore.

We are going to fix it in both Slice Machine and the new Page Builder, so you should expect to see the changes in the upcoming weeks.

I will keep you updated here.

stefan-garofalo commented 9 months ago

Thanks for the replying. I'd be happy to contribute to this issue if help is needed

xrutayisire commented 9 months ago

We just released a new Page Builder version! You should now see in the next hours that the button to add to a group with repeat: false is not visible anymore 🙂

We will release w fix for Slice Machine next week.

stefan-garofalo commented 9 months ago

Hello, I do confirm that the Page Builder correctly hides the repeat button Although the field is set to non repeatable the API sill responds with an array

console.log(page.data.grid)

[
  {
    image: {
      alt: 'a close up of a metal structure with mirrored balls on it',
      copyright: null,
      url: 'https://images.unsplash.com',
      id: '8BcYAgdo1Ac',
    },
    title: 'Elevating Energy: Pioneering a Future of Sustainable Brilliance.',
    link: {
      link_type: 'Web',
      url: 'https://www.google.com',
      target: '_blank'
    },
    title_link: 'Curious to contribute to the future of sustainable energy?'
  }
]

Is this desired or should it return just a plain object instead?

xrutayisire commented 9 months ago

We just released the fix on Slice Machine side to let you configure repeat: false.

Is this desired or should it return just a plain object instead?

Yes, today our model return an array that will always have only one entry if you correctly setup the repeat: false property. We could improve the type, but it's not yet planned.

Is it a blocker in some ways for you?

stefan-garofalo commented 9 months ago

I just updated slicemachine and indeed it works!

Is it a blocker in some ways for you?

No dont worry, I was just asking out of curiosity. I guess this issue can now be closed for good

xrutayisire commented 9 months ago

Great! Thank you for your patience 🙂