Add UI to delete tracked times (#14100)
Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
6a696b93b1
commit
d38ae597e1
13 changed files with 123 additions and 4 deletions
|
@ -136,6 +136,8 @@ type Comment struct {
|
|||
MilestoneID int64
|
||||
OldMilestone *Milestone `xorm:"-"`
|
||||
Milestone *Milestone `xorm:"-"`
|
||||
TimeID int64
|
||||
Time *TrackedTime `xorm:"-"`
|
||||
AssigneeID int64
|
||||
RemovedAssignee bool
|
||||
Assignee *User `xorm:"-"`
|
||||
|
@ -541,6 +543,16 @@ func (c *Comment) LoadDepIssueDetails() (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
// LoadTime loads the associated time for a CommentTypeAddTimeManual
|
||||
func (c *Comment) LoadTime() error {
|
||||
if c.Time != nil || c.TimeID == 0 {
|
||||
return nil
|
||||
}
|
||||
var err error
|
||||
c.Time, err = GetTrackedTimeByID(c.TimeID)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Comment) loadReactions(e Engine, repo *Repository) (err error) {
|
||||
if c.Reactions != nil {
|
||||
return nil
|
||||
|
@ -692,6 +704,7 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
|
|||
MilestoneID: opts.MilestoneID,
|
||||
OldProjectID: opts.OldProjectID,
|
||||
ProjectID: opts.ProjectID,
|
||||
TimeID: opts.TimeID,
|
||||
RemovedAssignee: opts.RemovedAssignee,
|
||||
AssigneeID: opts.AssigneeID,
|
||||
AssigneeTeamID: opts.AssigneeTeamID,
|
||||
|
@ -859,6 +872,7 @@ type CreateCommentOptions struct {
|
|||
MilestoneID int64
|
||||
OldProjectID int64
|
||||
ProjectID int64
|
||||
TimeID int64
|
||||
AssigneeID int64
|
||||
AssigneeTeamID int64
|
||||
RemovedAssignee bool
|
||||
|
|
|
@ -100,6 +100,7 @@ func CreateOrStopIssueStopwatch(user *User, issue *Issue) error {
|
|||
Repo: issue.Repo,
|
||||
Content: SecToTime(timediff),
|
||||
Type: CommentTypeStopTracking,
|
||||
TimeID: tt.ID,
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -162,6 +162,7 @@ func AddTime(user *User, issue *Issue, amount int64, created time.Time) (*Tracke
|
|||
Doer: user,
|
||||
Content: SecToTime(amount),
|
||||
Type: CommentTypeAddTimeManual,
|
||||
TimeID: t.ID,
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -292,6 +292,8 @@ var migrations = []Migration{
|
|||
NewMigration("Add Sorting to ProjectBoard table", addSortingColToProjectBoard),
|
||||
// v172 -> v173
|
||||
NewMigration("Add sessions table for go-chi/session", addSessionTable),
|
||||
// v173 -> v174
|
||||
NewMigration("Add time_id column to Comment", addTimeIDCommentColumn),
|
||||
}
|
||||
|
||||
// GetCurrentDBVersion returns the current db version
|
||||
|
|
22
models/migrations/v173.go
Normal file
22
models/migrations/v173.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
func addTimeIDCommentColumn(x *xorm.Engine) error {
|
||||
type Comment struct {
|
||||
TimeID int64
|
||||
}
|
||||
|
||||
if err := x.Sync2(new(Comment)); err != nil {
|
||||
return fmt.Errorf("Sync2: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue