nuxt / ui

A UI Library for Modern Web Apps, powered by Vue & Tailwind CSS.
https://ui.nuxt.com
MIT License
3.79k stars 463 forks source link

Nested attributes in objects #1800

Open max06 opened 3 months ago

max06 commented 3 months ago

Description

Hello there - sorry for the title, no idea how to phrase that....

There are multiple ui components taking an array of objects as input. In this case I want to talk about the SelectMenu.

<USelectMenu
  placeholder="Select an object"
  :options="flatObjects"
  option-attribute="name"
/>

This works great with flat objects. For unknown reason, I'm unable to specify a nested property (like metadata.name).

For these cases I have to create a computed, flat version of my original input array. Since I'm basically exclusively working with kubernetes manifests as input objects, I have to add a lot of wrappers for those.

I'm fine with that; however, I at least wanted to ask. 😅

Additional context

For reproduction, one of those objects, simplified:

  const specs = [{
    apiVersion: "some.api.io/v1alpha1",
    kind: "Spec",
    metadata: {
      creationTimestamp: "2024-02-26T13:42:36Z",
      generation: 3,
      name: "m1-small",
      namespace: "project",
      resourceVersion: "76533369",
      uid: "6567b033-b6fc-4ac7-ac56-1ed22853eea1"
    },
    spec: {
      disk: 20,
      ephemeral: 0,
      id: "5c48b89a-94b9-4e71-a838-69cdc09fb13e",
      name: "m1.small",
      public: true,
      ram: 2048,
      vcpus: 1
    },
    status: {
      status: "active"
    }
  }]
mrjakebaker commented 3 months ago

I have the same query but related to InputMenu component. I added a reproduction.

The docs say that search-attributes can be used with dot.notaton to access nested attributes, but it's not clear that it is only for the search-attributes until you try it out yourself. I would really like to be able to use it also for option-attribute and value-attribute to avoid unnecessary flattening when we have big nested objects.

Is this supported, or planned? Thanks :sunny:

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 30 days with no activity.

max06 commented 1 month ago

This issue is not stale.

github-actions[bot] commented 3 weeks ago

This issue is stale because it has been open for 30 days with no activity.

max06 commented 3 weeks ago

Nope, it's not...