Extend issue template yaml engine (#29274)

Add new option:

`visible`: witch can hide a specific field of the form or the created
content afterwards

It is a string array witch can contain `form` and `content`. If only
`form` is present, it wont show up in the created issue afterwards and
the other way around. By default it sets both except for markdown

As they are optional and github don't have any similar thing, it is non
breaking and also do not conflict with it.

With this you can:
- define "post issue creation" elements like a TODO list to track an
issue state
- make sure to have a checkbox that reminds the user to check for a
thing but dont have it in the created issue afterwards
- define markdown for the created issue (was the downside of using yaml
instead of md in the past)
 - ...

## Demo

```yaml
name: New Contribution
description: External Contributor creating a pull

body:
- type: checkboxes
  id: extern-todo
  visible: [form]
  attributes:
    label: Contribution Guidelines
    options:
      - label: I checked there exist no similar feature to be extended
        required: true
      - label: I did read the CONTRIBUTION.MD
        required: true
- type: checkboxes
  id: intern-todo
  visible: [content]
  attributes:
    label: Maintainer Check-List
    options:
      - label: Does this pull follow the KISS principe
      - label: Checked if internal bord was notifyed
# ....
```
[Demo
Video](https://cloud.obermui.de/s/tm34fSAbJp9qw9z/download/vid-20240220-152751.mkv)

---
*Sponsored by Kithara Software GmbH*

---------

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
(cherry picked from commit 77e29e0c39392f142627303bd798fb55258072b2)
This commit is contained in:
6543 2024-03-04 01:37:00 +01:00 committed by Earl Warren
parent ba7983aedc
commit ff8f7a7a0d
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
11 changed files with 247 additions and 50 deletions

View file

@ -135,6 +135,12 @@ body:
attributes: attributes:
value: | value: |
Thanks for taking the time to fill out this bug report! Thanks for taking the time to fill out this bug report!
# some markdown that will only be visible once the issue has been created
- type: markdown
attributes:
value: |
This issue was created by an issue **template** :)
visible: [content]
- type: input - type: input
id: contact id: contact
attributes: attributes:
@ -186,11 +192,16 @@ body:
options: options:
- label: I agree to follow this project's Code of Conduct - label: I agree to follow this project's Code of Conduct
required: true required: true
- label: I have also read the CONTRIBUTION.MD
required: true
visible: [form]
- label: This is a TODO only visible after issue creation
visible: [content]
``` ```
### Markdown ### Markdown
You can use a `markdown` element to display Markdown in your form that provides extra context to the user, but is not submitted. You can use a `markdown` element to display Markdown in your form that provides extra context to the user, but is not submitted by default.
Attributes: Attributes:
@ -198,6 +209,8 @@ Attributes:
|-------|--------------------------------------------------------------|----------|--------|---------|--------------| |-------|--------------------------------------------------------------|----------|--------|---------|--------------|
| value | The text that is rendered. Markdown formatting is supported. | Required | String | - | - | | value | The text that is rendered. Markdown formatting is supported. | Required | String | - | - |
visible: Default is **[form]**
### Textarea ### Textarea
You can use a `textarea` element to add a multi-line text field to your form. Contributors can also attach files in `textarea` fields. You can use a `textarea` element to add a multi-line text field to your form. Contributors can also attach files in `textarea` fields.
@ -218,6 +231,8 @@ Validations:
|----------|------------------------------------------------------|----------|---------|---------|--------------| |----------|------------------------------------------------------|----------|---------|---------|--------------|
| required | Prevents form submission until element is completed. | Optional | Boolean | false | - | | required | Prevents form submission until element is completed. | Optional | Boolean | false | - |
visible: Default is **[form, content]**
### Input ### Input
You can use an `input` element to add a single-line text field to your form. You can use an `input` element to add a single-line text field to your form.
@ -239,6 +254,8 @@ Validations:
| is_number | Prevents form submission until element is filled with a number. | Optional | Boolean | false | - | | is_number | Prevents form submission until element is filled with a number. | Optional | Boolean | false | - |
| regex | Prevents form submission until element is filled with a value that match the regular expression. | Optional | String | - | a [regular expression](https://en.wikipedia.org/wiki/Regular_expression) | | regex | Prevents form submission until element is filled with a value that match the regular expression. | Optional | String | - | a [regular expression](https://en.wikipedia.org/wiki/Regular_expression) |
visible: Default is **[form, content]**
### Dropdown ### Dropdown
You can use a `dropdown` element to add a dropdown menu in your form. You can use a `dropdown` element to add a dropdown menu in your form.
@ -258,6 +275,8 @@ Validations:
|----------|------------------------------------------------------|----------|---------|---------|--------------| |----------|------------------------------------------------------|----------|---------|---------|--------------|
| required | Prevents form submission until element is completed. | Optional | Boolean | false | - | | required | Prevents form submission until element is completed. | Optional | Boolean | false | - |
visible: Default is **[form, content]**
### Checkboxes ### Checkboxes
You can use the `checkboxes` element to add a set of checkboxes to your form. You can use the `checkboxes` element to add a set of checkboxes to your form.
@ -265,7 +284,7 @@ You can use the `checkboxes` element to add a set of checkboxes to your form.
Attributes: Attributes:
| Key | Description | Required | Type | Default | Valid values | | Key | Description | Required | Type | Default | Valid values |
|-------------|-------------------------------------------------------------------------------------------------------|----------|--------|--------------|--------------| | ----------- | ----------------------------------------------------------------------------------------------------- | -------- | ------ | ------------ | ------------ |
| label | A brief description of the expected user input, which is displayed in the form. | Required | String | - | - | | label | A brief description of the expected user input, which is displayed in the form. | Required | String | - | - |
| description | A description of the set of checkboxes, which is displayed in the form. Supports Markdown formatting. | Optional | String | Empty String | - | | description | A description of the set of checkboxes, which is displayed in the form. Supports Markdown formatting. | Optional | String | Empty String | - |
| options | An array of checkboxes that the user can select. For syntax, see below. | Required | Array | - | - | | options | An array of checkboxes that the user can select. For syntax, see below. | Required | Array | - | - |
@ -273,9 +292,12 @@ Attributes:
For each value in the options array, you can set the following keys. For each value in the options array, you can set the following keys.
| Key | Description | Required | Type | Default | Options | | Key | Description | Required | Type | Default | Options |
|----------|------------------------------------------------------------------------------------------------------------------------------------------|----------|---------|---------|---------| |--------------|------------------------------------------------------------------------------------------------------------------------------------------|----------|--------------|---------|---------|
| label | The identifier for the option, which is displayed in the form. Markdown is supported for bold or italic text formatting, and hyperlinks. | Required | String | - | - | | label | The identifier for the option, which is displayed in the form. Markdown is supported for bold or italic text formatting, and hyperlinks. | Required | String | - | - |
| required | Prevents form submission until element is completed. | Optional | Boolean | false | - | | required | Prevents form submission until element is completed. | Optional | Boolean | false | - |
| visible | Whether a specific checkbox appears in the form only, in the created issue only, or both. Valid options are "form" and "content". | Optional | String array | false | - |
visible: Default is **[form, content]**
## Syntax for issue config ## Syntax for issue config
@ -292,14 +314,14 @@ contact_links:
### Possible Options ### Possible Options
| Key | Description | Type | Default | | Key | Description | Type | Default |
|----------------------|-------------------------------------------------------------------------------------------------------|--------------------|----------------| |----------------------|-------------------------------------------------------|--------------------|-------------|
| blank_issues_enabled | If set to false, the User is forced to use a Template | Boolean | true | | blank_issues_enabled | If set to false, the User is forced to use a Template | Boolean | true |
| contact_links | Custom Links to show in the Choose Box | Contact Link Array | Empty Array | | contact_links | Custom Links to show in the Choose Box | Contact Link Array | Empty Array |
### Contact Link ### Contact Link
| Key | Description | Type | Required | | Key | Description | Type | Required |
|----------------------|-------------------------------------------------------------------------------------------------------|---------|----------| |-------|----------------------------------|--------|----------|
| name | the name of your link | String | true | | name | the name of your link | String | true |
| url | The URL of your Link | String | true | | url | The URL of your Link | String | true |
| about | A short description of your Link | String | true | | about | A short description of your Link | String | true |

View file

@ -122,7 +122,13 @@ func validateRequired(field *api.IssueFormField, idx int) error {
// The label is not required for a markdown or checkboxes field // The label is not required for a markdown or checkboxes field
return nil return nil
} }
return validateBoolItem(newErrorPosition(idx, field.Type), field.Validations, "required") if err := validateBoolItem(newErrorPosition(idx, field.Type), field.Validations, "required"); err != nil {
return err
}
if required, _ := field.Validations["required"].(bool); required && !field.VisibleOnForm() {
return newErrorPosition(idx, field.Type).Errorf("can not require a hidden field")
}
return nil
} }
func validateID(field *api.IssueFormField, idx int, ids container.Set[string]) error { func validateID(field *api.IssueFormField, idx int, ids container.Set[string]) error {
@ -172,10 +178,38 @@ func validateOptions(field *api.IssueFormField, idx int) error {
return position.Errorf("'label' is required and should be a string") return position.Errorf("'label' is required and should be a string")
} }
if visibility, ok := opt["visible"]; ok {
visibilityList, ok := visibility.([]any)
if !ok {
return position.Errorf("'visible' should be list")
}
for _, visibleType := range visibilityList {
visibleType, ok := visibleType.(string)
if !ok || !(visibleType == "form" || visibleType == "content") {
return position.Errorf("'visible' list can only contain strings of 'form' and 'content'")
}
}
}
if required, ok := opt["required"]; ok { if required, ok := opt["required"]; ok {
if _, ok := required.(bool); !ok { if _, ok := required.(bool); !ok {
return position.Errorf("'required' should be a bool") return position.Errorf("'required' should be a bool")
} }
// validate if hidden field is required
if visibility, ok := opt["visible"]; ok {
visibilityList, _ := visibility.([]any)
isVisible := false
for _, v := range visibilityList {
if vv, _ := v.(string); vv == "form" {
isVisible = true
break
}
}
if !isVisible {
return position.Errorf("can not require a hidden checkbox")
}
}
} }
} }
} }
@ -238,7 +272,7 @@ func RenderToMarkdown(template *api.IssueTemplate, values url.Values) string {
IssueFormField: field, IssueFormField: field,
Values: values, Values: values,
} }
if f.ID == "" { if f.ID == "" || !f.VisibleInContent() {
continue continue
} }
f.WriteTo(builder) f.WriteTo(builder)
@ -253,11 +287,6 @@ type valuedField struct {
} }
func (f *valuedField) WriteTo(builder *strings.Builder) { func (f *valuedField) WriteTo(builder *strings.Builder) {
if f.Type == api.IssueFormFieldTypeMarkdown {
// markdown blocks do not appear in output
return
}
// write label // write label
if !f.HideLabel() { if !f.HideLabel() {
_, _ = fmt.Fprintf(builder, "### %s\n\n", f.Label()) _, _ = fmt.Fprintf(builder, "### %s\n\n", f.Label())
@ -269,6 +298,9 @@ func (f *valuedField) WriteTo(builder *strings.Builder) {
switch f.Type { switch f.Type {
case api.IssueFormFieldTypeCheckboxes: case api.IssueFormFieldTypeCheckboxes:
for _, option := range f.Options() { for _, option := range f.Options() {
if !option.VisibleInContent() {
continue
}
checked := " " checked := " "
if option.IsChecked() { if option.IsChecked() {
checked = "x" checked = "x"
@ -302,6 +334,10 @@ func (f *valuedField) WriteTo(builder *strings.Builder) {
} else { } else {
_, _ = fmt.Fprintf(builder, "%s\n", value) _, _ = fmt.Fprintf(builder, "%s\n", value)
} }
case api.IssueFormFieldTypeMarkdown:
if value, ok := f.Attributes["value"].(string); ok {
_, _ = fmt.Fprintf(builder, "%s\n", value)
}
} }
_, _ = fmt.Fprintln(builder) _, _ = fmt.Fprintln(builder)
} }
@ -314,6 +350,9 @@ func (f *valuedField) Label() string {
} }
func (f *valuedField) HideLabel() bool { func (f *valuedField) HideLabel() bool {
if f.Type == api.IssueFormFieldTypeMarkdown {
return true
}
if label, ok := f.Attributes["hide_label"].(bool); ok { if label, ok := f.Attributes["hide_label"].(bool); ok {
return label return label
} }
@ -385,6 +424,22 @@ func (o *valuedOption) IsChecked() bool {
return false return false
} }
func (o *valuedOption) VisibleInContent() bool {
if o.field.Type == api.IssueFormFieldTypeCheckboxes {
if vs, ok := o.data.(map[string]any); ok {
if vl, ok := vs["visible"].([]any); ok {
for _, v := range vl {
if vv, _ := v.(string); vv == "content" {
return true
}
}
return false
}
}
}
return true
}
var minQuotesRegex = regexp.MustCompilePOSIX("^`{3,}") var minQuotesRegex = regexp.MustCompilePOSIX("^`{3,}")
// minQuotes return 3 or more back-quotes. // minQuotes return 3 or more back-quotes.

View file

@ -10,6 +10,7 @@ import (
"code.gitea.io/gitea/modules/json" "code.gitea.io/gitea/modules/json"
api "code.gitea.io/gitea/modules/structs" api "code.gitea.io/gitea/modules/structs"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@ -318,6 +319,42 @@ body:
`, `,
wantErr: "body[0](checkboxes), option[0]: 'required' should be a bool", wantErr: "body[0](checkboxes), option[0]: 'required' should be a bool",
}, },
{
name: "field is required but hidden",
content: `
name: "test"
about: "this is about"
body:
- type: "input"
id: "1"
attributes:
label: "a"
validations:
required: true
visible: [content]
`,
wantErr: "body[0](input): can not require a hidden field",
},
{
name: "checkboxes is required but hidden",
content: `
name: "test"
about: "this is about"
body:
- type: checkboxes
id: "1"
attributes:
label: Label of checkboxes
description: Description of checkboxes
options:
- label: Option 1
required: false
- label: Required and hidden
required: true
visible: [content]
`,
wantErr: "body[0](checkboxes), option[1]: can not require a hidden checkbox",
},
{ {
name: "valid", name: "valid",
content: ` content: `
@ -374,8 +411,11 @@ body:
required: true required: true
- label: Option 2 of checkboxes - label: Option 2 of checkboxes
required: false required: false
- label: Option 3 of checkboxes - label: Hidden Option 3 of checkboxes
visible: [content]
- label: Required but not submitted
required: true required: true
visible: [form]
`, `,
want: &api.IssueTemplate{ want: &api.IssueTemplate{
Name: "Name", Name: "Name",
@ -390,6 +430,7 @@ body:
Attributes: map[string]any{ Attributes: map[string]any{
"value": "Value of the markdown", "value": "Value of the markdown",
}, },
Visible: []api.IssueFormFieldVisible{api.IssueFormFieldVisibleForm},
}, },
{ {
Type: "textarea", Type: "textarea",
@ -404,6 +445,7 @@ body:
Validations: map[string]any{ Validations: map[string]any{
"required": true, "required": true,
}, },
Visible: []api.IssueFormFieldVisible{api.IssueFormFieldVisibleForm, api.IssueFormFieldVisibleContent},
}, },
{ {
Type: "input", Type: "input",
@ -419,6 +461,7 @@ body:
"is_number": true, "is_number": true,
"regex": "[a-zA-Z0-9]+", "regex": "[a-zA-Z0-9]+",
}, },
Visible: []api.IssueFormFieldVisible{api.IssueFormFieldVisibleForm, api.IssueFormFieldVisibleContent},
}, },
{ {
Type: "dropdown", Type: "dropdown",
@ -436,6 +479,7 @@ body:
Validations: map[string]any{ Validations: map[string]any{
"required": true, "required": true,
}, },
Visible: []api.IssueFormFieldVisible{api.IssueFormFieldVisibleForm, api.IssueFormFieldVisibleContent},
}, },
{ {
Type: "checkboxes", Type: "checkboxes",
@ -446,9 +490,11 @@ body:
"options": []any{ "options": []any{
map[string]any{"label": "Option 1 of checkboxes", "required": true}, map[string]any{"label": "Option 1 of checkboxes", "required": true},
map[string]any{"label": "Option 2 of checkboxes", "required": false}, map[string]any{"label": "Option 2 of checkboxes", "required": false},
map[string]any{"label": "Option 3 of checkboxes", "required": true}, map[string]any{"label": "Hidden Option 3 of checkboxes", "visible": []string{"content"}},
map[string]any{"label": "Required but not submitted", "required": true, "visible": []string{"form"}},
}, },
}, },
Visible: []api.IssueFormFieldVisible{api.IssueFormFieldVisibleForm, api.IssueFormFieldVisibleContent},
}, },
}, },
FileName: "test.yaml", FileName: "test.yaml",
@ -467,7 +513,12 @@ body:
- type: markdown - type: markdown
id: id1 id: id1
attributes: attributes:
value: Value of the markdown value: Value of the markdown shown in form
- type: markdown
id: id2
attributes:
value: Value of the markdown shown in created issue
visible: [content]
`, `,
want: &api.IssueTemplate{ want: &api.IssueTemplate{
Name: "Name", Name: "Name",
@ -480,8 +531,17 @@ body:
Type: "markdown", Type: "markdown",
ID: "id1", ID: "id1",
Attributes: map[string]any{ Attributes: map[string]any{
"value": "Value of the markdown", "value": "Value of the markdown shown in form",
}, },
Visible: []api.IssueFormFieldVisible{api.IssueFormFieldVisibleForm},
},
{
Type: "markdown",
ID: "id2",
Attributes: map[string]any{
"value": "Value of the markdown shown in created issue",
},
Visible: []api.IssueFormFieldVisible{api.IssueFormFieldVisibleContent},
}, },
}, },
FileName: "test.yaml", FileName: "test.yaml",
@ -515,6 +575,7 @@ body:
Attributes: map[string]any{ Attributes: map[string]any{
"value": "Value of the markdown", "value": "Value of the markdown",
}, },
Visible: []api.IssueFormFieldVisible{api.IssueFormFieldVisibleForm},
}, },
}, },
FileName: "test.yaml", FileName: "test.yaml",
@ -548,6 +609,7 @@ body:
Attributes: map[string]any{ Attributes: map[string]any{
"value": "Value of the markdown", "value": "Value of the markdown",
}, },
Visible: []api.IssueFormFieldVisible{api.IssueFormFieldVisibleForm},
}, },
}, },
FileName: "test.yaml", FileName: "test.yaml",
@ -622,9 +684,14 @@ body:
- type: markdown - type: markdown
id: id1 id: id1
attributes: attributes:
value: Value of the markdown value: Value of the markdown shown in form
- type: textarea - type: markdown
id: id2 id: id2
attributes:
value: Value of the markdown shown in created issue
visible: [content]
- type: textarea
id: id3
attributes: attributes:
label: Label of textarea label: Label of textarea
description: Description of textarea description: Description of textarea
@ -634,7 +701,7 @@ body:
validations: validations:
required: true required: true
- type: input - type: input
id: id3 id: id4
attributes: attributes:
label: Label of input label: Label of input
description: Description of input description: Description of input
@ -646,7 +713,7 @@ body:
is_number: true is_number: true
regex: "[a-zA-Z0-9]+" regex: "[a-zA-Z0-9]+"
- type: dropdown - type: dropdown
id: id4 id: id5
attributes: attributes:
label: Label of dropdown label: Label of dropdown
description: Description of dropdown description: Description of dropdown
@ -658,7 +725,7 @@ body:
validations: validations:
required: true required: true
- type: checkboxes - type: checkboxes
id: id5 id: id6
attributes: attributes:
label: Label of checkboxes label: Label of checkboxes
description: Description of checkboxes description: Description of checkboxes
@ -669,20 +736,26 @@ body:
required: false required: false
- label: Option 3 of checkboxes - label: Option 3 of checkboxes
required: true required: true
visible: [form]
- label: Hidden Option of checkboxes
visible: [content]
`, `,
values: map[string][]string{ values: map[string][]string{
"form-field-id2": {"Value of id2"},
"form-field-id3": {"Value of id3"}, "form-field-id3": {"Value of id3"},
"form-field-id4": {"0,1"}, "form-field-id4": {"Value of id4"},
"form-field-id5-0": {"on"}, "form-field-id5": {"0,1"},
"form-field-id5-2": {"on"}, "form-field-id6-0": {"on"},
"form-field-id6-2": {"on"},
}, },
}, },
want: `### Label of textarea
` + "```bash\nValue of id2\n```" + ` want: `Value of the markdown shown in created issue
Value of id3 ### Label of textarea
` + "```bash\nValue of id3\n```" + `
Value of id4
### Label of dropdown ### Label of dropdown
@ -692,7 +765,7 @@ Option 1 of dropdown, Option 2 of dropdown
- [x] Option 1 of checkboxes - [x] Option 1 of checkboxes
- [ ] Option 2 of checkboxes - [ ] Option 2 of checkboxes
- [x] Option 3 of checkboxes - [ ] Hidden Option of checkboxes
`, `,
}, },
@ -704,7 +777,7 @@ Option 1 of dropdown, Option 2 of dropdown
t.Fatal(err) t.Fatal(err)
} }
if got := RenderToMarkdown(template, tt.args.values); got != tt.want { if got := RenderToMarkdown(template, tt.args.values); got != tt.want {
t.Errorf("RenderToMarkdown() = %v, want %v", got, tt.want) assert.EqualValues(t, tt.want, got)
} }
}) })
} }

