Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions resources/js/components/FormField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
:mode="mode"
@move-up="moveUp(group.key)"
@move-down="moveDown(group.key)"
@move-to-bottom="moveToBottom(group.key)"
@move-to-top="moveToTop(group.key)"
@remove="remove(group.key)"
/>
</div>
Expand Down Expand Up @@ -221,6 +223,28 @@ export default {
this.order.push(group.key);
},

/**
* Move a group to the bottom
*/
moveToBottom(key) {
let index = this.order.indexOf(key);

if (index < 0 || index >= this.order.length - 1) return;

this.order.push(this.order.splice(index, 1)[0]);
},

/**
* Move a group to the top
*/
moveToTop(key) {
let index = this.order.indexOf(key);

if (index <= 0) return;

this.order.unshift(this.order.splice(index, 1)[0]);
},

/**
* Move a group up
*/
Expand Down
30 changes: 30 additions & 0 deletions resources/js/components/FormGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@
>
<icon type="selector" class="align-top" width="16" height="16" />
</button>
<button
dusk="move-to-top-group"
type="button"
class="group-control btn border-l border-gray-200 dark:border-gray-700 w-8 h-8 block"
:title="__('Move to top')"
@click.prevent="moveToTop">
<icon type="chevron-double-up" class="align-top" width="16" height="16" />
</button>
<button
dusk="move-to-bottom-group"
type="button"
class="group-control btn border-l border-gray-200 dark:border-gray-700 w-8 h-8 block"
:title="__('Move to bottom')"
@click.prevent="moveToBottom">
<icon type="chevron-double-down" class="align-top" width="16" height="16" />
</button>
<button
dusk="move-up-group"
type="button"
Expand Down Expand Up @@ -143,6 +159,20 @@ export default {
},

methods: {
/**
* Move this group to the top
*/
moveToTop() {
this.$emit("move-to-top");
},

/**
* Move this group to the bottom
*/
moveToBottom() {
this.$emit("move-to-bottom");
},

/**
* Move this group up
*/
Expand Down