From 697e5fceb723955eb651dd10eec988526ba2dd1e Mon Sep 17 00:00:00 2001 From: Robert Kossessa Date: Fri, 9 Feb 2024 14:45:32 +0100 Subject: [PATCH] ADD: Draggable categories + fixes --- src/components/profile/ProfileManager.vue | 105 +++++++++++++--------- src/store.js | 5 ++ 2 files changed, 68 insertions(+), 42 deletions(-) diff --git a/src/components/profile/ProfileManager.vue b/src/components/profile/ProfileManager.vue index b6c63c3..37ef39a 100644 --- a/src/components/profile/ProfileManager.vue +++ b/src/components/profile/ProfileManager.vue @@ -52,47 +52,60 @@
- - - - - {{ category.name }} ({{ category.profiles?.length || 0 - }}) - - - - - - - - - - + + +
@@ -123,7 +136,6 @@ defineProps({ }) const dragOptions = ref({ - group: 'profiles', ghostClass: 'ghost', animation: 150, direction: 'vertical', @@ -179,6 +191,15 @@ watch(showProfileConfig, value => { // return map // }) +const onCategoryDrop = (event) => { + if (event.moved) { + const category = event.moved.element + const oldIndex = event.moved.oldIndex + const newIndex = event.moved.newIndex + store.moveProfileCategory(category.name, oldIndex, newIndex) + } +} + const onProfileDrop = (event, categoryIndex) => { if (event.moved) { const profile = event.moved.element diff --git a/src/store.js b/src/store.js index 2713879..845a037 100644 --- a/src/store.js +++ b/src/store.js @@ -82,6 +82,11 @@ export const useStore = defineStore('main', { category.profiles[newIndex] = category.profiles[oldIndex] category.profiles[newIndex] = tmpProfile }, + moveProfileCategory(categoryName, oldIndex, newIndex) { + const tmpCategory = this.profileCategories[newIndex] + this.profileCategories[newIndex] = this.profileCategories[oldIndex] + this.profileCategories[newIndex] = tmpCategory + }, changeProfileCategory(profileId, newCategoryIndex, newIndex) { const profile = this.profiles.find(p => p.id === profileId) const oldCategory = this.profileCategories.find(c => c.profiles.find(p => p.id === profileId))