Skip to content

Advanced View List Header Labels #16

@jordanstephens

Description

@jordanstephens

Hello!

I'm investigating adding support for specifying the label to display in the advanced view list's collapsible header. For example, in the image below, I might like to replace "SKILL - 1" with "Ruby."

advanced_view_object

I'm planning to open a PR with the changes I make, so I want to try to make a change that you might merge upstream.

While investigating how I might add support for this, I noticed in this file app/views/fields/jsonb/_hash.html.erb:

<% structure.each do |sk, sv| %>
  <% if sv.is_a?(Hash) %>
    <dt class='attribute-label administrate-field-jsonb-accordion'><%= sk.to_s.titleize %></dt>
    <dd class='administrate-field-jsonb-panel'>
      <dl class='administrate-field-jsonb-box'>
        <% if data[sk].is_a?(Array) %> <% # <------------------ when is this branch triggered? %>
          <%= render field.to_partial_path('array'),
            field: field, structure: structure[sk], data: data[sk], label: sk.to_s.singularize.titleize %>
        <% else %>
          <% # ... %>
        <% end %>
      <dl>
    </dd>
  <% else %>
    <% # ... %>
  <% end %>
<% end %>

While iterating over the hash attributes, you check if sv.is_a?(Hash), then later in that same block you check if data[sk].is_a?(Array). It's not clear to me how this branch of code gets executed.

I don't see any examples in the README that have a hash value in the structure, and I don't see any tests at all. Would it be possible for you to provide an example configuration which would exercise this branch?

If I extend the API to support array header labels, I want to try my best to do it in a backwards compatible way. 👍

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions