[alphabetical-sort] Review fixes
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Stefan Genov 2021-12-20 11:54:37 +02:00
parent 0de59a0e94
commit cebc060714
3 changed files with 21 additions and 32 deletions

View File

@ -19,7 +19,7 @@
</fancycheckbox>
</div>
<div class="control">
<fancycheckbox @change="setSortAlphabetically" v-model="sortAlphabetically">
<fancycheckbox v-model="sortAlphabetically">
{{ $t('filters.attributes.sortAlphabetically') }}
</fancycheckbox>
</div>
@ -242,7 +242,6 @@ export default {
return {
params: DEFAULT_PARAMS,
filters: DEFAULT_FILTERS,
sortAlphabetically: false,
usersService: new UserService(),
foundusers: [],
@ -281,6 +280,18 @@ export default {
},
},
computed: {
sortAlphabetically: {
get() {
return this.params.sort_by.find(sortBy => sortBy === ALPHABETICAL_SORT) !== undefined
},
set(sortAlphabetically) {
this.params.sort_by = sortAlphabetically
? [ALPHABETICAL_SORT]
: getDefaultParams().sort_by
this.change()
},
},
foundLabels() {
return this.$store.getters['labels/filterLabelsByQuery'](this.labels, this.query)
},
@ -499,17 +510,6 @@ export default {
}
this.change()
},
// @TODO - Improve logic to work for all sorts ideally.
setSortAlphabetically() {
if ( ! this.sortAlphabetically) {
this.params.sort_by = getDefaultParams().sort_by
this.sortAlphabetically = false
} else {
this.params.sort_by = [ALPHABETICAL_SORT]
this.sortAlphabetically = true
}
this.change()
},
setFilterConcat() {
if (this.filters.requireAllFilters) {
this.params.filter_concat = 'and'

View File

@ -27,8 +27,6 @@ export default {
showTaskFilter: false,
params: {...getDefaultParams()},
sorting: getDefaultParams().sort_by,
}
},
watch: {
@ -64,9 +62,6 @@ export default {
params.s = search
}
//Save current sort
this.sorting = params.sort_by
const list = {listId: parseInt(this.$route.params.listId)}
const currentList = {

View File

@ -81,7 +81,7 @@
:disabled="!canWrite"
item-key="id"
:component-data="{
class: { 'dragging-disabled': !canWrite || !canDrag },
class: { 'dragging-disabled': !canWrite || isAlphabeticalSorting },
}"
>
<template #item="{element: t}">
@ -207,6 +207,9 @@ export default {
saveListView(this.$route.params.listId, this.$route.name)
},
computed: {
isAlphabeticalSorting() {
return this.params.sort_by.find( sortBy => sortBy === ALPHABETICAL_SORT ) !== undefined
},
firstNewPosition() {
if (this.tasks.length === 0) {
return 0
@ -217,9 +220,6 @@ export default {
canWrite() {
return this.list.maxRight > Rights.READ && this.list.id > 0
},
canDrag() {
return ! this.isAlphabeticalSorting()
},
list() {
return this.$store.state.currentList
},
@ -228,9 +228,6 @@ export default {
this.$nextTick(() => (this.ctaVisible = true))
},
methods: {
isAlphabeticalSorting() {
return this.sorting.find( sortBy => sortBy === ALPHABETICAL_SORT ) !== undefined
},
searchTasks() {
// Only search if the search term changed
if (this.$route.query === this.searchTerm) {
@ -262,22 +259,19 @@ export default {
this.$refs.newTaskInput.$refs.newTaskInput.focus()
},
updateTaskList( task ) {
if ( this.isAlphabeticalSorting() ) {
this.reloadTasksWithCurrentFilterAndSorting()
if ( this.isAlphabeticalSorting ) {
// reload tasks with current filter and sorting
this.loadTasks(1, undefined, undefined, true)
}
else {
const tasks = [
this.tasks = [
task,
...this.tasks,
]
this.tasks = tasks
}
this.$store.commit(HAS_TASKS, true)
},
reloadTasksWithCurrentFilterAndSorting(){
this.loadTasks(1, undefined, undefined, true)
},
editTask(id) {
// Find the selected task and set it to the current object
let theTask = this.getTaskById(id) // Somehow this does not work if we directly assign this to this.taskEditTask