loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

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
```

![image](https://github.com/user-attachments/assets/102ed0f4-89da-420b-ab2a-1788b59676f9)

![image](https://github.com/user-attachments/assets/a2bdb14e-43ff-4cc6-9bbe-20244830453c)

---
*Sponsored by Kithara Software GmbH*

(cherry picked from commit 1064e817c4a6fa6eb5170143150505503c4ef6ed)

authored by

6543 and committed by
Gergely Nagy
d0227c23 d4051439

+48 -6
+10 -1
modules/issue/template/template.go
··· 88 88 if err := validateBoolItem(position, field.Attributes, "multiple"); err != nil { 89 89 return err 90 90 } 91 + if err := validateBoolItem(position, field.Attributes, "list"); err != nil { 92 + return err 93 + } 91 94 if err := validateOptions(field, idx); err != nil { 92 95 return err 93 96 } ··· 340 343 } 341 344 } 342 345 if len(checkeds) > 0 { 343 - _, _ = fmt.Fprintf(builder, "%s\n", strings.Join(checkeds, ", ")) 346 + if list, ok := f.Attributes["list"].(bool); ok && list { 347 + for _, check := range checkeds { 348 + _, _ = fmt.Fprintf(builder, "- %s\n", check) 349 + } 350 + } else { 351 + _, _ = fmt.Fprintf(builder, "%s\n", strings.Join(checkeds, ", ")) 352 + } 344 353 } else { 345 354 _, _ = fmt.Fprint(builder, blankPlaceholder) 346 355 }
+38 -5
modules/issue/template/template_test.go
··· 217 217 wantErr: "body[0](dropdown): 'multiple' should be a bool", 218 218 }, 219 219 { 220 + name: "dropdown invalid list", 221 + content: ` 222 + name: "test" 223 + about: "this is about" 224 + body: 225 + - type: "dropdown" 226 + id: "1" 227 + attributes: 228 + label: "a" 229 + list: "on" 230 + `, 231 + wantErr: "body[0](dropdown): 'list' should be a bool", 232 + }, 233 + { 220 234 name: "checkboxes invalid description", 221 235 content: ` 222 236 name: "test" ··· 807 821 - type: dropdown 808 822 id: id5 809 823 attributes: 810 - label: Label of dropdown 824 + label: Label of dropdown (one line) 825 + description: Description of dropdown 826 + multiple: true 827 + options: 828 + - Option 1 of dropdown 829 + - Option 2 of dropdown 830 + - Option 3 of dropdown 831 + validations: 832 + required: true 833 + - type: dropdown 834 + id: id6 835 + attributes: 836 + label: Label of dropdown (list) 811 837 description: Description of dropdown 812 838 multiple: true 839 + list: true 813 840 options: 814 841 - Option 1 of dropdown 815 842 - Option 2 of dropdown ··· 817 844 validations: 818 845 required: true 819 846 - type: checkboxes 820 - id: id6 847 + id: id7 821 848 attributes: 822 849 label: Label of checkboxes 823 850 description: Description of checkboxes ··· 836 863 "form-field-id3": {"Value of id3"}, 837 864 "form-field-id4": {"Value of id4"}, 838 865 "form-field-id5": {"0,1"}, 839 - "form-field-id6-0": {"on"}, 840 - "form-field-id6-2": {"on"}, 866 + "form-field-id6": {"1,2"}, 867 + "form-field-id7-0": {"on"}, 868 + "form-field-id7-2": {"on"}, 841 869 }, 842 870 }, 843 871 ··· 849 877 850 878 Value of id4 851 879 852 - ### Label of dropdown 880 + ### Label of dropdown (one line) 853 881 854 882 Option 1 of dropdown, Option 2 of dropdown 883 + 884 + ### Label of dropdown (list) 885 + 886 + - Option 2 of dropdown 887 + - Option 3 of dropdown 855 888 856 889 ### Label of checkboxes 857 890