Skip to content

Commit

Permalink
Add collapsible attribute to lists (#1231)
Browse files Browse the repository at this point in the history
  • Loading branch information
newbthenewbd authored and rhukster committed Sep 26, 2017
1 parent bca7f7b commit 230bdcc
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions themes/grav/templates/forms/fields/list/list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
{% if field.fields %}
{% for key, val in value %}
{% set itemName = name ? name ~ '.' ~ key : key %}
<li data-collection-item="{{ itemName }}" data-collection-key="{{ key }}" class="{{ field.collapsed ? 'collection-collapsed' : '' }}">
<li data-collection-item="{{ itemName }}" data-collection-key="{{ key }}" class="{{ (field.collapsible is empty or field.collapsible) and field.collapsed ? 'collection-collapsed' : '' }}">
<div class="collection-sort"><i class="fa fa-fw fa-bars"></i></div>
{% for childName, child in field.fields %}
{% if childName starts with '.' %}
Expand Down Expand Up @@ -101,8 +101,10 @@
{% endif %}
{% endfor %}
<div class="item-actions">
<i class="fa fa-chevron-circle-{{ field.collapsed ? 'right' : 'down' }}" data-action="{{ field.collapsed ? 'expand' : 'collapse' }}"></i>
<br />
{% if field.collapsible is not defined or field.collapsible %}
<i class="fa fa-chevron-circle-{{ field.collapsed ? 'right' : 'down' }}" data-action="{{ field.collapsed ? 'expand' : 'collapse' }}"></i>
<br />
{% endif %}
<i class="fa fa-trash-o" data-action="delete"></i>
</div>
</li>
Expand All @@ -111,10 +113,12 @@
</ul>
{% if fieldControls in ['bottom', 'both'] %}
<div class="collection-actions">
<button class="button" type="button" data-action="expand_all"
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}><i class="fa fa-chevron-circle-down"></i> {{ "PLUGIN_ADMIN.EXPAND_ALL"|e|tu }}</button>
<button class="button" type="button" data-action="collapse_all"
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}><i class="fa fa-chevron-circle-right"></i> {{ "PLUGIN_ADMIN.COLLAPSE_ALL"|e|tu }}</button>
{% if field.collapsible is not defined or field.collapsible %}
<button class="button" type="button" data-action="expand_all"
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}><i class="fa fa-chevron-circle-down"></i> {{ "PLUGIN_ADMIN.EXPAND_ALL"|e|tu }}</button>
<button class="button" type="button" data-action="collapse_all"
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}><i class="fa fa-chevron-circle-right"></i> {{ "PLUGIN_ADMIN.COLLAPSE_ALL"|e|tu }}</button>
{% endif %}
{% if field.sortby %}
<button class="button{{ not value|length ? ' hidden' : '' }}" type="button" data-action="sort" data-action-sort="{{ field.sortby }}" data-action-sort-dir="{{ field.sortby_dir|default('asc') }}"
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}><i class="fa fa-sort-amount-{{ field.sortby_dir|default('asc') }}"></i> {{ btnSortLabel|e|tu }} '{{ field.sortby }}'</button>
Expand Down Expand Up @@ -163,8 +167,10 @@
{%- endif -%}
{%- endfor %}
<div class="item-actions">
<i class="fa fa-chevron-circle-down" data-action="collapse"></i>
<br />
{% if field.collapsible is not defined or field.collapsible %}
<i class="fa fa-chevron-circle-down" data-action="collapse"></i>
<br />
{% endif %}
<i class="fa fa-trash-o" data-action="delete"></i>
</div>
{%- endif -%}
Expand Down

0 comments on commit 230bdcc

Please sign in to comment.