Skip to content

Commit

Permalink
Merge pull request #1017 from bolt/feature/limit-imagelist
Browse files Browse the repository at this point in the history
Feature/limit imagelist
  • Loading branch information
bobdenotter committed Feb 5, 2020
2 parents 368f015 + 8f0ae9e commit 2361524
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 12 additions & 1 deletion assets/js/app/editor/Components/Imagelist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@
></editor-image>
</div>

<button class="btn btn-tertiary" type="button" @click="addImage">
<button
class="btn btn-tertiary"
type="button"
:disabled="!allowMore"
@click="addImage"
>
<i class="fas fa-fw fa-plus"></i>
{{ labels.add_new_image }}
</button>
Expand All @@ -50,6 +55,7 @@ export default {
'labels',
'extensions',
'attributesLink',
'limit',
],
data: function() {
let counter = 0;
Expand All @@ -64,6 +70,11 @@ export default {
containerImages: this.images,
};
},
computed: {
allowMore: function() {
return this.getActiveImageFields().length < this.limit;
},
},
methods: {
isFirstInImagelist(index) {
return index === 0;
Expand Down
2 changes: 2 additions & 0 deletions templates/_partials/fields/imagelist.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
'add_new_image': 'image.add_new_image'|trans,
}|json_encode %}
{% set extensions = field.definition.get('extensions')|default('') %}
{% set limit = field.definition.get('limit')|default(200) %}

<editor-imagelist
:images='{{ field.jsonvalue }}'
Expand All @@ -28,6 +29,7 @@
:labels='{{ labels }}'
:extensions='{{ extensions|json_encode }}'
:attributes-link='{{ path('bolt_media_new')|json_encode }}'
:limit='{{ limit|json_encode }}'
></editor-imagelist>

{% endblock %}

0 comments on commit 2361524

Please sign in to comment.