-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Change form actions to fetch for submit review box #25219
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
Merged
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
f774943
save
HesterG 3c56833
change to fetch
HesterG 984a30b
update
HesterG 2b71734
change to post
HesterG 7d3683b
Merge branch 'go-gitea:main' into change-actions-fetch
HesterG 2318bb3
change redirect
HesterG 183dc8e
update
HesterG ed54590
add loading
HesterG 8f57fc1
add comments
HesterG 0dc11e1
update js
HesterG 4602642
update
HesterG 7fa9e1e
Merge branch 'go-gitea:main' into change-actions-fetch
HesterG 9db8855
comment
HesterG acdd3cd
comment
HesterG f029cfb
change to resirect
HesterG 8f382f2
Merge branch 'main' into change-actions-fetch
HesterG cf540cd
Merge branch 'main' into change-actions-fetch
HesterG bfe1c6b
update to dataform
HesterG 1a8472f
add method
HesterG c3d5bfb
Merge branch 'main' into change-actions-fetch
HesterG 2d7d5d0
rename and append submitter value
HesterG f4da606
comment
HesterG b37a7db
comment
HesterG 74e330d
fix lint
HesterG a5c5145
Merge branch 'main' into change-actions-fetch
HesterG c45a1e1
fine tune (wip)
wxiaoguang 3b271d7
quick fix for submitterName and value
HesterG 6023a45
Merge branch 'main' into change-actions-fetch
wxiaoguang b8f64ca
improve
wxiaoguang 722d0ed
improve
wxiaoguang 9f428a3
improve
wxiaoguang f43cdc6
Merge branch 'main' into change-actions-fetch
HesterG 713feda
Merge branch 'main' into change-actions-fetch
GiteaBot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{{template "base/head" .}} | ||
<div class="page-content devtest ui container"> | ||
{{template "base/alert" .}} | ||
<div> | ||
<h1>link-action</h1> | ||
<div> | ||
Use "window.fetch" to send a request to backend, the request is defined in an "A" or "BUTTON" element. | ||
It might be renamed to "link-fetch-action" to match the "form-fetch-action". | ||
</div> | ||
<div> | ||
<button class="link-action" data-url="fetch-action-test?k=1">test</button> | ||
</div> | ||
</div> | ||
<div> | ||
<h1>form-fetch-action</h1> | ||
<div>Use "window.fetch" to send a form request to backend</div> | ||
<div> | ||
<form method="get" action="fetch-action-test?k=1" class="form-fetch-action"> | ||
<button name="btn">submit get</button> | ||
</form> | ||
<form method="post" action="fetch-action-test?k=1" class="form-fetch-action"> | ||
<div><textarea name="text" rows="3" class="js-quick-submit"></textarea></div> | ||
<div><label><input name="check" type="checkbox"> check</label></div> | ||
<div><button name="btn">submit post</button></div> | ||
</form> | ||
<form method="post" action="/no-such-uri" class="form-fetch-action"> | ||
<div class="gt-py-5">bad action url</div> | ||
<div><button name="btn">submit test</button></div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
<style> | ||
.ui.message.flash-message { | ||
text-align: left; | ||
} | ||
.form-fetch-action { | ||
margin-bottom: 1em; | ||
border: 1px red dashed; /* show the border for demo purpose */ | ||
} | ||
</style> | ||
{{template "base/footer" .}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
<style> | ||
@media (prefers-color-scheme: dark) { | ||
:root { | ||
color-scheme: dark; | ||
} | ||
} | ||
</style> | ||
{{template "base/head" .}} | ||
|
||
<ul> | ||
{{range .SubNames}} | ||
<li><a href="{{AppSubUrl}}/devtest/{{.}}">{{.}}</a></li> | ||
{{end}} | ||
</ul> | ||
|
||
<style> | ||
ul { | ||
line-height: 2em; | ||
} | ||
</style> | ||
|
||
{{template "base/footer" .}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
import $ from 'jquery'; | ||
|
||
export function handleGlobalEnterQuickSubmit(target) { | ||
const $target = $(target); | ||
const $form = $(target).closest('form'); | ||
if ($form.length) { | ||
const form = target.closest('form'); | ||
if (form) { | ||
if (!form.checkValidity()) { | ||
form.reportValidity(); | ||
return; | ||
} | ||
|
||
if (form.classList.contains('form-fetch-action')) { | ||
form.dispatchEvent(new SubmitEvent('submit', {bubbles: true, cancelable: true})); | ||
return; | ||
} | ||
|
||
// here use the event to trigger the submit event (instead of calling `submit()` method directly) | ||
// otherwise the `areYouSure` handler won't be executed, then there will be an annoying "confirm to leave" dialog | ||
if ($form[0].checkValidity()) { | ||
$form.trigger('submit'); | ||
} | ||
$(form).trigger('submit'); | ||
} else { | ||
// if no form, then the editor is for an AJAX request, dispatch an event to the target, let the target's event handler to do the AJAX request. | ||
// the 'ce-' prefix means this is a CustomEvent | ||
$target.trigger('ce-quick-submit'); | ||
target.dispatchEvent(new CustomEvent('ce-quick-submit', {bubbles: true})); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.