From ae7adcd3187c796913a961fad442c7b62d76144e Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 2 Jun 2023 11:22:40 +0200 Subject: [PATCH 1/7] chore: Added events for moving elements to the top and bottom chore: Added new buttons for moving elements to the top and bottom. --- resources/js/components/FormField.vue | 24 +++++++++++++++++++++ resources/js/components/FormGroup.vue | 30 +++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/resources/js/components/FormField.vue b/resources/js/components/FormField.vue index 5c47c9e4..00d75963 100644 --- a/resources/js/components/FormField.vue +++ b/resources/js/components/FormField.vue @@ -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)" /> @@ -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) 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 */ diff --git a/resources/js/components/FormGroup.vue b/resources/js/components/FormGroup.vue index cab6ad07..235f5e42 100644 --- a/resources/js/components/FormGroup.vue +++ b/resources/js/components/FormGroup.vue @@ -37,6 +37,22 @@ > + +