Skip to content

Commit

Permalink
Merge pull request #1853 from bolt/enhancement/collections-with-one-i…
Browse files Browse the repository at this point in the history
…tem-no-dropdown

No dropdown for adding collection items if there's just one.
  • Loading branch information
bobdenotter authored Sep 15, 2020
2 parents 43a4f56 + fa6ec75 commit 6671a3a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
16 changes: 12 additions & 4 deletions assets/js/app/editor/Components/Collection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</div>

<div
v-for="element in existingFields"
v-for="element in elements"
:key="element.hash"
class="collection-item"
>
Expand All @@ -37,9 +37,7 @@
</details>
</div>

<small>{{ labels.select_tooltip }}</small>

<div class="dropdown">
<div v-if="templates.length > 1" class="dropdown">
<button
id="dropdownMenuButton"
:disabled="!allowMore"
Expand All @@ -64,6 +62,16 @@
</a>
</div>
</div>
<button
v-else
type="button"
class="btn btn-secondary btn-small"
:data-template="templates[0].label"
@click="addCollectionItem($event)"
>
<i :class="[templates[0].icon, 'fas fa-fw']" />
{{ labels.add_collection_item }}
</button>
</div>
</template>

Expand Down
1 change: 0 additions & 1 deletion templates/_partials/fields/collection.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
'add_collection_item': 'collection.add_item'|trans({'%name%': field.definition.label}),
'expand_all': 'collection.expand_all'|trans,
'collapse_all': 'collection.collapse_all'|trans,
'select_tooltip': 'collection.select_tooltip'|trans,
'field_label': label,
} %}
{% set limit = field.definition.get('limit')|default(200) %}
Expand Down
6 changes: 0 additions & 6 deletions translations/messages.en.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2361,11 +2361,5 @@
<target>Collapse all</target>
</segment>
</unit>
<unit id="wAltpsD" name="collection.select_tooltip">
<segment>
<source>collection.select_tooltip</source>
<target>Select type of field to add</target>
</segment>
</unit>
</file>
</xliff>

0 comments on commit 6671a3a

Please sign in to comment.