mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-24 09:27:17 +00:00
Don't warn users about *every* dirty form (#3707)
The choice regarding which forms should or should not trigger a warning is subjective. I tried to be consistent and not warn about forms that: - run an action, rather than edit data: search, send an email. - delete data: a warning about losing data would be confusing Note that forms on sign-in pages were already ignored (using a selector, rather than an explicit class on the form element). Fixes #3698.
This commit is contained in:
parent
e64aa18dc9
commit
2dc6f15eca
|
@ -1663,8 +1663,11 @@ function selectRange($list, $select, $from) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
if ($('.user.signin').length > 0) return;
|
// Warn users that try to leave a page after entering data into a form.
|
||||||
$('form').areYouSure();
|
// Except on sign-in pages, and for forms marked as 'ignore-dirty'.
|
||||||
|
if ($('.user.signin').length === 0) {
|
||||||
|
$('form:not(.ignore-dirty)').areYouSure();
|
||||||
|
}
|
||||||
|
|
||||||
// Parse SSH Key
|
// Parse SSH Key
|
||||||
$("#ssh-key-content").on('change paste keyup',function(){
|
$("#ssh-key-content").on('change paste keyup',function(){
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<form class="ui form" style="max-width: 90%">
|
<form class="ui form ignore-dirty" style="max-width: 90%">
|
||||||
<div class="ui fluid action input">
|
<div class="ui fluid action input">
|
||||||
<input name="q" value="{{.Keyword}}" placeholder="{{.i18n.Tr "explore.search"}}..." autofocus>
|
<input name="q" value="{{.Keyword}}" placeholder="{{.i18n.Tr "explore.search"}}..." autofocus>
|
||||||
<button class="ui blue button">{{.i18n.Tr "explore.search"}}</button>
|
<button class="ui blue button">{{.i18n.Tr "explore.search"}}</button>
|
||||||
|
|
|
@ -185,7 +185,7 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
<dt>{{.i18n.Tr "admin.config.mailer_user"}}</dt>
|
<dt>{{.i18n.Tr "admin.config.mailer_user"}}</dt>
|
||||||
<dd>{{if .Mailer.User}}{{.Mailer.User}}{{else}}(empty){{end}}</dd><br>
|
<dd>{{if .Mailer.User}}{{.Mailer.User}}{{else}}(empty){{end}}</dd><br>
|
||||||
<form class="ui form" action="{{AppSubUrl}}/admin/config/test_mail" method="post">
|
<form class="ui form ignore-dirty" action="{{AppSubUrl}}/admin/config/test_mail" method="post">
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<div class="inline field ui left">
|
<div class="inline field ui left">
|
||||||
<div class="ui input">
|
<div class="ui input">
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div class="explore users">
|
<div class="explore users">
|
||||||
{{template "explore/navbar" .}}
|
{{template "explore/navbar" .}}
|
||||||
<div class="ui container">
|
<div class="ui container">
|
||||||
<form class="ui form" style="max-width: 100%">
|
<form class="ui form ignore-dirty" style="max-width: 100%">
|
||||||
<div class="ui fluid action input">
|
<div class="ui fluid action input">
|
||||||
<input name="q" value="{{.Keyword}}" placeholder="{{.i18n.Tr "explore.search"}}..." autofocus>
|
<input name="q" value="{{.Keyword}}" placeholder="{{.i18n.Tr "explore.search"}}..." autofocus>
|
||||||
<input type="hidden" name="tab" value="{{$.TabName}}">
|
<input type="hidden" name="tab" value="{{$.TabName}}">
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<form class="ui form" style="max-width: 90%">
|
<form class="ui form ignore-dirty" style="max-width: 90%">
|
||||||
<div class="ui fluid action input">
|
<div class="ui fluid action input">
|
||||||
<input name="q" value="{{.Keyword}}" placeholder="{{.i18n.Tr "explore.search"}}..." autofocus>
|
<input name="q" value="{{.Keyword}}" placeholder="{{.i18n.Tr "explore.search"}}..." autofocus>
|
||||||
<input type="hidden" name="tab" value="{{$.TabName}}">
|
<input type="hidden" name="tab" value="{{$.TabName}}">
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
<div class="ui red message">
|
<div class="ui red message">
|
||||||
<p class="text left"><i class="octicon octicon-alert"></i> {{.i18n.Tr "org.settings.delete_prompt" | Str2html}}</p>
|
<p class="text left"><i class="octicon octicon-alert"></i> {{.i18n.Tr "org.settings.delete_prompt" | Str2html}}</p>
|
||||||
</div>
|
</div>
|
||||||
<form class="ui form" id="delete-form" action="{{.Link}}" method="post">
|
<form class="ui form ignore-dirty" id="delete-form" action="{{.Link}}" method="post">
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<input class="fake" type="password">
|
<input class="fake" type="password">
|
||||||
<div class="inline required field {{if .Err_Password}}error{{end}}">
|
<div class="inline required field {{if .Err_Password}}error{{end}}">
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="ten wide right aligned column">
|
<div class="ten wide right aligned column">
|
||||||
{{if .PageIsCommits}}
|
{{if .PageIsCommits}}
|
||||||
<form action="{{.RepoLink}}/commits/{{.BranchNameSubURL}}/search">
|
<form class="ignore-dirty" action="{{.RepoLink}}/commits/{{.BranchNameSubURL}}/search">
|
||||||
<div class="ui tiny search input">
|
<div class="ui tiny search input">
|
||||||
<input name="q" placeholder="{{.i18n.Tr "repo.commits.search"}}" value="{{.Keyword}}" autofocus>
|
<input name="q" placeholder="{{.i18n.Tr "repo.commits.search"}}" value="{{.Keyword}}" autofocus>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{if .RepoSearchEnabled}}
|
{{if .RepoSearchEnabled}}
|
||||||
<div class="ui repo-search">
|
<div class="ui repo-search">
|
||||||
<form class="ui form" action="{{.RepoLink}}/search" method="get">
|
<form class="ui form ignore-dirty" action="{{.RepoLink}}/search" method="get">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="ui action input">
|
<div class="ui action input">
|
||||||
<input name="q" value="{{.Keyword}}" placeholder="{{.i18n.Tr "repo.search.search_repo"}}">
|
<input name="q" value="{{.Keyword}}" placeholder="{{.i18n.Tr "repo.search.search_repo"}}">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<form class="ui form">
|
<form class="ui form ignore-dirty">
|
||||||
<div class="ui fluid action input">
|
<div class="ui fluid action input">
|
||||||
<input type="hidden" name="type" value="{{$.ViewType}}"/>
|
<input type="hidden" name="type" value="{{$.ViewType}}"/>
|
||||||
<input type="hidden" name="state" value="{{$.State}}"/>
|
<input type="hidden" name="state" value="{{$.State}}"/>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
{{template "repo/header" .}}
|
{{template "repo/header" .}}
|
||||||
<div class="ui container">
|
<div class="ui container">
|
||||||
<div class="ui repo-search">
|
<div class="ui repo-search">
|
||||||
<form class="ui form" method="get">
|
<form class="ui form ignore-dirty" method="get">
|
||||||
<div class="ui fluid action input">
|
<div class="ui fluid action input">
|
||||||
<input name="q" value="{{.Keyword}}" placeholder="{{.i18n.Tr "repo.search.search_repo"}}">
|
<input name="q" value="{{.Keyword}}" placeholder="{{.i18n.Tr "repo.search.search_repo"}}">
|
||||||
<button class="ui button" type="submit">
|
<button class="ui button" type="submit">
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div class="user activate">
|
<div class="user activate">
|
||||||
<div class="ui middle very relaxed page grid">
|
<div class="ui middle very relaxed page grid">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<form class="ui form" action="{{AppSubUrl}}/user/activate" method="post">
|
<form class="ui form ignore-dirty" action="{{AppSubUrl}}/user/activate" method="post">
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<h2 class="ui top attached header">
|
<h2 class="ui top attached header">
|
||||||
{{.i18n.Tr "auth.active_your_account"}}
|
{{.i18n.Tr "auth.active_your_account"}}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div class="user forgot password">
|
<div class="user forgot password">
|
||||||
<div class="ui middle very relaxed page grid">
|
<div class="ui middle very relaxed page grid">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<form class="ui form" action="{{.Link}}" method="post">
|
<form class="ui form ignore-dirty" action="{{.Link}}" method="post">
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<h2 class="ui top attached header">
|
<h2 class="ui top attached header">
|
||||||
{{.i18n.Tr "auth.forgot_password_title"}}
|
{{.i18n.Tr "auth.forgot_password_title"}}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div class="user reset password">
|
<div class="user reset password">
|
||||||
<div class="ui middle very relaxed page grid">
|
<div class="ui middle very relaxed page grid">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<form class="ui form" action="{{.Link}}" method="post">
|
<form class="ui form ignore-dirty" action="{{.Link}}" method="post">
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<input name="code" type="hidden" value="{{.Code}}">
|
<input name="code" type="hidden" value="{{.Code}}">
|
||||||
<h2 class="ui top attached header">
|
<h2 class="ui top attached header">
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
{{.i18n.Tr "settings.generate_new_token"}}
|
{{.i18n.Tr "settings.generate_new_token"}}
|
||||||
</h4>
|
</h4>
|
||||||
<div class="ui attached segment">
|
<div class="ui attached segment">
|
||||||
<form class="ui form" action="{{.Link}}" method="post">
|
<form class="ui form ignore-dirty" action="{{.Link}}" method="post">
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<p>{{.i18n.Tr "settings.new_token_desc"}}</p>
|
<p>{{.i18n.Tr "settings.new_token_desc"}}</p>
|
||||||
<div class="field {{if .Err_Name}}error{{end}}">
|
<div class="field {{if .Err_Name}}error{{end}}">
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<div class="ui red message">
|
<div class="ui red message">
|
||||||
<p class="text left"><i class="octicon octicon-alert"></i> {{.i18n.Tr "settings.delete_prompt" | Str2html}}</p>
|
<p class="text left"><i class="octicon octicon-alert"></i> {{.i18n.Tr "settings.delete_prompt" | Str2html}}</p>
|
||||||
</div>
|
</div>
|
||||||
<form class="ui form" id="delete-form" action="{{.Link}}" method="post">
|
<form class="ui form ignore-dirty" id="delete-form" action="{{.Link}}" method="post">
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<input class="fake" type="password">
|
<input class="fake" type="password">
|
||||||
<div class="required field {{if .Err_Password}}error{{end}}">
|
<div class="required field {{if .Err_Password}}error{{end}}">
|
||||||
|
|
Loading…
Reference in a new issue