mirror of
https://github.com/go-gitea/gitea.git
synced 2024-09-30 03:26:01 -04:00
support assignees
This commit is contained in:
parent
ec771fdfcd
commit
13cea95de1
@ -452,6 +452,7 @@ name: Name
|
||||
title: Title
|
||||
about: About
|
||||
labels: ["label1", "label2"]
|
||||
assignees: ["user1", "user2"]
|
||||
ref: Ref
|
||||
body:
|
||||
- type: markdown
|
||||
@ -513,6 +514,7 @@ body:
|
||||
Title: "Title",
|
||||
About: "About",
|
||||
Labels: []string{"label1", "label2"},
|
||||
Assignees: []string{"user1", "user2"},
|
||||
Ref: "Ref",
|
||||
Fields: []*api.IssueFormField{
|
||||
{
|
||||
|
@ -179,16 +179,17 @@ type IssueTemplate struct {
|
||||
Name string `json:"name" yaml:"name"`
|
||||
Title string `json:"title" yaml:"title"`
|
||||
About string `json:"about" yaml:"about"` // Using "description" in a template file is compatible
|
||||
Labels IssueTemplateLabels `json:"labels" yaml:"labels"`
|
||||
Labels IssueTemplateStringSlice `json:"labels" yaml:"labels"`
|
||||
Assignees IssueTemplateStringSlice `json:"assignees" yaml:"assignees"`
|
||||
Ref string `json:"ref" yaml:"ref"`
|
||||
Content string `json:"content" yaml:"-"`
|
||||
Fields []*IssueFormField `json:"body" yaml:"body"`
|
||||
FileName string `json:"file_name" yaml:"-"`
|
||||
}
|
||||
|
||||
type IssueTemplateLabels []string
|
||||
type IssueTemplateStringSlice []string
|
||||
|
||||
func (l *IssueTemplateLabels) UnmarshalYAML(value *yaml.Node) error {
|
||||
func (l *IssueTemplateStringSlice) UnmarshalYAML(value *yaml.Node) error {
|
||||
var labels []string
|
||||
if value.IsZero() {
|
||||
*l = labels
|
||||
@ -216,7 +217,7 @@ func (l *IssueTemplateLabels) UnmarshalYAML(value *yaml.Node) error {
|
||||
*l = labels
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("line %d: cannot unmarshal %s into IssueTemplateLabels", value.Line, value.ShortTag())
|
||||
return fmt.Errorf("line %d: cannot unmarshal %s into IssueTemplateStringSlice", value.Line, value.ShortTag())
|
||||
}
|
||||
|
||||
type IssueConfigContactLink struct {
|
||||
|
@ -934,12 +934,23 @@ func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleFiles
|
||||
}
|
||||
}
|
||||
}
|
||||
selectedAssigneeIDs := make([]int64, 0, len(template.Assignees))
|
||||
selectedAssigneeIDStrings := make([]string, 0, len(template.Assignees))
|
||||
if userIDs, err := user_model.GetUserIDsByNames(ctx, template.Assignees, false); err == nil {
|
||||
for _, userID := range userIDs {
|
||||
selectedAssigneeIDs = append(selectedAssigneeIDs, userID)
|
||||
selectedAssigneeIDStrings = append(selectedAssigneeIDStrings, strconv.FormatInt(userID, 10))
|
||||
}
|
||||
}
|
||||
|
||||
if template.Ref != "" && !strings.HasPrefix(template.Ref, "refs/") { // Assume that the ref intended is always a branch - for tags users should use refs/tags/<ref>
|
||||
template.Ref = git.BranchPrefix + template.Ref
|
||||
}
|
||||
ctx.Data["HasSelectedLabel"] = len(labelIDs) > 0
|
||||
ctx.Data["label_ids"] = strings.Join(labelIDs, ",")
|
||||
ctx.Data["HasSelectedAssignee"] = len(selectedAssigneeIDs) > 0
|
||||
ctx.Data["selected_assignee_ids_value"] = strings.Join(selectedAssigneeIDStrings, ",")
|
||||
ctx.Data["selected_assignee_ids"] = selectedAssigneeIDs
|
||||
ctx.Data["Reference"] = template.Ref
|
||||
ctx.Data["RefEndName"] = git.RefName(template.Ref).ShortName()
|
||||
return true, templateErrs
|
||||
|
@ -140,7 +140,7 @@
|
||||
</div>
|
||||
{{end}}
|
||||
<div class="divider"></div>
|
||||
<input id="assignee_ids" name="assignee_ids" type="hidden" value="{{.assignee_ids}}">
|
||||
<input id="assignee_ids" name="assignee_ids" type="hidden" value="{{.selected_assignee_ids_value}}">
|
||||
<div class="ui {{if not .HasIssuesOrPullsWritePermission}}disabled{{end}} floating jump select-assignees dropdown">
|
||||
<span class="text flex-text-block">
|
||||
<strong>{{ctx.Locale.Tr "repo.issues.new.assignees"}}</strong>
|
||||
@ -155,8 +155,8 @@
|
||||
</div>
|
||||
<div class="no-select item">{{ctx.Locale.Tr "repo.issues.new.clear_assignees"}}</div>
|
||||
{{range .Assignees}}
|
||||
<a class="item muted" href="#" data-id="{{.ID}}" data-id-selector="#assignee_{{.ID}}">
|
||||
<span class="octicon-check tw-invisible">{{svg "octicon-check"}}</span>
|
||||
<a class="{{if SliceUtils.Contains $.selected_assignee_ids .ID}}checked{{end}} item muted" href="#" data-id="{{.ID}}" data-id-selector="#assignee_{{.ID}}">
|
||||
<span class="octicon-check {{if not (SliceUtils.Contains $.selected_assignee_ids .ID)}}tw-invisible{{end}}">{{svg "octicon-check"}}</span>
|
||||
<span class="text">
|
||||
{{ctx.AvatarUtils.Avatar . 28 "tw-mr-2"}}{{template "repo/search_name" .}}
|
||||
</span>
|
||||
@ -165,12 +165,12 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui assignees list">
|
||||
<span class="no-select item {{if .HasSelectedLabel}}tw-hidden{{end}}">
|
||||
<span class="no-select item {{if .HasSelectedAssignee}}tw-hidden{{end}}">
|
||||
{{ctx.Locale.Tr "repo.issues.new.no_assignees"}}
|
||||
</span>
|
||||
<div class="selected">
|
||||
{{range .Assignees}}
|
||||
<a class="item tw-p-1 muted tw-hidden" id="assignee_{{.ID}}" href="{{$.RepoLink}}/issues?assignee={{.ID}}">
|
||||
<a class="item tw-p-1 muted {{if not (SliceUtils.Contains $.selected_assignee_ids .ID)}}tw-hidden{{end}}" id="assignee_{{.ID}}" href="{{$.RepoLink}}/issues?assignee={{.ID}}">
|
||||
{{ctx.AvatarUtils.Avatar . 28 "tw-mr-2 tw-align-middle"}}{{.GetDisplayName}}
|
||||
</a>
|
||||
{{end}}
|
||||
|
Loading…
Reference in New Issue
Block a user