mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-22 05:36:16 +00:00
Fix milestone assignment in New Issue
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.
This commit is contained in:
parent
b42ca2ed0c
commit
1e54e211ca
|
@ -1,3 +1,4 @@
|
||||||
|
{{$useHTMX := not .NewIssuePage}}
|
||||||
{{if or .OpenMilestones .ClosedMilestones}}
|
{{if or .OpenMilestones .ClosedMilestones}}
|
||||||
<div class="ui icon search input">
|
<div class="ui icon search input">
|
||||||
<i class="icon">{{svg "octicon-search" 16}}</i>
|
<i class="icon">{{svg "octicon-search" 16}}</i>
|
||||||
|
@ -5,7 +6,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
{{end}}
|
{{end}}
|
||||||
<div class="no-select item" hx-post="{{$.RepoLink}}/issues/milestone?issue_ids={{$.Issue.ID}}&htmx=true">{{ctx.Locale.Tr "repo.issues.new.clear_milestone"}}</div>
|
<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)}}
|
{{if and (not .OpenMilestones) (not .ClosedMilestones)}}
|
||||||
<div class="disabled item">
|
<div class="disabled item">
|
||||||
{{ctx.Locale.Tr "repo.issues.new.no_items"}}
|
{{ctx.Locale.Tr "repo.issues.new.no_items"}}
|
||||||
|
@ -17,7 +18,7 @@
|
||||||
{{ctx.Locale.Tr "repo.issues.new.open_milestone"}}
|
{{ctx.Locale.Tr "repo.issues.new.open_milestone"}}
|
||||||
</div>
|
</div>
|
||||||
{{range .OpenMilestones}}
|
{{range .OpenMilestones}}
|
||||||
<a class="item" hx-post="{{$.RepoLink}}/issues/milestone?id={{.ID}}&issue_ids={{$.Issue.ID}}&htmx=true">
|
<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"}}
|
{{svg "octicon-milestone" 16 "tw-mr-1"}}
|
||||||
{{.Name}}
|
{{.Name}}
|
||||||
</a>
|
</a>
|
||||||
|
@ -29,7 +30,7 @@
|
||||||
{{ctx.Locale.Tr "repo.issues.new.closed_milestone"}}
|
{{ctx.Locale.Tr "repo.issues.new.closed_milestone"}}
|
||||||
</div>
|
</div>
|
||||||
{{range .ClosedMilestones}}
|
{{range .ClosedMilestones}}
|
||||||
<a class="item" hx-post="{{$.RepoLink}}/issues/milestone?id={{.ID}}&issue_ids={{$.Issue.ID}}&htmx=true">
|
<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"}}
|
{{svg "octicon-milestone" 16 "tw-mr-1"}}
|
||||||
{{.Name}}
|
{{.Name}}
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -64,7 +64,7 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
</span>
|
</span>
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
{{template "repo/issue/milestone/select_menu" .}}
|
{{template "repo/issue/milestone/select_menu" dict "." . "NewIssuePage" 1}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui select-milestone list">
|
<div class="ui select-milestone list">
|
||||||
|
|
Loading…
Reference in a new issue