This commit is contained in:
stuzer05 2024-11-22 12:33:08 +02:00
parent 10767d7bb2
commit b24c958da6
No known key found for this signature in database
GPG Key ID: A6ABAAA9268F9F4F
5 changed files with 63 additions and 1530 deletions

View File

@ -1694,7 +1694,7 @@ issues.add_time_hours = Hours
issues.add_time_minutes = Minutes
issues.add_time_sum_to_small = No time was entered.
issues.time_spent_total = Total Time Spent
issues.time_spent_from_all_authors = `Total Time Spent:`
issues.time_spent_from_all_authors = `Total Time Spent: %s`
issues.due_date = Due Date
issues.invalid_due_date_format = "Due date format must be 'yyyy-mm-dd'."
issues.error_modifying_due_date = "Failed to modify the due date."

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,7 @@ import (
"fmt"
"html/template"
"net/http"
"regexp"
"slices"
"sort"
"strconv"
@ -401,3 +402,54 @@ func NewIssuePost(ctx *context.Context) {
ctx.JSONRedirect(issue.Link())
}
}
// UpdateIssueTimeEstimate change issue's planned time
var (
rTimeEstimateStr = regexp.MustCompile(`^([\d]+w)?\s?([\d]+d)?\s?([\d]+h)?\s?([\d]+m)?$`)
rTimeEstimateStrHoursOnly = regexp.MustCompile(`^([\d]+)$`)
)
func UpdateIssueTimeEstimate(ctx *context.Context) {
issue := GetActionIssue(ctx)
if ctx.Written() {
return
}
if !ctx.IsSigned || (!issue.IsPoster(ctx.Doer.ID) && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) {
ctx.Error(http.StatusForbidden)
return
}
url := issue.Link()
timeStr := ctx.FormString("time_estimate")
// Validate input
if !rTimeEstimateStr.MatchString(timeStr) && !rTimeEstimateStrHoursOnly.MatchString(timeStr) {
ctx.Flash.Error(ctx.Tr("repo.issues.time_estimate_invalid"))
ctx.Redirect(url, http.StatusSeeOther)
return
}
total := util.TimeEstimateFromStr(timeStr)
// User entered something wrong
if total == 0 && len(timeStr) != 0 {
ctx.Flash.Error(ctx.Tr("repo.issues.time_estimate_invalid"))
ctx.Redirect(url, http.StatusSeeOther)
return
}
// No time changed
if issue.TimeEstimate == total {
ctx.Redirect(url, http.StatusSeeOther)
return
}
if err := issue_service.ChangeTimeEstimate(ctx, issue, ctx.Doer, total); err != nil {
ctx.ServerError("ChangeTimeEstimate", err)
return
}
ctx.Redirect(url, http.StatusSeeOther)
}

View File

@ -48,8 +48,7 @@
<div class="content">
<form method="post" id="add_time_manual_form" action="{{.Issue.Link}}/times/add" class="ui input fluid tw-gap-2">
{{$.CsrfTokenHtml}}
<input placeholder='{{ctx.Locale.Tr "repo.issues.add_time_hours"}}' type="number" name="hours">
<input placeholder='{{ctx.Locale.Tr "repo.issues.add_time_minutes"}}' type="number" name="minutes" class="ui compact">
<input placeholder="{{ctx.Locale.Tr "repo.issues.add_time_estimate"}}" type="text" name="time_string" dir="auto">
</form>
</div>
<div class="actions">

View File

@ -710,7 +710,14 @@
{{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{ctx.Locale.Tr "repo.issues.change_time_estimate_at" .RenderedContent $createdStr | SafeHTML}}
{{if .RenderedContent}}
{{/* compatibility with time comments made before v1.21 */}}
{{ctx.Locale.Tr "repo.issues.change_time_estimate_at" .RenderedContent $createdStr | SafeHTML}}
{{else}}
{{$timeStr := .Content|Sec2Time}}
{{ctx.Locale.Tr "repo.issues.change_time_estimate_at" $timeStr $createdStr | SafeHTML}}
{{end}}
</span>
</div>
{{end}}