mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-28 09:21:13 -05:00
1e54e211ca
Avoids the use of HTMX on milestone assignment within a New Issue form. The New Issue form doesn't have an issue ID to send to a milestone change URL, which the backend expects in order to construct a proper reply. The frontend template was also not built to use the new HTMX response. This resulted in a backend error and a large warning whenever anyone tried to set a milestone from within the New Issue form (new pull requests were also affected), rather than from a View Issue page. This introduces a new parameter into the `issue/milestone/select_menu` template, "NewIssuePage". When unset, the template produces the same results as before. Selection uses `hx-post` to notify the server immediately, using the updated htmx fragment from the reply. When set to a truthy value, the old style of form is used. Selection uses `data-id` and `data-href` to update the selected milestone locally, via `selectItem` in `repo-legacy.js`, recreating the selected element and updating the hidden form value. Fixes #5176.
39 lines
1.5 KiB
Go HTML Template
39 lines
1.5 KiB
Go HTML Template
{{$useHTMX := not .NewIssuePage}}
|
|
{{if or .OpenMilestones .ClosedMilestones}}
|
|
<div class="ui icon search input">
|
|
<i class="icon">{{svg "octicon-search" 16}}</i>
|
|
<input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_milestones"}}">
|
|
</div>
|
|
<div class="divider"></div>
|
|
{{end}}
|
|
<div class="no-select item"{{if $useHTMX}} hx-post="{{$.RepoLink}}/issues/milestone?issue_ids={{$.Issue.ID}}&htmx=true"{{end}}>{{ctx.Locale.Tr "repo.issues.new.clear_milestone"}}</div>
|
|
{{if and (not .OpenMilestones) (not .ClosedMilestones)}}
|
|
<div class="disabled item">
|
|
{{ctx.Locale.Tr "repo.issues.new.no_items"}}
|
|
</div>
|
|
{{else}}
|
|
{{if .OpenMilestones}}
|
|
<div class="divider"></div>
|
|
<div class="header">
|
|
{{ctx.Locale.Tr "repo.issues.new.open_milestone"}}
|
|
</div>
|
|
{{range .OpenMilestones}}
|
|
<a class="item"{{if $useHTMX}} hx-post="{{$.RepoLink}}/issues/milestone?id={{.ID}}&issue_ids={{$.Issue.ID}}&htmx=true"{{else}} data-id="{{.ID}}" data-href="{{$.RepoLink}}/issues?milestone={{.ID}}"{{end}}>
|
|
{{svg "octicon-milestone" 16 "tw-mr-1"}}
|
|
{{.Name}}
|
|
</a>
|
|
{{end}}
|
|
{{end}}
|
|
{{if .ClosedMilestones}}
|
|
<div class="divider"></div>
|
|
<div class="header">
|
|
{{ctx.Locale.Tr "repo.issues.new.closed_milestone"}}
|
|
</div>
|
|
{{range .ClosedMilestones}}
|
|
<a class="item"{{if $useHTMX}} hx-post="{{$.RepoLink}}/issues/milestone?id={{.ID}}&issue_ids={{$.Issue.ID}}&htmx=true"{{else}} data-id="{{.ID}}" data-href="{{$.RepoLink}}/issues?milestone={{.ID}}"{{end}}>
|
|
{{svg "octicon-milestone" 16 "tw-mr-1"}}
|
|
{{.Name}}
|
|
</a>
|
|
{{end}}
|
|
{{end}}
|
|
{{end}}
|