diff --git a/src/components/home/ProjectsNavigation.vue b/src/components/home/ProjectsNavigation.vue
new file mode 100644
index 000000000..0b61105b3
--- /dev/null
+++ b/src/components/home/ProjectsNavigation.vue
@@ -0,0 +1,156 @@
+
+
+
+
+
+
+
+
+
+ drag = true"
+ @end="saveProjectPosition"
+ handle=".handle"
+ tag="ul"
+ item-key="id"
+ :component-data="{
+ type: 'transition-group',
+ name: !drag ? 'flip-list' : null,
+ class: [
+ 'menu-list can-be-hidden',
+ { 'dragging-disabled': false }
+ ]
+ }"
+ >
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/components/home/navigation.vue b/src/components/home/navigation.vue
index a16888400..2318cfc76 100644
--- a/src/components/home/navigation.vue
+++ b/src/components/home/navigation.vue
@@ -49,9 +49,7 @@
@@ -84,68 +82,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -170,15 +107,10 @@ import ColorBubble from '@/components/misc/colorBubble.vue'
import {useBaseStore} from '@/stores/base'
import {useProjectStore} from '@/stores/projects'
+import ProjectsNavigation from '@/components/home/ProjectsNavigation.vue'
-const drag = ref(false)
-const dragOptions = {
- animation: 100,
- ghostClass: 'ghost',
-}
const baseStore = useBaseStore()
-const currentProject = computed(() => baseStore.currentProject)
const menuActive = computed(() => baseStore.menuActive)
const loading = computed(() => namespaceStore.isLoading)
@@ -214,7 +146,7 @@ onBeforeMount(async () => {
await projectStore.loadProjects()
})
-const projects = computed(() => projectStore.projects)
+const projects = computed(() => Object.values(projectStore.projects).sort((a, b) => a.position < b.position ? -1 : 1))
function updateActiveProjects(namespace: INamespace, activeProjects: IProject[]) {
// This is a bit hacky: since we do have to filter out the archived items from the list
@@ -233,41 +165,7 @@ function updateActiveProjects(namespace: INamespace, activeProjects: IProject[])
})
}
-const projectUpdating = ref<{ [id: INamespace['id']]: boolean }>({})
-async function saveProjectPosition(e: SortableEvent) {
- if (!e.newIndex && e.newIndex !== 0) return
-
- const namespaceId = parseInt(e.to.dataset.namespaceId as string)
- const newNamespaceIndex = parseInt(e.to.dataset.namespaceIndex as string)
-
- const projectsActive = activeProjects.value[newNamespaceIndex]
- // If the project was dragged to the last position, Safari will report e.newIndex as the size of the projectsActive
- // array instead of using the position. Because the index is wrong in that case, dragging the project will fail.
- // To work around that we're explicitly checking that case here and decrease the index.
- const newIndex = e.newIndex === projectsActive.length ? e.newIndex - 1 : e.newIndex
-
- const project = projectsActive[newIndex]
- const projectBefore = projectsActive[newIndex - 1] ?? null
- const projectAfter = projectsActive[newIndex + 1] ?? null
- projectUpdating.value[project.id] = true
-
- const position = calculateItemPosition(
- projectBefore !== null ? projectBefore.position : null,
- projectAfter !== null ? projectAfter.position : null,
- )
-
- try {
- // create a copy of the project in order to not violate pinia manipulation
- await projectStore.updateProject({
- ...project,
- position,
- namespaceId,
- })
- } finally {
- projectUpdating.value[project.id] = false
- }
-}