Fix passing sort_by and order_by as query path arrays
This commit is contained in:
parent
1555f04bd2
commit
d483fe8beb
1 changed files with 12 additions and 2 deletions
|
@ -31,8 +31,10 @@ type TaskCollection struct {
|
||||||
|
|
||||||
// The query parameter to sort by. This is for ex. done, priority, etc.
|
// The query parameter to sort by. This is for ex. done, priority, etc.
|
||||||
SortBy []string `query:"sort_by"`
|
SortBy []string `query:"sort_by"`
|
||||||
|
SortByArr []string `query:"sort_by[]"`
|
||||||
// The query parameter to order the items by. This can be either asc or desc, with asc being the default.
|
// 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"`
|
OrderBy []string `query:"order_by"`
|
||||||
|
OrderByArr []string `query:"order_by[]"`
|
||||||
|
|
||||||
web.CRUDable `xorm:"-" json:"-"`
|
web.CRUDable `xorm:"-" json:"-"`
|
||||||
web.Rights `xorm:"-" json:"-"`
|
web.Rights `xorm:"-" json:"-"`
|
||||||
|
@ -58,6 +60,14 @@ type TaskCollection struct {
|
||||||
// @Router /lists/{listID}/tasks [get]
|
// @Router /lists/{listID}/tasks [get]
|
||||||
func (tf *TaskCollection) ReadAll(a web.Auth, search string, page int, perPage int) (result interface{}, resultCount int, totalItems int64, err error) {
|
func (tf *TaskCollection) ReadAll(a web.Auth, search string, page int, perPage int) (result interface{}, resultCount int, totalItems int64, err error) {
|
||||||
|
|
||||||
|
if len(tf.SortByArr) > 0 {
|
||||||
|
tf.SortBy = append(tf.SortBy, tf.SortByArr...)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(tf.OrderByArr) > 0 {
|
||||||
|
tf.OrderBy = append(tf.OrderBy, tf.OrderByArr...)
|
||||||
|
}
|
||||||
|
|
||||||
var sort = make([]*sortParam, 0, len(tf.SortBy))
|
var sort = make([]*sortParam, 0, len(tf.SortBy))
|
||||||
for i, s := range tf.SortBy {
|
for i, s := range tf.SortBy {
|
||||||
param := &sortParam{
|
param := &sortParam{
|
||||||
|
|
Loading…
Reference in a new issue