This commit is contained in:
stuzer05 2023-02-24 14:08:38 +02:00
parent 870bb922cc
commit d247b0ffd1
9 changed files with 110 additions and 110 deletions

View File

@ -146,7 +146,7 @@ var commentStrings = []string{
"milestone",
"assignees",
"change_title",
"change_plan_time",
"change_time_estimate",
"delete_branch",
"start_tracking",
"stop_tracking",
@ -305,8 +305,8 @@ type Comment struct {
CommitsNum int64 `xorm:"-"`
IsForcePush bool `xorm:"-"`
PlanTimeHours int
PlanTimeMinutes int
TimeEstimateHours int
TimeEstimateMinutes int
}
func init() {
@ -793,40 +793,40 @@ func CreateComment(ctx context.Context, opts *CreateCommentOptions) (_ *Comment,
}
comment := &Comment{
Type: opts.Type,
PosterID: opts.Doer.ID,
Poster: opts.Doer,
IssueID: opts.Issue.ID,
LabelID: LabelID,
OldMilestoneID: opts.OldMilestoneID,
MilestoneID: opts.MilestoneID,
OldProjectID: opts.OldProjectID,
ProjectID: opts.ProjectID,
TimeID: opts.TimeID,
RemovedAssignee: opts.RemovedAssignee,
AssigneeID: opts.AssigneeID,
AssigneeTeamID: opts.AssigneeTeamID,
CommitID: opts.CommitID,
CommitSHA: opts.CommitSHA,
Line: opts.LineNum,
Content: opts.Content,
OldTitle: opts.OldTitle,
NewTitle: opts.NewTitle,
OldRef: opts.OldRef,
NewRef: opts.NewRef,
DependentIssueID: opts.DependentIssueID,
TreePath: opts.TreePath,
ReviewID: opts.ReviewID,
Patch: opts.Patch,
RefRepoID: opts.RefRepoID,
RefIssueID: opts.RefIssueID,
RefCommentID: opts.RefCommentID,
RefAction: opts.RefAction,
RefIsPull: opts.RefIsPull,
IsForcePush: opts.IsForcePush,
Invalidated: opts.Invalidated,
PlanTimeHours: opts.PlanTimeHours,
PlanTimeMinutes: opts.PlanTimeMinutes,
Type: opts.Type,
PosterID: opts.Doer.ID,
Poster: opts.Doer,
IssueID: opts.Issue.ID,
LabelID: LabelID,
OldMilestoneID: opts.OldMilestoneID,
MilestoneID: opts.MilestoneID,
OldProjectID: opts.OldProjectID,
ProjectID: opts.ProjectID,
TimeID: opts.TimeID,
RemovedAssignee: opts.RemovedAssignee,
AssigneeID: opts.AssigneeID,
AssigneeTeamID: opts.AssigneeTeamID,
CommitID: opts.CommitID,
CommitSHA: opts.CommitSHA,
Line: opts.LineNum,
Content: opts.Content,
OldTitle: opts.OldTitle,
NewTitle: opts.NewTitle,
OldRef: opts.OldRef,
NewRef: opts.NewRef,
DependentIssueID: opts.DependentIssueID,
TreePath: opts.TreePath,
ReviewID: opts.ReviewID,
Patch: opts.Patch,
RefRepoID: opts.RefRepoID,
RefIssueID: opts.RefIssueID,
RefCommentID: opts.RefCommentID,
RefAction: opts.RefAction,
RefIsPull: opts.RefIsPull,
IsForcePush: opts.IsForcePush,
Invalidated: opts.Invalidated,
TimeEstimateHours: opts.TimeEstimateHours,
TimeEstimateMinutes: opts.TimeEstimateMinutes,
}
if _, err = e.Insert(comment); err != nil {
return nil, err
@ -970,36 +970,36 @@ type CreateCommentOptions struct {
Issue *Issue
Label *Label
DependentIssueID int64
OldMilestoneID int64
MilestoneID int64
OldProjectID int64
ProjectID int64
TimeID int64
AssigneeID int64
AssigneeTeamID int64
RemovedAssignee bool
OldTitle string
NewTitle string
OldRef string
NewRef string
CommitID int64
CommitSHA string
Patch string
LineNum int64
TreePath string
ReviewID int64
Content string
Attachments []string // UUIDs of attachments
RefRepoID int64
RefIssueID int64
RefCommentID int64
RefAction references.XRefAction
RefIsPull bool
IsForcePush bool
Invalidated bool
PlanTimeHours int
PlanTimeMinutes int
DependentIssueID int64
OldMilestoneID int64
MilestoneID int64
OldProjectID int64
ProjectID int64
TimeID int64
AssigneeID int64
AssigneeTeamID int64
RemovedAssignee bool
OldTitle string
NewTitle string
OldRef string
NewRef string
CommitID int64
CommitSHA string
Patch string
LineNum int64
TreePath string
ReviewID int64
Content string
Attachments []string // UUIDs of attachments
RefRepoID int64
RefIssueID int64
RefCommentID int64
RefAction references.XRefAction
RefIsPull bool
IsForcePush bool
Invalidated bool
TimeEstimateHours int
TimeEstimateMinutes int
}
// GetCommentByID returns the comment by given ID.

View File

@ -148,8 +148,8 @@ type Issue struct {
ShowRole RoleDescriptor `xorm:"-"`
// Plan time
PlanTimeHours int
PlanTimeMinutes int
TimeEstimateHours int
TimeEstimateMinutes int
}
var (
@ -778,15 +778,15 @@ func ChangeIssueTitle(issue *Issue, doer *user_model.User, oldTitle string) (err
return committer.Commit()
}
// ChangeIssuePlanTime changes the plan time of this issue, as the given user.
func ChangeIssuePlanTime(issue *Issue, doer *user_model.User, planTimeHours, planTimeMinutes int) (err error) {
// ChangeIssueTimeEstimate changes the plan time of this issue, as the given user.
func ChangeIssueTimeEstimate(issue *Issue, doer *user_model.User, planTimeHours, planTimeMinutes int) (err error) {
ctx, committer, err := db.TxContext(db.DefaultContext)
if err != nil {
return err
}
defer committer.Close()
if err = UpdateIssueCols(ctx, &Issue{ID: issue.ID, PlanTimeHours: planTimeHours, PlanTimeMinutes: planTimeMinutes}, "plan_time_hours", "plan_time_minutes"); err != nil {
if err = UpdateIssueCols(ctx, &Issue{ID: issue.ID, TimeEstimateHours: planTimeHours, TimeEstimateMinutes: planTimeMinutes}, "time_estimate_hours", "plan_time_minutes"); err != nil {
return fmt.Errorf("updateIssueCols: %w", err)
}
@ -795,12 +795,12 @@ func ChangeIssuePlanTime(issue *Issue, doer *user_model.User, planTimeHours, pla
}
opts := &CreateCommentOptions{
Type: CommentTypeChangeTimeEstimate,
Doer: doer,
Repo: issue.Repo,
Issue: issue,
PlanTimeHours: planTimeHours,
PlanTimeMinutes: planTimeMinutes,
Type: CommentTypeChangeTimeEstimate,
Doer: doer,
Repo: issue.Repo,
Issue: issue,
TimeEstimateHours: planTimeHours,
TimeEstimateMinutes: planTimeMinutes,
}
if _, err = CreateComment(ctx, opts); err != nil {
return fmt.Errorf("createComment: %w", err)

View File

@ -41,21 +41,21 @@ type RepositoryMeta struct {
// Issue represents an issue in a repository
// swagger:model
type Issue struct {
ID int64 `json:"id"`
URL string `json:"url"`
HTMLURL string `json:"html_url"`
Index int64 `json:"number"`
Poster *User `json:"user"`
OriginalAuthor string `json:"original_author"`
OriginalAuthorID int64 `json:"original_author_id"`
Title string `json:"title"`
Body string `json:"body"`
Ref string `json:"ref"`
Attachments []*Attachment `json:"assets"`
Labels []*Label `json:"labels"`
Milestone *Milestone `json:"milestone"`
PlanTimeHours int64 `json:"plan_time_hours"`
PlanTimeMinutes int64 `json:"plan_time_minutes"`
ID int64 `json:"id"`
URL string `json:"url"`
HTMLURL string `json:"html_url"`
Index int64 `json:"number"`
Poster *User `json:"user"`
OriginalAuthor string `json:"original_author"`
OriginalAuthorID int64 `json:"original_author_id"`
Title string `json:"title"`
Body string `json:"body"`
Ref string `json:"ref"`
Attachments []*Attachment `json:"assets"`
Labels []*Label `json:"labels"`
Milestone *Milestone `json:"milestone"`
TimeEstimateHours int64 `json:"time_estimate_hours"`
TimeEstimateMinutes int64 `json:"plan_time_minutes"`
// deprecated
Assignee *User `json:"assignee"`
Assignees []*User `json:"assignees"`
@ -108,10 +108,10 @@ type EditIssueOption struct {
Milestone *int64 `json:"milestone"`
State *string `json:"state"`
// swagger:strfmt date-time
Deadline *time.Time `json:"due_date"`
PlanTimeHours int `json:"plan_time_hours"`
PlanTimeMinutes int `json:"plan_time_minutes"`
RemoveDeadline *bool `json:"unset_due_date"`
Deadline *time.Time `json:"due_date"`
TimeEstimateHours int `json:"time_estimate_hours"`
TimeEstimateMinutes int `json:"plan_time_minutes"`
RemoveDeadline *bool `json:"unset_due_date"`
}
// EditDeadlineOption options for creating a deadline

View File

@ -1301,7 +1301,7 @@ issues.add_assignee_at = `was assigned by <b>%s</b> %s`
issues.remove_assignee_at = `was unassigned by <b>%s</b> %s`
issues.remove_self_assignment = `removed their assignment %s`
issues.change_title_at = `changed title from <b><strike>%s</strike></b> to <b>%s</b> %s`
issues.tracker_estimate = `Time Estimate`
issues.tracker_time_estimate = `Time Estimate`
issues.change_time_estimate_at = `changed time estimate to <b>%d hour %d minutes</b> %s`
issues.remove_time_estimate = `removed time estimate %s`
issues.change_ref_at = `changed reference from <b><strike>%s</strike></b> to <b>%s</b> %s`

View File

@ -1982,10 +1982,10 @@ func UpdateIssuePlanTime(ctx *context.Context) {
return
}
planTimeHours := ctx.FormInt("plan_time_hours")
planTimeHours := ctx.FormInt("time_estimate_hours")
planTimeMinutes := ctx.FormInt("plan_time_minutes")
if issue.PlanTimeHours == planTimeHours && issue.PlanTimeMinutes == planTimeMinutes {
if issue.TimeEstimateHours == planTimeHours && issue.TimeEstimateMinutes == planTimeMinutes {
ctx.JSON(http.StatusOK, map[string]interface{}{
"status": "ok",
})

View File

@ -63,10 +63,10 @@ func ChangeTitle(issue *issues_model.Issue, doer *user_model.User, title string)
// ChangeTitle changes the title of this issue, as the given user.
func ChangePlanTime(issue *issues_model.Issue, doer *user_model.User, planTimeHours, planTimeMinutes int) (err error) {
issue.PlanTimeHours = planTimeHours
issue.PlanTimeMinutes = planTimeMinutes
issue.TimeEstimateHours = planTimeHours
issue.TimeEstimateMinutes = planTimeMinutes
if err = issues_model.ChangeIssuePlanTime(issue, doer, planTimeHours, planTimeMinutes); err != nil {
if err = issues_model.ChangeIssueTimeEstimate(issue, doer, planTimeHours, planTimeMinutes); err != nil {
return
}

View File

@ -799,10 +799,10 @@
{{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{if and (eq .PlanTimeHours 0) (eq .PlanTimeMinutes 0)}}
{{if and (eq .TimeEstimateHours 0) (eq .TimeEstimateMinutes 0)}}
{{$.locale.Tr "repo.issues.remove_time_estimate" $createdStr | Safe}}
{{else}}
{{$.locale.Tr "repo.issues.change_time_estimate_at" (.PlanTimeHours) (.PlanTimeMinutes) $createdStr | Safe}}
{{$.locale.Tr "repo.issues.change_time_estimate_at" (.TimeEstimateHours) (.TimeEstimateMinutes) $createdStr | Safe}}
{{end}}
</span>
</div>

View File

@ -360,13 +360,13 @@
{{if and .CanUseTimetracker (not .Repository.IsArchived)}}
<div class="ui divider"></div>
<div>
<span class="text"><strong>{{.locale.Tr "repo.issues.tracker_estimate"}}</strong></span>
<span class="text"><strong>{{.locale.Tr "repo.issues.tracker_time_estimate"}}</strong></span>
<form method="POST" id="set_plan_time_form" class="gt-mt-3" action="{{.Issue.Link}}/plan_time">
{{$.CsrfTokenHtml}}
<div class="ui action input fluid">
<input placeholder='{{.locale.Tr "repo.issues.add_time_hours"}}' type="number" min="0" value="{{ ($.Issue.PlanTimeHours) }}" name="plan_time_hours">
<input placeholder='{{.locale.Tr "repo.issues.add_time_minutes"}}' type="number" min="0" max="59" value="{{ ($.Issue.PlanTimeMinutes) }}" name="plan_time_minutes" class="ui compact">
<input placeholder='{{.locale.Tr "repo.issues.add_time_hours"}}' type="number" min="0" value="{{ ($.Issue.TimeEstimateHours) }}" name="time_estimate_hours">
<input placeholder='{{.locale.Tr "repo.issues.add_time_minutes"}}' type="number" min="0" max="59" value="{{ ($.Issue.TimeEstimateMinutes) }}" name="plan_time_minutes" class="ui compact">
</div>
<button class="ui fluid button green tooltip gt-mt-3">
{{.locale.Tr "repo.issues.save"}}

View File

@ -643,12 +643,12 @@ export function initRepoIssuePlanTimeEdit() {
$('#set_plan_time_form').on('submit', function(e) {
e.preventDefault();
const planTimeHours = $(this).find('[name=plan_time_hours]').val();
const planTimeHours = $(this).find('[name=time_estimate_hours]').val();
const planTimeMinutes = $(this).find('[name=plan_time_minutes]').val();
$.post($(this).attr('action'), {
_csrf: csrfToken,
plan_time_hours: planTimeHours,
time_estimate_hours: planTimeHours,
plan_time_minutes: planTimeMinutes,
}).always(() => {
window.location.reload();