mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-15 12:56:10 +00:00
refactor: wiki edit form (#38918)
1. the fragile `document.querySelector('.repository.wiki.new
.ui.form')!` is broken (again), rewrite to "data-global-init"
* regression from #37571 because a new form was added
3. use "form-fetch-action" and JSON response instead of
"RenderWithErrDeprecated"
This commit is contained in:
@@ -298,6 +298,7 @@ func GetFetchActionForm[T interface {
|
||||
}
|
||||
form := T(new(E))
|
||||
errs := binding.Bind(ctx.Req, form)
|
||||
errs = form.Validate(GetValidateContext(ctx.Req), errs)
|
||||
errorMessage, fieldName, _ := middleware.BuildValidationErrorForUser(form, ctx.Locale, errs)
|
||||
if errorMessage != "" {
|
||||
ctx.Resp.Header().Set("Content-Type", "application/json")
|
||||
|
||||
+11
-18
@@ -558,27 +558,20 @@ type EditReleaseForm struct {
|
||||
Files []string
|
||||
}
|
||||
|
||||
// __ __.__ __ .__
|
||||
// / \ / \__| | _|__|
|
||||
// \ \/\/ / | |/ / |
|
||||
// \ /| | <| |
|
||||
// \__/\ / |__|__|_ \__|
|
||||
// \/ \/
|
||||
|
||||
// NewWikiForm form for creating wiki
|
||||
type NewWikiForm struct {
|
||||
middleware.FormDefaultValidator
|
||||
Title string `binding:"Required"`
|
||||
Content string `binding:"Required"`
|
||||
type WikiEditForm struct {
|
||||
Title string
|
||||
Content string
|
||||
Message string
|
||||
}
|
||||
|
||||
// ___________.__ ___________ __
|
||||
// \__ ___/|__| _____ ____ \__ ___/___________ ____ | | __ ___________
|
||||
// | | | |/ \_/ __ \ | | \_ __ \__ \ _/ ___\| |/ // __ \_ __ \
|
||||
// | | | | Y Y \ ___/ | | | | \// __ \\ \___| <\ ___/| | \/
|
||||
// |____| |__|__|_| /\___ > |____| |__| (____ /\___ >__|_ \\___ >__|
|
||||
// \/ \/ \/ \/ \/ \/
|
||||
func (f *WikiEditForm) Validate(ctx *middleware.ValidateContext, errs binding.Errors) binding.Errors {
|
||||
f.Title = strings.TrimSpace(f.Title)
|
||||
if f.Title == "" {
|
||||
errs = middleware.AddValidationError(errs, "title", ctx.Locale.TrString("repo.issues.new.title_empty"))
|
||||
}
|
||||
f.Message = strings.TrimSpace(f.Message)
|
||||
return errs
|
||||
}
|
||||
|
||||
// AddTimeManuallyForm form that adds spent time manually.
|
||||
type AddTimeManuallyForm struct {
|
||||
|
||||
Reference in New Issue
Block a user