feat(views)!: move done and default bucket setting to view
This commit is contained in:
@ -82,14 +82,14 @@ func getBucketByID(s *xorm.Session, id int64) (b *Bucket, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func getDefaultBucketID(s *xorm.Session, project *Project) (bucketID int64, err error) {
|
||||
if project.DefaultBucketID != 0 {
|
||||
return project.DefaultBucketID, nil
|
||||
func getDefaultBucketID(s *xorm.Session, view *ProjectView) (bucketID int64, err error) {
|
||||
if view.DefaultBucketID != 0 {
|
||||
return view.DefaultBucketID, nil
|
||||
}
|
||||
|
||||
bucket := &Bucket{}
|
||||
_, err = s.
|
||||
Where("project_id = ?", project.ID).
|
||||
Where("project_view_id = ?", view.ID).
|
||||
OrderBy("position asc").
|
||||
Get(bucket)
|
||||
if err != nil {
|
||||
@ -369,7 +369,7 @@ func (b *Bucket) Delete(s *xorm.Session, a web.Auth) (err error) {
|
||||
}
|
||||
|
||||
// Get the default bucket
|
||||
p, err := GetProjectSimpleByID(s, b.ProjectID)
|
||||
p, err := GetProjectViewByID(s, b.ProjectViewID, b.ProjectID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -63,6 +63,8 @@ func GetTables() []interface{} {
|
||||
&Webhook{},
|
||||
&Reaction{},
|
||||
&ProjectView{},
|
||||
&TaskPosition{},
|
||||
&TaskBucket{},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,9 +52,7 @@ type Project struct {
|
||||
ParentProjectID int64 `xorm:"bigint INDEX null" json:"parent_project_id"`
|
||||
ParentProject *Project `xorm:"-" json:"-"`
|
||||
|
||||
// The ID of the bucket where new tasks without a bucket are added to. By default, this is the leftmost bucket in a project.
|
||||
DefaultBucketID int64 `xorm:"bigint INDEX null" json:"default_bucket_id"`
|
||||
// If tasks are moved to the done bucket, they are marked as done. If they are marked as done individually, they are moved into the done bucket.
|
||||
// Deprecated: If tasks are moved to the done bucket, they are marked as done. If they are marked as done individually, they are moved into the done bucket.
|
||||
DoneBucketID int64 `xorm:"bigint INDEX null" json:"done_bucket_id"`
|
||||
|
||||
// The user who created this project.
|
||||
|
@ -133,6 +133,10 @@ type ProjectView struct {
|
||||
BucketConfigurationMode BucketConfigurationModeKind `xorm:"default 0" json:"bucket_configuration_mode"`
|
||||
// When the bucket configuration mode is not `manual`, this field holds the options of that configuration.
|
||||
BucketConfiguration []*ProjectViewBucketConfiguration `xorm:"json" json:"bucket_configuration"`
|
||||
// The ID of the bucket where new tasks without a bucket are added to. By default, this is the leftmost bucket in a view.
|
||||
DefaultBucketID int64 `xorm:"bigint INDEX null" json:"default_bucket_id"`
|
||||
// If tasks are moved to the done bucket, they are marked as done. If they are marked as done individually, they are moved into the done bucket.
|
||||
DoneBucketID int64 `xorm:"bigint INDEX null" json:"done_bucket_id"`
|
||||
|
||||
// A timestamp when this view was updated. You cannot change this value.
|
||||
Updated time.Time `xorm:"updated not null" json:"updated"`
|
||||
|
@ -648,10 +648,10 @@ func checkBucketLimit(s *xorm.Session, t *Task, bucket *Bucket) (err error) {
|
||||
}
|
||||
|
||||
// Contains all the task logic to figure out what bucket to use for this task.
|
||||
func setTaskBucket(s *xorm.Session, task *Task, originalTask *Task, doCheckBucketLimit bool, project *Project) (targetBucket *Bucket, err error) {
|
||||
func setTaskBucket(s *xorm.Session, task *Task, originalTask *Task, doCheckBucketLimit bool, view *ProjectView) (targetBucket *Bucket, err error) {
|
||||
|
||||
if project == nil {
|
||||
project, err = GetProjectSimpleByID(s, task.ProjectID)
|
||||
if view == nil {
|
||||
view, err = GetProjectViewByID(s, view.ID, task.ProjectID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -660,7 +660,7 @@ func setTaskBucket(s *xorm.Session, task *Task, originalTask *Task, doCheckBucke
|
||||
var bucket *Bucket
|
||||
if task.Done && originalTask != nil &&
|
||||
(!originalTask.Done || task.ProjectID != originalTask.ProjectID) {
|
||||
task.BucketID = project.DoneBucketID
|
||||
task.BucketID = view.DoneBucketID
|
||||
}
|
||||
|
||||
if task.BucketID == 0 && originalTask != nil && originalTask.BucketID != 0 {
|
||||
@ -672,7 +672,7 @@ func setTaskBucket(s *xorm.Session, task *Task, originalTask *Task, doCheckBucke
|
||||
// because then we have it already updated to the done bucket.
|
||||
if task.BucketID == 0 ||
|
||||
(originalTask != nil && task.ProjectID != 0 && originalTask.ProjectID != task.ProjectID && !task.Done) {
|
||||
task.BucketID, err = getDefaultBucketID(s, project)
|
||||
task.BucketID, err = getDefaultBucketID(s, view)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -699,7 +699,7 @@ func setTaskBucket(s *xorm.Session, task *Task, originalTask *Task, doCheckBucke
|
||||
}
|
||||
}
|
||||
|
||||
if bucket.ID == project.DoneBucketID && originalTask != nil && !originalTask.Done {
|
||||
if bucket.ID == view.DoneBucketID && originalTask != nil && !originalTask.Done {
|
||||
task.Done = true
|
||||
}
|
||||
|
||||
@ -869,7 +869,7 @@ func (t *Task) Update(s *xorm.Session, a web.Auth) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
targetBucket, err := setTaskBucket(s, t, &ot, t.BucketID != 0 && t.BucketID != ot.BucketID, project)
|
||||
targetBucket, err := setTaskBucket(s, t, &ot, t.BucketID != 0 && t.BucketID != ot.BucketID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user