feat/alphabetical-sort #1162

Merged
dpschen merged 9 commits from :feat/alphabetical-sort into main 2021-12-21 16:29:50 +00:00
Contributor

Alphabetical sorting.
Disables re-ordering when applied.
Does not work with the search button as expected, but neither do the filters tbh... Works fine with the search in the filters menu.

I know we talked about having a dropdown but since this is pretty much finished I thought I'd submit a PR. I am a bit short on time these days but may submit a new PR to add the dropdown ( should be simple enough )

Alphabetical sorting. Disables re-ordering when applied. Does not work with the search button as expected, but neither do the filters tbh... Works fine with the search in the filters menu. I know we talked about having a dropdown but since this is pretty much finished I thought I'd submit a PR. I am a bit short on time these days but may submit a new PR to add the dropdown ( should be simple enough )
Michaelpalacce added 3 commits 2021-12-09 07:03:47 +00:00
First-time contributor

Yes! This is happening :D

Yes! This is happening :D
Author
Contributor

Fix linting issues with build

Fix linting issues with build
konrad requested changes 2021-12-11 12:47:52 +00:00
konrad left a comment
Owner

Hi! Thanks for the PR.

A few nits, but looks good overall.

Please also fix the lint errors, you should be able to run yarn lint --fix to fix most of them.

