|
24 | 24 | {% set actionMenuId = "matrixblock-action-menu--#{entry.uid}" %}
|
25 | 25 |
|
26 | 26 | {% set actionBtnAttributes = {
|
27 |
| - class: ['btn', 'settings', 'icon', 'menubtn'], |
| 27 | + class: ['action-btn', 'btn'], |
28 | 28 | type: 'button',
|
29 | 29 | role: 'button',
|
30 | 30 | title: 'Actions'|t('app'),
|
|
37 | 37 | }
|
38 | 38 | } %}
|
39 | 39 |
|
| 40 | +{% set actionMenuItems = [ |
| 41 | + { |
| 42 | + label: 'Collapse'|t('app'), |
| 43 | + attributes: { |
| 44 | + data: {icon: 'down-left-and-up-right-to-center', action: 'collapse'}, |
| 45 | + }, |
| 46 | + }, |
| 47 | + { |
| 48 | + label: 'Expand'|t('app'), |
| 49 | + attributes: { |
| 50 | + data: {icon: 'up-right-and-down-left-from-center', action: 'expand'}, |
| 51 | + }, |
| 52 | + liAttributes: { |
| 53 | + class: ['hidden'], |
| 54 | + }, |
| 55 | + }, |
| 56 | + { |
| 57 | + label: 'Disable'|t('app'), |
| 58 | + attributes: { |
| 59 | + data: {icon: 'circle-dashed', action: 'disable'}, |
| 60 | + }, |
| 61 | + liAttributes: { |
| 62 | + class: { |
| 63 | + hidden: not entry.enabled, |
| 64 | + }|filter|keys, |
| 65 | + }, |
| 66 | + }, |
| 67 | + { |
| 68 | + label: 'Enable'|t('app'), |
| 69 | + attributes: { |
| 70 | + data: {icon: 'circle', action: 'enable'}, |
| 71 | + }, |
| 72 | + liAttributes: { |
| 73 | + class: { |
| 74 | + hidden: entry.enabled, |
| 75 | + }|filter|keys, |
| 76 | + }, |
| 77 | + }, |
| 78 | + { |
| 79 | + label: 'Move up'|t('app'), |
| 80 | + attributes: { |
| 81 | + data: {icon: 'arrow-up', action: 'moveUp'}, |
| 82 | + }, |
| 83 | + }, |
| 84 | + { |
| 85 | + label: 'Move down'|t('app'), |
| 86 | + attributes: { |
| 87 | + data: {icon: 'arrow-down', action: 'moveDown'}, |
| 88 | + }, |
| 89 | + }, |
| 90 | +] %} |
| 91 | + |
| 92 | +{% if entry.id %} |
| 93 | + {% set actionMenuItems = actionMenuItems|merge([ |
| 94 | + {hr: true}, |
| 95 | + { |
| 96 | + label: 'Open in a new tab'|t('app'), |
| 97 | + url: entry.getCpEditUrl(), |
| 98 | + attributes: { |
| 99 | + target: '_blank', |
| 100 | + data: {icon: 'external'}, |
| 101 | + }, |
| 102 | + }, |
| 103 | + ]) %} |
| 104 | +{% endif %} |
| 105 | + |
| 106 | +{% if not staticEntries %} |
| 107 | + {% set actionMenuItems = actionMenuItems|merge([ |
| 108 | + {hr: true}, |
| 109 | + { |
| 110 | + label: 'Delete'|t('app'), |
| 111 | + destructive: true, |
| 112 | + attributes: { |
| 113 | + data: {icon: 'xmark', action: 'delete'}, |
| 114 | + }, |
| 115 | + }, |
| 116 | + {hr: true}, |
| 117 | + ]) %} |
| 118 | + |
| 119 | + {% for entryType in entryTypes %} |
| 120 | + {% set actionMenuItems = actionMenuItems|push({ |
| 121 | + label: 'Add {type} above'|t('app', {type: entryType.name|t('site')}), |
| 122 | + attributes: { |
| 123 | + data: {icon: 'plus', action: 'add', type: entryType.handle}, |
| 124 | + }, |
| 125 | + }) %} |
| 126 | + {% endfor %} |
| 127 | +{% endif %} |
| 128 | + |
| 129 | +{% namespace baseInputName %} |
| 130 | + {% set form = entry.getFieldLayout().createForm(entry, static) %} |
| 131 | + {% set tabs = form.getTabMenu() %} |
| 132 | +{% endnamespace %} |
| 133 | + |
40 | 134 | <div {{ attr(entryAttributes) }}>
|
41 | 135 | {% if not static %}
|
42 | 136 | {{ hiddenInput("#{name}[sortOrder][]", entry.uid) }}
|
|
46 | 140 | {% endif %}
|
47 | 141 | {{ hiddenInput("#{baseInputName}[type]", entryType.handle) }}
|
48 | 142 | {{ hiddenInput("#{baseInputName}[enabled]", entry.enabled ? '1' : '') }}
|
49 |
| - <div class="titlebar"> |
50 |
| - <div class="blocktype{% if entry.hasErrors() %} error{% endif %}"> |
51 |
| - {{ entryTypeName }} |
52 |
| - {% if entry.hasErrors() %}<span data-icon="alert" aria-label="{{ 'Error'|t('app') }}"></span>{% endif %} |
53 |
| - </div> |
54 |
| - <div class="preview"></div> |
| 143 | + {% endif %} |
| 144 | + |
| 145 | + <div class="titlebar"> |
| 146 | + <div class="blocktype{% if not static and entry.hasErrors() %} error{% endif %}"> |
| 147 | + {{ entryTypeName }} |
| 148 | + {% if not static and entry.hasErrors() %}<span data-icon="alert" aria-label="{{ 'Error'|t('app') }}"></span>{% endif %} |
| 149 | + </div> |
| 150 | + <div class="preview"></div> |
| 151 | + <div class="matrixblock-tabs"> |
| 152 | + {% namespace baseInputName %} |
| 153 | + {% if tabs|length > 1 %} |
| 154 | + {% include '_includes/tabs.twig' with {'tabs': tabs, 'containerAttributes': {'id': 'tabs'}} %} |
| 155 | + {% endif %} |
| 156 | + {% endnamespace %} |
55 | 157 | </div>
|
| 158 | + </div> |
| 159 | + |
| 160 | + {% if not static %} |
56 | 161 | <div class="checkbox" title="{{ 'Select'|t('app') }}" aria-label="{{ 'Select'|t('app') }}"></div>
|
57 | 162 | <div class="actions">
|
58 | 163 | <div class="status off" title="{{ 'Disabled'|t('app') }}">
|
|
63 | 168 | </div>
|
64 | 169 |
|
65 | 170 | <div>
|
66 |
| - <button {{ attr(actionBtnAttributes) }}></button> |
67 |
| - <div id="{{ actionMenuId }}" class="menu menu--disclosure"> |
68 |
| - <ul> |
69 |
| - <li><a data-icon="collapse" data-action="collapse" href="#" type="button" role="button" aria-label="{{ 'Collapse'|t('app') }}">{{ "Collapse"|t('app') }}</a></li> |
70 |
| - <li class="hidden"><a data-icon="expand" data-action="expand" href="#" type="button" role="button" aria-label="{{ 'Expand'|t('app') }}">{{ "Expand"|t('app') }}</a></li> |
71 |
| - <li{% if not entry.enabled %} class="hidden"{% endif %}><a data-icon="disabled" data-action="disable" href="#" type="button" role="button" aria-label="{{ 'Disable'|t('app') }}">{{ "Disable"|t('app') }}</a></li> |
72 |
| - <li{% if entry.enabled %} class="hidden"{% endif %}><a data-icon="enabled" data-action="enable" href="#" type="button" role="button" aria-label="{{ 'Enable'|t('app') }}">{{ "Enable"|t('app') }}</a></li> |
73 |
| - <li><a data-icon="uarr" data-action="moveUp" href="#" type="button" role="button" aria-label="{{ 'Move up'|t('app') }}">{{ 'Move up'|t('app') }}</a></li> |
74 |
| - <li><a data-icon="darr" data-action="moveDown" href="#" type="button" role="button" aria-label="{{ 'Move down'|t('app') }}">{{ 'Move down'|t('app') }}</a></li> |
75 |
| - </ul> |
76 |
| - {% if not staticEntries %} |
77 |
| - <hr class="padded"> |
78 |
| - <ul> |
79 |
| - <li><a class="error" data-icon="remove" data-action="delete" href="#" type="button" role="button" aria-label="{{ 'Delete'|t('app') }}">{{ "Delete"|t('app') }}</a></li> |
80 |
| - </ul> |
81 |
| - <hr class="padded"> |
82 |
| - <ul> |
83 |
| - {% for entryType in entryTypes %} |
84 |
| - <li><a data-icon="plus" data-action="add" data-type="{{ entryType.handle }}" href="#" type="button" role="button" aria-label="{{ 'Add {type} above'|t('app', { type: entryType.name|t('site') }) }}">{{ "Add {type} above"|t('app', { type: entryType.name|t('site') }) }}</a></li> |
85 |
| - {% endfor %} |
86 |
| - </ul> |
87 |
| - {% endif %} |
88 |
| - </div> |
| 171 | + {{ disclosureMenu(actionMenuItems, { |
| 172 | + hiddenLabel: 'Actions'|t('app'), |
| 173 | + buttonAttributes: { |
| 174 | + class: ['action-btn'], |
| 175 | + title: 'Actions'|t('app'), |
| 176 | + data: { |
| 177 | + 'disclosure-trigger': true, |
| 178 | + }, |
| 179 | + }, |
| 180 | + }) }} |
89 | 181 | </div>
|
90 | 182 | <a class="move icon" title="{{ 'Reorder'|t('app') }}" aria-label="{{ 'Reorder'|t('app') }}" role="button"></a>
|
91 | 183 | </div>
|
92 | 184 | {% endif %}
|
93 | 185 | <div class="fields">
|
94 | 186 | {% namespace baseInputName %}
|
95 |
| - {{ entry.getFieldLayout().createForm(entry, static).render()|raw }} |
| 187 | + {{ form.render()|raw }} |
96 | 188 | {% endnamespace %}
|
97 | 189 | </div>
|
98 | 190 | </div>
|
0 commit comments