mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-11-04 08:21:11 +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
					
				
			
		
					 2 changed files with 5 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,4 @@
 | 
			
		|||
{{$useHTMX := not .NewIssuePage}}
 | 
			
		||||
{{if or .OpenMilestones .ClosedMilestones}}
 | 
			
		||||
	<div class="ui icon search input">
 | 
			
		||||
		<i class="icon">{{svg "octicon-search" 16}}</i>
 | 
			
		||||
| 
						 | 
				
			
			@ -5,7 +6,7 @@
 | 
			
		|||
	</div>
 | 
			
		||||
	<div class="divider"></div>
 | 
			
		||||
{{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)}}
 | 
			
		||||
	<div class="disabled item">
 | 
			
		||||
		{{ctx.Locale.Tr "repo.issues.new.no_items"}}
 | 
			
		||||
| 
						 | 
				
			
			@ -17,7 +18,7 @@
 | 
			
		|||
			{{ctx.Locale.Tr "repo.issues.new.open_milestone"}}
 | 
			
		||||
		</div>
 | 
			
		||||
		{{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"}}
 | 
			
		||||
				{{.Name}}
 | 
			
		||||
			</a>
 | 
			
		||||
| 
						 | 
				
			
			@ -29,7 +30,7 @@
 | 
			
		|||
			{{ctx.Locale.Tr "repo.issues.new.closed_milestone"}}
 | 
			
		||||
		</div>
 | 
			
		||||
		{{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"}}
 | 
			
		||||
				{{.Name}}
 | 
			
		||||
			</a>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -64,7 +64,7 @@
 | 
			
		|||
				{{end}}
 | 
			
		||||
			</span>
 | 
			
		||||
			<div class="menu">
 | 
			
		||||
				{{template "repo/issue/milestone/select_menu" .}}
 | 
			
		||||
				{{template "repo/issue/milestone/select_menu" dict "." . "NewIssuePage" 1}}
 | 
			
		||||
			</div>
 | 
			
		||||
		</div>
 | 
			
		||||
		<div class="ui select-milestone list">
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue