1
0

Reorder tasks, lists and kanban buckets (#923)

Co-authored-by: kolaente <k@knt.li>
Reviewed-on: https://kolaente.dev/vikunja/api/pulls/923
Co-authored-by: konrad <konrad@kola-entertainments.de>
Co-committed-by: konrad <konrad@kola-entertainments.de>
This commit is contained in:
konrad
2021-07-28 19:06:40 +00:00
parent dac315db59
commit 6ccb85a0dc
22 changed files with 475 additions and 96 deletions

View File

@ -41,6 +41,9 @@ type Bucket struct {
// If this bucket is the "done bucket". All tasks moved into this bucket will automatically marked as done. All tasks marked as done from elsewhere will be moved into this bucket.
IsDoneBucket bool `xorm:"BOOL" json:"is_done_bucket"`
// The position this bucket has when querying all buckets. See the tasks.position property on how to use this.
Position float64 `xorm:"double null" json:"position"`
// A timestamp when this bucket was created. You cannot change this value.
Created time.Time `xorm:"created not null" json:"created"`
// A timestamp when this bucket was last updated. You cannot change this value.
@ -134,7 +137,10 @@ func (b *Bucket) ReadAll(s *xorm.Session, auth web.Auth, search string, page int
// Get all buckets for this list
buckets := []*Bucket{}
err = s.Where("list_id = ?", b.ListID).Find(&buckets)
err = s.
Where("list_id = ?", b.ListID).
OrderBy("position").
Find(&buckets)
if err != nil {
return
}
@ -167,7 +173,7 @@ func (b *Bucket) ReadAll(s *xorm.Session, auth web.Auth, search string, page int
opts.sortby = []*sortParam{
{
orderBy: orderAscending,
sortBy: taskPropertyPosition,
sortBy: taskPropertyKanbanPosition,
},
}
opts.page = page
@ -251,6 +257,12 @@ func (b *Bucket) Create(s *xorm.Session, a web.Auth) (err error) {
b.CreatedByID = b.CreatedBy.ID
_, err = s.Insert(b)
if err != nil {
return
}
b.Position = calculateDefaultPosition(b.ID, b.Position)
_, err = s.Where("id = ?", b.ID).Update(b)
return
}
@ -289,6 +301,7 @@ func (b *Bucket) Update(s *xorm.Session, a web.Auth) (err error) {
"title",
"limit",
"is_done_bucket",
"position",
).
Update(b)
return