Skip to content

Commit 29d37f8

Browse files
committed
Define Copy once
1 parent 28fb6ee commit 29d37f8

File tree

1 file changed

+18
-24
lines changed
  • src/templates/_components/fieldtypes/Matrix

1 file changed

+18
-24
lines changed

src/templates/_components/fieldtypes/Matrix/block.twig

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,12 @@
9090
{% endif %}
9191
{% endif %}
9292

93+
{% set actionMenuItems = actionMenuItems|merge([
94+
{hr: true},
95+
]) %}
96+
9397
{% if not staticEntries %}
9498
{% set actionMenuItems = actionMenuItems|merge([
95-
{hr: true},
9699
{
97100
icon: 'trash',
98101
label: 'Delete'|t('app'),
@@ -109,17 +112,22 @@
109112
data: {action: 'duplicate'},
110113
},
111114
},
112-
{
113-
icon: 'clone-dashed',
114-
color: 'fuchsia',
115-
label: 'Copy'|t('app'),
116-
attributes: {
117-
data: {action: 'copy'},
118-
},
119-
},
120-
{hr: true},
121115
]) %}
116+
{% endif %}
117+
118+
{% set actionMenuItems = actionMenuItems|merge([
119+
{
120+
icon: 'clone-dashed',
121+
color: 'fuchsia',
122+
label: 'Copy'|t('app'),
123+
attributes: {
124+
data: {action: 'copy'},
125+
},
126+
},
127+
{hr: true},
128+
]) %}
122129

130+
{% if not staticEntries %}
123131
{% for entryType in entryTypes %}
124132
{% set actionMenuItems = actionMenuItems|push({
125133
icon: entryType.icon ?? 'plus',
@@ -130,20 +138,6 @@
130138
},
131139
}) %}
132140
{% endfor %}
133-
{% else %}
134-
{# copy action should be available even for the "static" field - one entry type with min and max entries set to the same value #}
135-
{% set actionMenuItems = actionMenuItems|merge([
136-
{hr: true},
137-
{
138-
icon: 'clone-dashed',
139-
color: 'fuchsia',
140-
label: 'Copy'|t('app'),
141-
attributes: {
142-
data: {action: 'copy'},
143-
},
144-
},
145-
{hr: true},
146-
]) %}
147141
{% endif %}
148142

149143
{% namespace baseInputName %}

0 commit comments

Comments
 (0)