From 556f7ab6bf7eba8c2716742ca5308967352d24c5 Mon Sep 17 00:00:00 2001 From: Stefan Genov Date: Thu, 9 Dec 2021 08:52:15 +0200 Subject: [PATCH 1/9] [alphabetical-sort] Done with checkbox --- src/components/list/partials/filters.vue | 29 ++++++++++++++++++++++++ src/components/tasks/mixins/taskList.js | 12 +++++++++- src/i18n/lang/en.json | 1 + src/views/list/views/List.vue | 24 ++++++++++++++------ vite.config.js | 3 +++ 5 files changed, 61 insertions(+), 8 deletions(-) diff --git a/src/components/list/partials/filters.vue b/src/components/list/partials/filters.vue index 039061ac3..57fc4c5a1 100644 --- a/src/components/list/partials/filters.vue +++ b/src/components/list/partials/filters.vue @@ -18,6 +18,23 @@ {{ $t('filters.attributes.showDoneTasks') }} +
+ +
+ +
+
+
+ + {{ $t('filters.attributes.sortAlphabetically') }} + +
@@ -190,6 +207,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" // FIXME: merge with DEFAULT_PARAMS in taskList.js const DEFAULT_PARAMS = { @@ -234,6 +252,7 @@ export default { return { params: DEFAULT_PARAMS, filters: DEFAULT_FILTERS, + sortAlphabetically: false, usersService: new UserService(), foundusers: [], @@ -490,6 +509,16 @@ export default { } this.change() }, + setSortAlphabetically() { + if ( ! this.sortAlphabetically) { + this.params.sort_by = getDefaultParams().sort_by + this.sortAlphabetically = false + } else { + this.params.sort_by = ['title'] + this.sortAlphabetically = true + } + this.change() + }, setFilterConcat() { if (this.filters.requireAllFilters) { this.params.filter_concat = 'and' diff --git a/src/components/tasks/mixins/taskList.js b/src/components/tasks/mixins/taskList.js index 5326b25ed..8361c6615 100644 --- a/src/components/tasks/mixins/taskList.js +++ b/src/components/tasks/mixins/taskList.js @@ -27,6 +27,8 @@ export default { showTaskFilter: false, params: {...getDefaultParams()}, + + sorting: getDefaultParams().sort_by, } }, watch: { @@ -44,7 +46,10 @@ export default { params = null, forceLoading = false, ) { - + console.log( page ) + console.log( search ) + console.log( params ) + console.log( forceLoading ) // Because this function is triggered every time on topNavigation, we're putting a condition here to only load it when we actually want to show tasks // FIXME: This is a bit hacky -> Cleanup. if ( @@ -59,10 +64,15 @@ export default { params = this.params } + console.log( this.params ) + if (search !== '') { params.s = search } + //Save current sort + this.sorting = params.sort_by + const list = {listId: parseInt(this.$route.params.listId)} const currentList = { diff --git a/src/i18n/lang/en.json b/src/i18n/lang/en.json index 09714acd6..62cc65bf3 100644 --- a/src/i18n/lang/en.json +++ b/src/i18n/lang/en.json @@ -373,6 +373,7 @@ "includeNulls": "Include Tasks which don't have a value set", "requireAll": "Require all filters to be true for a task to show up", "showDoneTasks": "Show Done Tasks", + "sortAlphabetically": "Sort Alphabetically", "enablePriority": "Enable Filter By Priority", "enablePercentDone": "Enable Filter By Percent Done", "dueDateRange": "Due Date Range", diff --git a/src/views/list/views/List.vue b/src/views/list/views/List.vue index 9d121fc65..b2e3fee6b 100644 --- a/src/views/list/views/List.vue +++ b/src/views/list/views/List.vue @@ -81,7 +81,7 @@ :disabled="!canWrite" item-key="id" :component-data="{ - class: { 'dragging-disabled': !canWrite }, + class: { 'dragging-disabled': !canWrite || !canDrag }, }" >