Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple the issue-template code from comment_tab.tmpl #23556

Merged
merged 3 commits into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions templates/repo/issue/comment_tab.tmpl
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
{{if .Fields}}
<input type="hidden" name="template-file" value="{{.TemplateFile}}">
{{range .Fields}}
{{if eq .Type "input"}}
{{template "repo/issue/fields/input" Dict "Context" $.Context "item" .}}
{{else if eq .Type "markdown"}}
{{template "repo/issue/fields/markdown" Dict "Context" $.Context "item" .}}
{{else if eq .Type "textarea"}}
{{template "repo/issue/fields/textarea" Dict "Context" $.Context "item" .}}
{{else if eq .Type "dropdown"}}
{{template "repo/issue/fields/dropdown" Dict "Context" $.Context "item" .}}
{{else if eq .Type "checkboxes"}}
{{template "repo/issue/fields/checkboxes" Dict "Context" $.Context "item" .}}
{{end}}
{{end}}
{{else}}
<div class="ui top tabular menu" data-write="write" data-preview="preview">
<a class="active item" data-tab="write">{{.locale.Tr "write"}}</a>
<a class="item" data-tab="preview" data-url="{{.Repository.Link}}/markdown" data-context="{{.RepoLink}}">{{.locale.Tr "preview"}}</a>
Expand All @@ -28,7 +12,6 @@
{{.locale.Tr "loading"}}
</div>
</div>
{{end}}
{{if .IsAttachmentEnabled}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, we could also extract the lines below into its own subtemplate, so that we don't need to declare them twice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My plan is introducing a "ComboEditor" for Gitea in the future, a ComboEditor could have: markdown toolbar, preview, textarea, dropzone(uploader).

So leave it to future.

<div class="field">
{{template "repo/upload" .}}
Expand Down
24 changes: 23 additions & 1 deletion templates/repo/issue/new_form.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,29 @@
<div class="title_wip_desc" data-wip-prefixes="{{Json .PullRequestWorkInProgressPrefixes}}">{{.locale.Tr "repo.pulls.title_wip_desc" (index .PullRequestWorkInProgressPrefixes 0| Escape) | Safe}}</div>
{{end}}
</div>
{{template "repo/issue/comment_tab" .}}
{{if .Fields}}
<input type="hidden" name="template-file" value="{{.TemplateFile}}">
{{range .Fields}}
{{if eq .Type "input"}}
{{template "repo/issue/fields/input" Dict "Context" $.Context "item" .}}
{{else if eq .Type "markdown"}}
{{template "repo/issue/fields/markdown" Dict "Context" $.Context "item" .}}
{{else if eq .Type "textarea"}}
{{template "repo/issue/fields/textarea" Dict "Context" $.Context "item" .}}
{{else if eq .Type "dropdown"}}
{{template "repo/issue/fields/dropdown" Dict "Context" $.Context "item" .}}
{{else if eq .Type "checkboxes"}}
{{template "repo/issue/fields/checkboxes" Dict "Context" $.Context "item" .}}
{{end}}
{{end}}
{{if .IsAttachmentEnabled}}
<div class="field">
{{template "repo/upload" .}}
</div>
{{end}}
{{else}}
{{template "repo/issue/comment_tab" .}}
{{end}}
<div class="text right">
<button class="ui green button loading-button" tabindex="6">
{{if .PageIsComparePull}}
Expand Down