mirror of
https://github.com/go-gitea/gitea
synced 2024-06-03 03:46:51 +02:00
Commit
This commit is contained in:
parent
d247b0ffd1
commit
09c05e8b76
|
@ -147,7 +147,7 @@ type Issue struct {
|
||||||
// For view issue page.
|
// For view issue page.
|
||||||
ShowRole RoleDescriptor `xorm:"-"`
|
ShowRole RoleDescriptor `xorm:"-"`
|
||||||
|
|
||||||
// Plan time
|
// Time estimate
|
||||||
TimeEstimateHours int
|
TimeEstimateHours int
|
||||||
TimeEstimateMinutes int
|
TimeEstimateMinutes int
|
||||||
}
|
}
|
||||||
|
@ -779,14 +779,14 @@ func ChangeIssueTitle(issue *Issue, doer *user_model.User, oldTitle string) (err
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeIssueTimeEstimate changes the plan time of this issue, as the given user.
|
// 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) {
|
func ChangeIssueTimeEstimate(issue *Issue, doer *user_model.User, timeEstimateHours, timeEstimateMinutes int) (err error) {
|
||||||
ctx, committer, err := db.TxContext(db.DefaultContext)
|
ctx, committer, err := db.TxContext(db.DefaultContext)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer committer.Close()
|
defer committer.Close()
|
||||||
|
|
||||||
if err = UpdateIssueCols(ctx, &Issue{ID: issue.ID, TimeEstimateHours: planTimeHours, TimeEstimateMinutes: planTimeMinutes}, "time_estimate_hours", "plan_time_minutes"); err != nil {
|
if err = UpdateIssueCols(ctx, &Issue{ID: issue.ID, TimeEstimateHours: timeEstimateHours, TimeEstimateMinutes: timeEstimateMinutes}, "time_estimate_hours", "time_estimate_minutes"); err != nil {
|
||||||
return fmt.Errorf("updateIssueCols: %w", err)
|
return fmt.Errorf("updateIssueCols: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -799,8 +799,8 @@ func ChangeIssueTimeEstimate(issue *Issue, doer *user_model.User, planTimeHours,
|
||||||
Doer: doer,
|
Doer: doer,
|
||||||
Repo: issue.Repo,
|
Repo: issue.Repo,
|
||||||
Issue: issue,
|
Issue: issue,
|
||||||
TimeEstimateHours: planTimeHours,
|
TimeEstimateHours: timeEstimateHours,
|
||||||
TimeEstimateMinutes: planTimeMinutes,
|
TimeEstimateMinutes: timeEstimateMinutes,
|
||||||
}
|
}
|
||||||
if _, err = CreateComment(ctx, opts); err != nil {
|
if _, err = CreateComment(ctx, opts); err != nil {
|
||||||
return fmt.Errorf("createComment: %w", err)
|
return fmt.Errorf("createComment: %w", err)
|
||||||
|
|
|
@ -55,7 +55,7 @@ type Issue struct {
|
||||||
Labels []*Label `json:"labels"`
|
Labels []*Label `json:"labels"`
|
||||||
Milestone *Milestone `json:"milestone"`
|
Milestone *Milestone `json:"milestone"`
|
||||||
TimeEstimateHours int64 `json:"time_estimate_hours"`
|
TimeEstimateHours int64 `json:"time_estimate_hours"`
|
||||||
TimeEstimateMinutes int64 `json:"plan_time_minutes"`
|
TimeEstimateMinutes int64 `json:"time_estimate_minutes"`
|
||||||
// deprecated
|
// deprecated
|
||||||
Assignee *User `json:"assignee"`
|
Assignee *User `json:"assignee"`
|
||||||
Assignees []*User `json:"assignees"`
|
Assignees []*User `json:"assignees"`
|
||||||
|
@ -110,7 +110,7 @@ type EditIssueOption struct {
|
||||||
// swagger:strfmt date-time
|
// swagger:strfmt date-time
|
||||||
Deadline *time.Time `json:"due_date"`
|
Deadline *time.Time `json:"due_date"`
|
||||||
TimeEstimateHours int `json:"time_estimate_hours"`
|
TimeEstimateHours int `json:"time_estimate_hours"`
|
||||||
TimeEstimateMinutes int `json:"plan_time_minutes"`
|
TimeEstimateMinutes int `json:"time_estimate_minutes"`
|
||||||
RemoveDeadline *bool `json:"unset_due_date"`
|
RemoveDeadline *bool `json:"unset_due_date"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1970,8 +1970,8 @@ func UpdateIssueTitle(ctx *context.Context) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateIssuePlanTime change issue's planned time
|
// UpdateIssueTimeEstimate change issue's planned time
|
||||||
func UpdateIssuePlanTime(ctx *context.Context) {
|
func UpdateIssueTimeEstimate(ctx *context.Context) {
|
||||||
issue := GetActionIssue(ctx)
|
issue := GetActionIssue(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
|
@ -1982,18 +1982,18 @@ func UpdateIssuePlanTime(ctx *context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
planTimeHours := ctx.FormInt("time_estimate_hours")
|
timeEstimateHours := ctx.FormInt("time_estimate_hours")
|
||||||
planTimeMinutes := ctx.FormInt("plan_time_minutes")
|
timeEstimateMinutes := ctx.FormInt("time_estimate_minutes")
|
||||||
|
|
||||||
if issue.TimeEstimateHours == planTimeHours && issue.TimeEstimateMinutes == planTimeMinutes {
|
if issue.TimeEstimateHours == timeEstimateHours && issue.TimeEstimateMinutes == timeEstimateMinutes {
|
||||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||||
"status": "ok",
|
"status": "ok",
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := issue_service.ChangePlanTime(issue, ctx.Doer, planTimeHours, planTimeMinutes); err != nil {
|
if err := issue_service.ChangeTimeEstimate(issue, ctx.Doer, timeEstimateHours, timeEstimateMinutes); err != nil {
|
||||||
ctx.ServerError("ChangePlanTime", err)
|
ctx.ServerError("ChangeTimeEstimate", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1069,7 +1069,7 @@ func RegisterRoutes(m *web.Route) {
|
||||||
// So they can apply their own enable/disable logic on routers.
|
// So they can apply their own enable/disable logic on routers.
|
||||||
m.Group("/{type:issues|pulls}", func() {
|
m.Group("/{type:issues|pulls}", func() {
|
||||||
m.Group("/{index}", func() {
|
m.Group("/{index}", func() {
|
||||||
m.Post("/plan_time", repo.UpdateIssuePlanTime)
|
m.Post("/time_estimate", repo.UpdateIssueTimeEstimate)
|
||||||
m.Post("/title", repo.UpdateIssueTitle)
|
m.Post("/title", repo.UpdateIssueTitle)
|
||||||
m.Post("/content", repo.UpdateIssueContent)
|
m.Post("/content", repo.UpdateIssueContent)
|
||||||
m.Post("/deadline", web.Bind(structs.EditDeadlineOption{}), repo.UpdateIssueDeadline)
|
m.Post("/deadline", web.Bind(structs.EditDeadlineOption{}), repo.UpdateIssueDeadline)
|
||||||
|
|
|
@ -62,11 +62,11 @@ func ChangeTitle(issue *issues_model.Issue, doer *user_model.User, title string)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeTitle changes the title of this issue, as the given user.
|
// 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) {
|
func ChangeTimeEstimate(issue *issues_model.Issue, doer *user_model.User, timeEstimateHours, timeEstimateMinutes int) (err error) {
|
||||||
issue.TimeEstimateHours = planTimeHours
|
issue.TimeEstimateHours = timeEstimateHours
|
||||||
issue.TimeEstimateMinutes = planTimeMinutes
|
issue.TimeEstimateMinutes = timeEstimateMinutes
|
||||||
|
|
||||||
if err = issues_model.ChangeIssueTimeEstimate(issue, doer, planTimeHours, planTimeMinutes); err != nil {
|
if err = issues_model.ChangeIssueTimeEstimate(issue, doer, timeEstimateHours, timeEstimateMinutes); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -362,11 +362,11 @@
|
||||||
<div>
|
<div>
|
||||||
<span class="text"><strong>{{.locale.Tr "repo.issues.tracker_time_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">
|
<form method="POST" id="set_time_estimate_form" class="gt-mt-3" action="{{.Issue.Link}}/time_estimate">
|
||||||
{{$.CsrfTokenHtml}}
|
{{$.CsrfTokenHtml}}
|
||||||
<div class="ui action input fluid">
|
<div class="ui action input fluid">
|
||||||
<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_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">
|
<input placeholder='{{.locale.Tr "repo.issues.add_time_minutes"}}' type="number" min="0" max="59" value="{{ ($.Issue.TimeEstimateMinutes) }}" name="time_estimate_minutes" class="ui compact">
|
||||||
</div>
|
</div>
|
||||||
<button class="ui fluid button green tooltip gt-mt-3">
|
<button class="ui fluid button green tooltip gt-mt-3">
|
||||||
{{.locale.Tr "repo.issues.save"}}
|
{{.locale.Tr "repo.issues.save"}}
|
||||||
|
|
|
@ -640,16 +640,16 @@ export function initRepoIssueTitleEdit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initRepoIssuePlanTimeEdit() {
|
export function initRepoIssuePlanTimeEdit() {
|
||||||
$('#set_plan_time_form').on('submit', function(e) {
|
$('#set_time_estimate_form').on('submit', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const planTimeHours = $(this).find('[name=time_estimate_hours]').val();
|
const timeEstimateHours = $(this).find('[name=time_estimate_hours]').val();
|
||||||
const planTimeMinutes = $(this).find('[name=plan_time_minutes]').val();
|
const timeEstimateMinutes = $(this).find('[name=time_estimate_minutes]').val();
|
||||||
|
|
||||||
$.post($(this).attr('action'), {
|
$.post($(this).attr('action'), {
|
||||||
_csrf: csrfToken,
|
_csrf: csrfToken,
|
||||||
time_estimate_hours: planTimeHours,
|
time_estimate_hours: timeEstimateHours,
|
||||||
plan_time_minutes: planTimeMinutes,
|
time_estimate_minutes: timeEstimateMinutes,
|
||||||
}).always(() => {
|
}).always(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user