mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-18 16:03:07 +00:00
Issue Templates: add option to have dropdown printed list (#31577)
Issue template dropdown can have many entries, and it could be better to have them rendered as list later on if multi-select is enabled. so this adds an option to the issue template engine to do so. DOCS: https://gitea.com/gitea/docs/pulls/19 --- ## demo: ```yaml name: Name title: Title about: About labels: ["label1", "label2"] ref: Ref body: - type: dropdown id: id6 attributes: label: Label of dropdown (list) description: Description of dropdown multiple: true list: true options: - Option 1 of dropdown - Option 2 of dropdown - Option 3 of dropdown - Option 4 of dropdown - Option 5 of dropdown - Option 6 of dropdown - Option 7 of dropdown - Option 8 of dropdown - Option 9 of dropdown ```   --- *Sponsored by Kithara Software GmbH* (cherry picked from commit 1064e817c4a6fa6eb5170143150505503c4ef6ed)
This commit is contained in:
parent
d405143919
commit
d0227c236a
2 changed files with 48 additions and 6 deletions
|
@ -88,6 +88,9 @@ func validateYaml(template *api.IssueTemplate) error {
|
|||
if err := validateBoolItem(position, field.Attributes, "multiple"); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validateBoolItem(position, field.Attributes, "list"); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validateOptions(field, idx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -340,7 +343,13 @@ func (f *valuedField) WriteTo(builder *strings.Builder) {
|
|||
}
|
||||
}
|
||||
if len(checkeds) > 0 {
|
||||
_, _ = fmt.Fprintf(builder, "%s\n", strings.Join(checkeds, ", "))
|
||||
if list, ok := f.Attributes["list"].(bool); ok && list {
|
||||
for _, check := range checkeds {
|
||||
_, _ = fmt.Fprintf(builder, "- %s\n", check)
|
||||
}
|
||||
} else {
|
||||
_, _ = fmt.Fprintf(builder, "%s\n", strings.Join(checkeds, ", "))
|
||||
}
|
||||
} else {
|
||||
_, _ = fmt.Fprint(builder, blankPlaceholder)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue