diff --git a/frontend/src/components/project/partials/SortPopup.vue b/frontend/src/components/project/partials/SortPopup.vue new file mode 100644 index 000000000..8e06f8090 --- /dev/null +++ b/frontend/src/components/project/partials/SortPopup.vue @@ -0,0 +1,120 @@ + + + + + diff --git a/frontend/src/components/project/views/ProjectList.vue b/frontend/src/components/project/views/ProjectList.vue index 270f99d14..94fa3ae42 100644 --- a/frontend/src/components/project/views/ProjectList.vue +++ b/frontend/src/components/project/views/ProjectList.vue @@ -14,6 +14,9 @@ :project-id="projectId" @update:modelValue="prepareFiltersAndLoadTasks()" /> + @@ -49,13 +52,13 @@ v-if="tasks && tasks.length > 0" v-model="tasks" :group="{name: 'tasks', put: false}" - :disabled="!canDragTasks" + :disabled="!canDragTasks || !isPositionSorting" item-key="id" tag="ul" :component-data="{ class: { tasks: true, - 'dragging-disabled': !canDragTasks || isAlphabeticalSorting + 'dragging-disabled': !canDragTasks || !isPositionSorting }, type: 'transition-group' }" @@ -71,14 +74,14 @@ @@ -109,7 +112,7 @@ import SingleTaskInProject from '@/components/tasks/partials/SingleTaskInProject import FilterPopup from '@/components/project/partials/FilterPopup.vue' import Nothing from '@/components/misc/Nothing.vue' import Pagination from '@/components/misc/Pagination.vue' -import {ALPHABETICAL_SORT} from '@/components/project/partials/Filters.vue' +import SortPopup from '@/components/project/partials/SortPopup.vue' import {useTaskList} from '@/composables/useTaskList' import {useTaskDragToProject} from '@/composables/useTaskDragToProject' @@ -171,8 +174,8 @@ watch( }, ) -const isAlphabeticalSorting = computed(() => { - return params.value.sort_by.find(sortBy => sortBy === ALPHABETICAL_SORT) !== undefined +const isPositionSorting = computed(() => { + return Object.keys(sortByParam.value).length === 0 || (Object.keys(sortByParam.value).length === 1 && typeof sortByParam.value.position !== 'undefined') }) const firstNewPosition = computed(() => { @@ -214,15 +217,15 @@ function focusNewTaskInput() { } function updateTaskList(task: ITask) { - if (isAlphabeticalSorting.value) { - // reload tasks with current filter and sorting - loadTasks() - } else { - allTasks.value = [ - task, - ...allTasks.value, - ] - } + if (!isPositionSorting.value) { + // reload tasks with current filter and sorting + loadTasks() + } else { + allTasks.value = [ + task, + ...allTasks.value, + ] + } baseStore.setHasTasks(true) } @@ -287,12 +290,7 @@ async function saveTaskPosition(e: { originalEvent?: MouseEvent, to: HTMLElement } function prepareFiltersAndLoadTasks() { - if (isAlphabeticalSorting.value) { - sortByParam.value = {} - sortByParam.value[ALPHABETICAL_SORT] = 'asc' - } - - loadTasks() + loadTasks() } const taskRefs = ref<(InstanceType | null)[]>([]) diff --git a/frontend/src/i18n/lang/en.json b/frontend/src/i18n/lang/en.json index d6bd83afb..103e0d555 100644 --- a/frontend/src/i18n/lang/en.json +++ b/frontend/src/i18n/lang/en.json @@ -380,7 +380,8 @@ "addPlaceholder": "Add a task…", "empty": "This project is currently empty.", "newTaskCta": "Create a task.", - "editTask": "Edit Task" + "editTask": "Edit Task", + "sort": "Sort" }, "gantt": { "title": "Gantt", @@ -572,6 +573,14 @@ } } }, + "sorting": { + "title": "Sort Tasks", + "sortBy": "Sort by", + "order": "Order", + "position": "Position", + "asc": "Ascending", + "desc": "Descending" + }, "migrate": { "title": "Import from other services", "titleService": "Import your data from {name} into Vikunja",