Skip to content

Commit

Permalink
feat(repeater): expose option to disable reordering of repeaters
Browse files Browse the repository at this point in the history
  • Loading branch information
m4n1ok authored and haringsrob committed Apr 4, 2022
1 parent 0ed79be commit c227d5a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/src/form-fields/repeater.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pageClass: twill-doc
| name | Name of the field | string | same as `type` |
| max | Maximum amount that can be created | number | null (unlimited) |
| buttonAsLink | Displays the `Add` button as a centered link | boolean | false |
| reorder | Allow reordering of repeater items | boolean | true |

<br/>

Expand Down
1 change: 1 addition & 0 deletions frontend/js/components/Repeater.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
ref="blockList"
:block="block"
:index="index"
:withHandle="draggable"
:size="blockSize"
:opened="opened"
>
Expand Down
6 changes: 5 additions & 1 deletion frontend/js/components/blocks/BlockEditorItem.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="block" :class="blockClasses">
<div class="block__header" @dblclick.prevent="toggleExpand()">
<span class="block__handle"></span>
<span v-if="withHandle" class="block__handle"></span>
<div class="block__toggle">
<a17-dropdown :ref="moveDropdown" class="f--small" position="bottom-left" v-if="withMoveDropdown" :maxHeight="270">
<span class="block__counter f--tiny" @click="$refs[moveDropdown].toggle()">{{ index + 1 }}</span>
Expand Down Expand Up @@ -66,6 +66,10 @@
block: {
type: Object,
default: () => {}
},
withHandle: {
type: Boolean,
default: true
}
},
data () {
Expand Down
2 changes: 2 additions & 0 deletions views/partials/form/_repeater.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
$name = $name ?? $type;
$buttonAsLink = $buttonAsLink ?? false;
$max = $max ?? null;
$reorder = $reorder ?? true;
@endphp

<a17-repeater
type="{{ $type }}"
@if ($max) :max="{{$max}}" @endif
@if (!$reorder) :draggable="false" @endif
@if ($renderForBlocks) :name="repeaterName('{{ $name }}')" @else name="{{ $name }}" @endif
@if ($buttonAsLink) :button-as-link="true" @endif
></a17-repeater>
Expand Down

0 comments on commit c227d5a

Please sign in to comment.