gitea源码

fetch-action.tmpl 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. {{template "devtest/devtest-header"}}
  2. <div class="page-content devtest ui container">
  3. {{template "base/alert" .}}
  4. <div>
  5. <h1>link-action</h1>
  6. <div>
  7. Use "window.fetch" to send a request to backend, the request is defined in an "A" or "BUTTON" element.
  8. It might be renamed to "link-fetch-action" to match the "form-fetch-action".
  9. </div>
  10. <div>
  11. <button class="link-action" data-url="fetch-action-test?k=1">test action</button>
  12. <button class="link-action" data-url="fetch-action-test?k=1" data-modal-confirm="confirm?">test with confirm</button>
  13. <button class="ui red button link-action" data-url="fetch-action-test?k=1" data-modal-confirm="confirm?">test with risky confirm</button>
  14. <button class="ui button link-action" data-url="fetch-action-test?k=1" data-modal-confirm-header="confirm header" data-modal-confirm-content="confirm content">test with confirm header</button>
  15. </div>
  16. </div>
  17. <div>
  18. <h1>form-fetch-action</h1>
  19. <div>Use "window.fetch" to send a form request to backend</div>
  20. <div>
  21. <form method="get" action="fetch-action-test?k=1" class="form-fetch-action">
  22. <button name="btn">submit get</button>
  23. </form>
  24. <form method="post" action="fetch-action-test?k=1" class="form-fetch-action">
  25. <div><textarea name="text" rows="3"></textarea></div>
  26. <div><label><input name="check" type="checkbox"> check</label></div>
  27. <div><button name="btn">submit post</button></div>
  28. </form>
  29. <form method="post" action="no-such-uri" class="form-fetch-action">
  30. <div class="tw-py-8">bad action url</div>
  31. <div><button name="btn">submit test</button></div>
  32. </form>
  33. </div>
  34. </div>
  35. </div>
  36. <style>
  37. .ui.message.flash-message {
  38. text-align: left;
  39. }
  40. .form-fetch-action {
  41. margin-bottom: 1em;
  42. border: 1px red dashed; /* show the border for demo purpose */
  43. }
  44. </style>
  45. {{template "devtest/devtest-footer"}}