PagesDialog for Editor-Block-Plugin

Hello everybody,

I am trying to build a kirby editor block where one can select a page (in the case child pages from the page “readers”). So far, my code for the pages dialog looks like this.

 this.$refs.pagesDialog.open({
 endpoint: 'pages/readers/children',
 multiple: false,
 search: false,
 selected: [this.attrs.id]
 });

But the Dialog now looks like this:

The objects in the received collection are missing the fields “text” and “image”. What would be the recommended way to query the pages?

Hi there,

Have you found the solution?
Let me know.

Thanks.

Hello!

I now use a normal api request to get the pages, set the text and image fields of the array and then hand the array over to the dialog component. It works for my project right now, but its not a clean solution i guess. :grimacing: Also, because some build in dialog-functionality (searching etc.) does not work when you do it like that.

this.$api.get('pages/readers/children?select=id,num,title,url,files').then(response => {
    const data = response.data.map(element => {
      const elementData = {
        ... element,
        'text': element.title
      }

      if (element.files[0]) {
        elementData.image = {
          ratio: '1/1',
          cover: true,
          back: 'white',
          url: element.files[0].url
        }
      }
      
      return elementData
    })
    this.$refs.readerDialog.open(data, {
      multiple: false,
      parent: 'readers',
      search: false,
      selected: [this.attrs.id]
    });
  });
},