User setting to sort comments #2307
No reviewers
Labels
No Label
dependencies
duplicate
help wanted
invalid
kind/bug
kind/feature
needs reproduction
question
security
wontfix
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: vikunja/vikunja#2307
Loading…
Reference in New Issue
No description provided.
Delete Branch "andileni/vikunja:main"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Following the discussion here https://community.vikunja.io/t/add-option-to-sort-comments/2286/8 this implements the needed functionality.
I tested it on my end as good as I could, but no guarantee.
Please have a look and point out any issues which must be fixed before merging.
Thanks and kind regards
Andreas
Please also check why the CI fails and make it pass.
@ -38,2 +39,4 @@
TaskID int64 `xorm:"not null" json:"-" param:"task"`
// The query parameter to order the items by. This can be either asc or desc, with asc being the default.
OrderBy []string `query:"order_by" json:"order_by"`
There should be a
SortBy
as well for the property to sort comments by. "Order asc / desc" does not tell you which property the sorting is using. Similar to how sorting is done in theTaskCollection
.No need to implement any other property than
created
in this PR but it should be extendable without breaking changes in the future.Please exclude this from
json
as it's not used in the actual comment and document this as query parameter in the swagger annotation comment.@ -271,3 +275,3 @@
Where(builder.And(where...)).
Join("LEFT", "users", "users.id = task_comments.author_id").
OrderBy("task_comments.created asc")
OrderBy(fmt.Sprintf("task_comments.created %s", tc.OrderBy[0]))
Please use
"task_comments.created " + orderBy
and make sure the property to order is defined. With this approach, the api will crash when you do not pass an order parameter.