ckan / ckanext-scheming

Easy, shareable custom CKAN schemas
Other
87 stars 163 forks source link

Option to display grouped metadata by relying on start_form_page #383

Open frafra opened 1 year ago

frafra commented 1 year ago

Hi, it would be nice to display metadata using the same groups defined while editing. A simple solution can be extending package_additional_info section in additional_info.html snippet to add an extra row to show the group title and description, if any:

https://github.com/ckan/ckanext-scheming/blob/8646a9dce79aa0b5a46274271ca6330dc0870b92/ckanext/scheming/templates/scheming/package/snippets/additional_info.html#L13-L17

This is an example on how to do it:

      {%- if field.start_form_page is defined -%}  
      </tbody>
    </table>
    <h3>Additional info - {{ field.start_form_page.title }}</h3>
    {%- if field.start_form_page.description is defined -%}
    <p>{{ field.start_form_page.description }}</p>
    {%- endif -%}
    <table class="table table-striped table-bordered table-condensed">
      <thead>
        <tr>
          <th scope="col">{{ _('Field') }}</th>
          <th scope="col">{{ _('Value') }}</th>
        </tr>
      </thead>
      <tbody>
      {%- endif -%}

This would not work with the main section though, as owner belongs to the excluded field, so a more complex logic should be implemented for that.

What are your thoughts on that?