Hi! Thanks for the PR. A few nits, but looks good overall. Please also fix the lint errors, you should be able to run `yarn lint --fix` to fix most of them.
@ -493,0 +503,4 @@
this.params.sort_by = getDefaultParams().sort_by
this.sortAlphabetically = false
} else {
this.params.sort_by = ['title']

Please use a const for that.

Please use a const for that.
konrad marked this conversation as resolved
@ -373,6 +373,7 @@
"includeNulls": "Zahrnout úkoly, které nemají nastavenou hodnotu",
"requireAll": "Vyžaduje aby všechny filtry odpovídaly, aby se úkol zobrazil",
"showDoneTasks": "Zobrazit dokončené úkoly",
"sortAlphabetically": "Sort Alphabetically",

This will be synced from crowdin automatically - please don't include it in this PR, only the string in en.json.

This will be synced from crowdin automatically - please don't include it in this PR, only the string in `en.json`.
konrad marked this conversation as resolved
@ -263,0 +265,4 @@
// task,
// ...this.tasks,
// ]
// this.tasks = tasks

Why did you comment this? If it is not used, remove it.

Why did you comment this? If it is not used, remove it.
konrad marked this conversation as resolved
@ -264,0 +270,4 @@
this.reloadTasksWithCurrentFilterAndSorting()
},
reloadTasksWithCurrentFilterAndSorting(){
this.loadTasks(undefined, undefined, undefined, true)

This should use the default params instead of undefined.

This should use the default params instead of `undefined`.
Author
Contributor

Default parameters will overwrite the current filtering,searching etc, no?

Idea here is to preserve it

Default parameters will overwrite the current filtering,searching etc, no? Idea here is to preserve it

That's actually the idea behind the default paramters. If they are set, it will first look for the params in the data variables of the component and use them. The function parameters are only meant to override that.

Passing in undefined is, well, undefined behaviour.

That's actually the idea behind the default paramters. If they are set, it will first look for the params in the data variables of the component and use them. The function parameters are only meant to override that. Passing in `undefined` is, well, undefined behaviour.
Author
Contributor

Do you mean something like this:

	reloadTasksWithCurrentFilterAndSorting(){
		this.loadTasks(1, DEFAULT_PARAMS.s, DEFAULT_PARAMS, true)
	},

Where DEFAULT PARAMS are:

// FIXME: merge with DEFAULT_PARAMS in taskList.js
export const DEFAULT_PARAMS = {
	sort_by: [],
	order_by: [],
	filter_by: [],
	filter_value: [],
	filter_comparator: [],
	filter_include_nulls: true,
	filter_concat: 'or',
	s: '',
}
Do you mean something like this: reloadTasksWithCurrentFilterAndSorting(){ this.loadTasks(1, DEFAULT_PARAMS.s, DEFAULT_PARAMS, true) }, Where DEFAULT PARAMS are: ~~~ // FIXME: merge with DEFAULT_PARAMS in taskList.js export const DEFAULT_PARAMS = { sort_by: [], order_by: [], filter_by: [], filter_value: [], filter_comparator: [], filter_include_nulls: true, filter_concat: 'or', s: '', } ~~~

No, I mean the default parameters for the variables as they are declared in the function. You should call this.loadTasks with just the page function parameter specified (the first)

No, I mean the default parameters for the variables as they are declared in the function. You should call `this.loadTasks` with just the page function parameter specified (the first)
Author
Contributor

Sure but this would break the behavior since I need forceLoading ( the 4th parameter to be set ). undefined means take the default, it was my bad for passing undefined for page but otherwise it should be this.loadTasks(1, undefined, undefined, true)

Sure but this would break the behavior since I need forceLoading ( the 4th parameter to be set ). undefined means take the default, it was my bad for passing undefined for page but otherwise it should be this.loadTasks(1, undefined, undefined, true)

Please pass in '' for the search param and null for the params param so it matches the function declaration: https://kolaente.dev/vikunja/frontend/src/branch/main/src/components/tasks/mixins/taskList.js#L41-L46

Please pass in `''` for the search param and `null` for the params param so it matches the function declaration: https://kolaente.dev/vikunja/frontend/src/branch/main/src/components/tasks/mixins/taskList.js#L41-L46
Member

@Michaelpalacce @konrad

Thanks for this pull request.

This will collide with #816 if we merge it.

@Michaelpalacce @konrad Thanks for this pull request. This will collide with https://kolaente.dev/vikunja/frontend/pulls/816 if we merge it.
Owner

@dpschen Would this require a rewrite once #816 is merged or "only" a few conflicts?

@dpschen Would this require a rewrite once #816 is merged or "only" a few conflicts?
Member

I think currently only the import

import {getDefaultParams} from "../../tasks/mixins/taskList"

EDIT: to be clear: the filepath of that import. So nothing major.

and the changed changed stuff in src/views/list/views/List.vue is conflicting.
The latter has changed a lot in my branch.

I think currently only the import ```js import {getDefaultParams} from "../../tasks/mixins/taskList" ``` **EDIT:** to be clear: the filepath of that import. So nothing major. and the changed changed stuff in `src/views/list/views/List.vue` is conflicting. The latter has changed a lot in my branch.
Michaelpalacce added 1 commit 2021-12-15 07:02:38 +00:00
continuous-integration/drone/pr Build is failing Details
1b6d50860c
[alphabetical-sort] Review fixes
Member

Hi Michaelpalacce!

Thank you for creating a PR!

I've deployed the changes of this PR on a preview environment under this URL: https://1162-featalphabetical-sort--vikunja-frontend-preview.netlify.app

You can use this url to view the changes live and test them out.
You will need to manually connect this to an api running somehwere. The easiest to use is https://try.vikunja.io/.

Have a nice day!

Beep boop, I'm a bot.

Hi Michaelpalacce! Thank you for creating a PR! I've deployed the changes of this PR on a preview environment under this URL: https://1162-featalphabetical-sort--vikunja-frontend-preview.netlify.app You can use this url to view the changes live and test them out. You will need to manually connect this to an api running somehwere. The easiest to use is https://try.vikunja.io/. Have a nice day! > Beep boop, I'm a bot.
konrad reviewed 2021-12-15 20:29:00 +00:00
@ -262,2 +263,3 @@
this.tasks = tasks
updateTaskList() {
this.$store.commit(HAS_TASKS, true)
this.reloadTasksWithCurrentFilterAndSorting()

Still not quite happy with reloading everything. This gives a very noticable load flickering. I get why it is nessecary though. Maybe only reload if there are filters set and otherwise prepend the task as done already?

Still not quite happy with reloading everything. This gives a very noticable load flickering. I get why it is nessecary though. Maybe only reload if there are filters set and otherwise prepend the task as done already?

The sorting should probably happen on client and server side.
This way the client can sort already what he is aware of and fetches an update.

The sorting should probably happen on client _and_ server side. This way the client can sort already what he is aware of and fetches an update.

Since this would require a bit of work, I think we should do this in another PR and keep the current logic of prepending new tasks to the list.

Since this would require a bit of work, I think we should do this in another PR and keep the current logic of prepending new tasks to the list.
Author
Contributor

So should I do reload only if filters and/or sorts are set ?

So should I do reload only if filters and/or sorts are set ?

I think that would be a good idea.

I think that would be a good idea.
dpschen marked this conversation as resolved
Owner

It looks like this breaks the test. Please take a look.

It looks like this breaks the test. Please take a look.
dpschen requested changes 2021-12-15 20:43:10 +00:00
@ -190,6 +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'

Use @

Use `@`
dpschen marked this conversation as resolved
@ -225,2 +228,4 @@
},
methods: {
isAlphabeticalSorting() {
return this.sorting.find( sortBy => sortBy === 'title' ) !== undefined

Import declared const ALPHABETICAL_SORT

Import declared const `ALPHABETICAL_SORT`
dpschen marked this conversation as resolved
Author
Contributor

It looks like this breaks the test. Please take a look.

I don't really know much of cypress, to fix it. Seems like something basic but I cannot tell exactly what the issue is

> It looks like this breaks the test. Please take a look. I don't really know much of cypress, to fix it. Seems like something basic but I cannot tell exactly what the issue is
Member

@Michaelpalacce:

Something went wrong in 5808a8980b002f898ee4504f37a8491419268424.
Seems like all files were formatted.

@Michaelpalacce: Something went wrong in 5808a8980b002f898ee4504f37a8491419268424. Seems like all files were formatted.
Author
Contributor

@Michaelpalacce:

Something went wrong in 5808a8980b002f898ee4504f37a8491419268424.
Seems like all files were formatted.

Oh wow.. I'll ammend this as soon as possible

> @Michaelpalacce: > > Something went wrong in 5808a8980b002f898ee4504f37a8491419268424. > Seems like all files were formatted. Oh wow.. I'll ammend this as soon as possible
Member

If you did this, mark me.

I can check if I can find out anything about the failing test.
But might be tricky: some tests are flaky right now :/
I'm not super into Cypres aswell.

If you did this, mark me. I can check if I can find out anything about the failing test. But might be tricky: some tests are flaky right now :/ I'm not super into Cypres aswell.
Michaelpalacce force-pushed feat/alphabetical-sort from 5808a8980b to 1b6d50860c 2021-12-19 13:08:41 +00:00 Compare
Michaelpalacce added 1 commit 2021-12-19 13:09:19 +00:00
continuous-integration/drone/pr Build is failing Details
0de59a0e94
[alphabetical-sort] Ammended commit
dpschen requested changes 2021-12-19 20:02:33 +00:00
@ -491,2 +500,4 @@
this.change()
},
// @TODO - Improve logic to work for all sorts ideally.
setSortAlphabetically() {

Use computed setter and getter and remove @change:

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
	},
},
Use computed setter and getter and remove `@change`: ```js 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 }, },
dpschen marked this conversation as resolved
@ -82,3 +82,3 @@
item-key="id"
:component-data="{
class: { 'dragging-disabled': !canWrite },
class: { 'dragging-disabled': !canWrite || !canDrag },

The canDrag is misleading here because dragging could also be disabled if canWrite is false (and thus the invertion true).

Make isAlphabeticalSorting a computed and you don't have to double invert it (since
its result is inverted inside the computed).

The `canDrag` is misleading here because dragging could also be disabled if `canWrite` is false (and thus the invertion `true`). Make `isAlphabeticalSorting` a computed and you don't have to double invert it (since its result is inverted inside the computed).
dpschen marked this conversation as resolved
@ -225,2 +229,4 @@
},
methods: {
isAlphabeticalSorting() {
return this.sorting.find( sortBy => sortBy === ALPHABETICAL_SORT ) !== undefined

Please use params.sort_by => This way we do not need to introduce a new this.sorting variable in the mixin.

Please use `params.sort_by` => This way we do not need to introduce a new `this.sorting` variable in the mixin.
dpschen marked this conversation as resolved
@ -262,1 +264,3 @@
this.tasks = tasks
updateTaskList( task ) {
if ( this.isAlphabeticalSorting() ) {
this.reloadTasksWithCurrentFilterAndSorting()

Instead of putting this in a new function just make a comment:

// reload tasks with current filter and sorting
this.loadTasks(1, undefined, undefined, true)
Instead of putting this in a new function just make a comment: ```js // reload tasks with current filter and sorting this.loadTasks(1, undefined, undefined, true) ```
dpschen marked this conversation as resolved
@ -263,0 +266,4 @@
this.reloadTasksWithCurrentFilterAndSorting()
}
else {
const tasks = [

Merge this:

this.tasks = [
	task,
    ...this.tasks,
]
Merge this: ```js this.tasks = [ task, ...this.tasks, ] ```
dpschen marked this conversation as resolved
Michaelpalacce added 1 commit 2021-12-20 09:54:43 +00:00
continuous-integration/drone/pr Build is passing Details
cebc060714
[alphabetical-sort] Review fixes
Member

Okay I changed some small stuff in my branch.
I don't have the right to push to your branch @Michaelpalacce.

My Changes

  • I fixed a property access error that happend in the kanban view.
  • The sorting alphabetical doesn't work for the kanban and the table view but I think an implementation for kanban is not in the scope of this pull request. In the table soriting by title is already possible by clicking on the column header.
    Making the new option work aswell might be not too complex to add here but I would prefere to improve the general loading implementation instead of wasting time by making the current implementation more complex for a single case / filter.
  • improved the grouping in the <filters> component. It was grouped in the field under "Show done tasks" which doesn't really make sense. I also removed the divs with the .control class since they didn't change the layout and didn't add any semantics.

Since I see this branch as a quick win to make alphabetical sorting work I think we shouldn't waste time for complex special cases. Because of that I'm fine with merging after @Michaelpalacce cherry picked my added commits.

@konrad: Anything to add?

Okay I changed some small stuff in [my branch](https://kolaente.dev/dpschen/frontend/src/branch/feat/alphabetical-sort). I don't have the right to push to your branch @Michaelpalacce. ### My Changes - I fixed a property access error that happend in the kanban view. - The sorting alphabetical doesn't work for the kanban and the table view but I think an implementation for kanban is not in the scope of this pull request. In the table soriting by title is already possible by clicking on the column header. Making the new option work aswell might be not too complex to add here but I would prefere to improve the general loading implementation instead of wasting time by making the current implementation more complex for a single case / filter. - improved the grouping in the `<filters>` component. It was grouped in the field under "Show done tasks" which doesn't really make sense. I also removed the divs with the `.control` class since they didn't change the layout and didn't add any semantics. Since I see this branch as a quick win to make alphabetical sorting work I think we shouldn't waste time for complex special cases. Because of that I'm fine with merging after @Michaelpalacce cherry picked my added commits. @konrad: Anything to add?
konrad was assigned by dpschen 2021-12-21 12:57:37 +00:00
Author
Contributor

@dpschen yes it was decided that this will be done only for list view for now.

Also I also don't have access to your branch ( can't even see it. )
If you want I can give you access to mine so you can push any changes you want?

@dpschen yes it was decided that this will be done only for list view for now. Also I also don't have access to your branch ( can't even see it. ) If you want I can give you access to mine so you can push any changes you want?
dpschen added 3 commits 2021-12-21 14:10:32 +00:00
Member

If you want I can give you access to mine so you can push any changes you want?

Thanks! Pushed the changes =)

> If you want I can give you access to mine so you can push any changes you want? Thanks! Pushed the changes =)
konrad approved these changes 2021-12-21 14:25:44 +00:00
konrad left a comment
Owner

Fine by me once the CI passes.

Fine by me once the CI passes.
dpschen approved these changes 2021-12-21 14:32:24 +00:00
dpschen merged commit 7ebca9afc5 into main 2021-12-21 16:29:50 +00:00
dpschen deleted branch feat/alphabetical-sort 2021-12-21 16:29:50 +00:00
Owner

Thanks again @Michaelpalacce!

Thanks again @Michaelpalacce!
Author
Contributor

Thanks again @Michaelpalacce!

No problem... Feels like I just slowed you guys down more than anything lol

> Thanks again @Michaelpalacce! No problem... Feels like I just slowed you guys down more than anything lol
First-time contributor

Thank you all, and @Michaelpalacce in particular, for this :)

Thank you all, and @Michaelpalacce in particular, for this :)
This repo is archived. You cannot comment on pull requests.
No description provided.