In the files selector, let the user pick a page then a file inside that page

Hi, I’m trying to achieve a file picker where the user gets to select first a page, then a file inside this page folder.

Actually the field files doesn’t allow you to display pages and then files afaik. (?)
My workaround would be to first ask the user to pick a project, then based on that pick, generate a query for a pick of files inside that page folder.
Something that would look like that.

name: Image
icon: circle-filled

fields:
  project:
    type: pages
    query: site.find('projects').childrenAndDrafts
    label: Choisir un projet
    multiple: false

  image:
    type: files
    label: "AA {{ content.project }} "
    multiple: false
    layout: cards
    size: huge
    uploads: false
    query: "page.project.images"

Is this a good option there?

Apart from not being correct (should be page.project.toPage.images), this would only work with an intermediary step of saving the page before you could select the images from that page.

Thanks a lot for your reply.
(and I’m looking to make that work inside a block too, I just didn’t figured out how to access my block infos yet…)

I’ve been testing this way :

  debug:
    type: info
    text: |
      this.id: {{ $this.project }}
      parent.project: {{ parent.uid }}
      model.uid: {{ model.uid }}
      page.uid: {{ page.uid }}
      block.uid: {{ block.content.project}}
      content.uid: {{ content.project }}
      site.uid: {{ content }}

What would you suggest for my initial idea to work? Should I investigate a plugin?

The workaround solution that I found is to display :

image:
    type: files
    text: "{{ file.parent.title }} — {{ file.filename }}"

in order to be able to use the search box to search for a specific project name.