diff --git a/src/components/list/partials/filters.vue b/src/components/list/partials/filters.vue index 2b36ff56b..15545afb3 100644 --- a/src/components/list/partials/filters.vue +++ b/src/components/list/partials/filters.vue @@ -195,7 +195,7 @@ import NamespaceService from '@/services/namespace' import EditLabels from '@/components/tasks/partials/editLabels.vue' import {objectToSnakeCase} from '@/helpers/case' -import {getDefaultParams} from '../../tasks/mixins/taskList' +import {getDefaultParams} from '@/components/tasks/mixins/taskList' // FIXME: merge with DEFAULT_PARAMS in taskList.js const DEFAULT_PARAMS = { @@ -226,7 +226,7 @@ const DEFAULT_FILTERS = { namespace: '', } -const ALPHABETICAL_SORT = ['title'] +export const ALPHABETICAL_SORT = 'title' export default { name: 'filters', @@ -505,7 +505,7 @@ export default { this.params.sort_by = getDefaultParams().sort_by this.sortAlphabetically = false } else { - this.params.sort_by = ALPHABETICAL_SORT + this.params.sort_by = [ALPHABETICAL_SORT] this.sortAlphabetically = true } this.change() diff --git a/src/views/list/views/List.vue b/src/views/list/views/List.vue index d234209ab..c31a5d7d1 100644 --- a/src/views/list/views/List.vue +++ b/src/views/list/views/List.vue @@ -148,6 +148,7 @@ import {HAS_TASKS} from '@/store/mutation-types' import Nothing from '@/components/misc/nothing.vue' import Pagination from '@/components/misc/pagination.vue' import Popup from '@/components/misc/popup' +import { ALPHABETICAL_SORT } from '@/components/list/partials/filters' import draggable from 'vuedraggable' import {calculateItemPosition} from '../../../helpers/calculateItemPosition' @@ -228,7 +229,7 @@ export default { }, methods: { isAlphabeticalSorting() { - return this.sorting.find( sortBy => sortBy === 'title' ) !== undefined + return this.sorting.find( sortBy => sortBy === ALPHABETICAL_SORT ) !== undefined }, searchTasks() { // Only search if the search term changed @@ -260,12 +261,22 @@ export default { focusNewTaskInput() { this.$refs.newTaskInput.$refs.newTaskInput.focus() }, - updateTaskList() { + updateTaskList( task ) { + if ( this.isAlphabeticalSorting() ) { + this.reloadTasksWithCurrentFilterAndSorting() + } + else { + const tasks = [ + task, + ...this.tasks, + ] + this.tasks = tasks + } + this.$store.commit(HAS_TASKS, true) - this.reloadTasksWithCurrentFilterAndSorting() }, reloadTasksWithCurrentFilterAndSorting(){ - this.loadTasks(undefined, undefined, undefined, true) + this.loadTasks(1, undefined, undefined, true) }, editTask(id) { // Find the selected task and set it to the current object