View file

@ -128,9 +128,18 @@ func unmarshal(filename string, content []byte) (*api.IssueTemplate, error) {
} }
} }
for i, v := range it.Fields { for i, v := range it.Fields {
// set default id value
if v.ID == "" { if v.ID == "" {
v.ID = strconv.Itoa(i) v.ID = strconv.Itoa(i)
} }
// set default visibility
if v.Visible == nil {
v.Visible = []api.IssueFormFieldVisible{api.IssueFormFieldVisibleForm}
// markdown is not submitted by default
if v.Type != api.IssueFormFieldTypeMarkdown {
v.Visible = append(v.Visible, api.IssueFormFieldVisibleContent)
}
}
} }
} }

View file

@ -6,6 +6,7 @@ package structs
import ( import (
"fmt" "fmt"
"path" "path"
"slices"
"strings" "strings"
"time" "time"
@ -147,8 +148,33 @@ type IssueFormField struct {
ID string `json:"id" yaml:"id"` ID string `json:"id" yaml:"id"`
Attributes map[string]any `json:"attributes" yaml:"attributes"` Attributes map[string]any `json:"attributes" yaml:"attributes"`
Validations map[string]any `json:"validations" yaml:"validations"` Validations map[string]any `json:"validations" yaml:"validations"`
Visible []IssueFormFieldVisible `json:"visible,omitempty"`
} }
func (iff IssueFormField) VisibleOnForm() bool {
if len(iff.Visible) == 0 {
return true
}
return slices.Contains(iff.Visible, IssueFormFieldVisibleForm)
}
func (iff IssueFormField) VisibleInContent() bool {
if len(iff.Visible) == 0 {
// we have our markdown exception
return iff.Type != IssueFormFieldTypeMarkdown
}
return slices.Contains(iff.Visible, IssueFormFieldVisibleContent)
}
// IssueFormFieldVisible defines issue form field visible
// swagger:model
type IssueFormFieldVisible string
const (
IssueFormFieldVisibleForm IssueFormFieldVisible = "form"
IssueFormFieldVisibleContent IssueFormFieldVisible = "content"
)
// IssueTemplate represents an issue template for a repository // IssueTemplate represents an issue template for a repository
// swagger:model // swagger:model
type IssueTemplate struct { type IssueTemplate struct {

View file

@ -1,8 +1,8 @@
<div class="field"> <div class="field {{if not .item.VisibleOnForm}}gt-hidden{{end}}">
{{template "repo/issue/fields/header" .}} {{template "repo/issue/fields/header" .}}
{{range $i, $opt := .item.Attributes.options}} {{range $i, $opt := .item.Attributes.options}}
<div class="field inline"> <div class="field inline">
<div class="ui checkbox gt-mr-0"> <div class="ui checkbox gt-mr-0 {{if and ($opt.visible) (not (SliceUtils.Contains $opt.visible "form"))}}gt-hidden{{end}}">
<input type="checkbox" name="form-field-{{$.item.ID}}-{{$i}}" {{if $opt.required}}required{{end}}> <input type="checkbox" name="form-field-{{$.item.ID}}-{{$i}}" {{if $opt.required}}required{{end}}>
<label>{{RenderMarkdownToHtml $.context $opt.label}}</label> <label>{{RenderMarkdownToHtml $.context $opt.label}}</label>
</div> </div>

View file

@ -1,4 +1,4 @@
<div class="field"> <div class="field {{if not .item.VisibleOnForm}}gt-hidden{{end}}">
{{template "repo/issue/fields/header" .}} {{template "repo/issue/fields/header" .}}
{{/* FIXME: required validation */}} {{/* FIXME: required validation */}}
<div class="ui fluid selection dropdown {{if .item.Attributes.multiple}}multiple clearable{{end}}"> <div class="ui fluid selection dropdown {{if .item.Attributes.multiple}}multiple clearable{{end}}">

View file

@ -1,4 +1,4 @@
<div class="field"> <div class="field {{if not .item.VisibleOnForm}}gt-hidden{{end}}">
{{template "repo/issue/fields/header" .}} {{template "repo/issue/fields/header" .}}
<input type="{{if .item.Validations.is_number}}number{{else}}text{{end}}" name="form-field-{{.item.ID}}" placeholder="{{.item.Attributes.placeholder}}" value="{{.item.Attributes.value}}" {{if .item.Validations.required}}required{{end}} {{if .item.Validations.regex}}pattern="{{.item.Validations.regex}}" title="{{.item.Validations.regex}}"{{end}}> <input type="{{if .item.Validations.is_number}}number{{else}}text{{end}}" name="form-field-{{.item.ID}}" placeholder="{{.item.Attributes.placeholder}}" value="{{.item.Attributes.value}}" {{if .item.Validations.required}}required{{end}} {{if .item.Validations.regex}}pattern="{{.item.Validations.regex}}" title="{{.item.Validations.regex}}"{{end}}>
</div> </div>

View file

@ -1,3 +1,3 @@
<div class="field"> <div class="field {{if not .item.VisibleOnForm}}gt-hidden{{end}}">
<div>{{RenderMarkdownToHtml .Context .item.Attributes.value}}</div> <div>{{RenderMarkdownToHtml .Context .item.Attributes.value}}</div>
</div> </div>

View file

@ -1,5 +1,5 @@
{{$useMarkdownEditor := not .item.Attributes.render}} {{$useMarkdownEditor := not .item.Attributes.render}}
<div class="field {{if $useMarkdownEditor}}combo-editor-dropzone{{end}}"> <div class="field {{if not .item.VisibleOnForm}}gt-hidden{{end}} {{if $useMarkdownEditor}}combo-editor-dropzone{{end}}">
{{template "repo/issue/fields/header" .}} {{template "repo/issue/fields/header" .}}
{{/* the real form element to provide the value */}} {{/* the real form element to provide the value */}}

View file

@ -21225,6 +21225,13 @@
"type": "object", "type": "object",
"additionalProperties": {}, "additionalProperties": {},
"x-go-name": "Validations" "x-go-name": "Validations"
},
"visible": {
"type": "array",
"items": {
"$ref": "#/definitions/IssueFormFieldVisible"
},
"x-go-name": "Visible"
} }
}, },
"x-go-package": "code.gitea.io/gitea/modules/structs" "x-go-package": "code.gitea.io/gitea/modules/structs"
@ -21234,6 +21241,11 @@
"title": "IssueFormFieldType defines issue form field type, can be \"markdown\", \"textarea\", \"input\", \"dropdown\" or \"checkboxes\"", "title": "IssueFormFieldType defines issue form field type, can be \"markdown\", \"textarea\", \"input\", \"dropdown\" or \"checkboxes\"",
"x-go-package": "code.gitea.io/gitea/modules/structs" "x-go-package": "code.gitea.io/gitea/modules/structs"
}, },
"IssueFormFieldVisible": {
"description": "IssueFormFieldVisible defines issue form field visible",
"type": "string",
"x-go-package": "code.gitea.io/gitea/modules/structs"
},
"IssueLabelsOption": { "IssueLabelsOption": {
"description": "IssueLabelsOption a collection of labels", "description": "IssueLabelsOption a collection of labels",
"type": "object", "type": "object",