forked from goffee/core
Merge pull request 'WIP pull' (#1) from goffee/core:main into main
Reviewed-on: #1
This commit is contained in:
commit
8b9728c3d2
7 changed files with 29 additions and 11 deletions
2
core.go
2
core.go
|
@ -245,7 +245,7 @@ func (app *App) makeHTTPRouterHandlerFunc(h Controller, ms []Hook) httprouter.Ha
|
||||||
w.WriteHeader(ctx.Response.statusCode)
|
w.WriteHeader(ctx.Response.statusCode)
|
||||||
}
|
}
|
||||||
if ctx.Response.redirectTo != "" {
|
if ctx.Response.redirectTo != "" {
|
||||||
http.Redirect(w, r, ctx.Response.redirectTo, http.StatusPermanentRedirect)
|
http.Redirect(w, r, ctx.Response.redirectTo, http.StatusTemporaryRedirect)
|
||||||
} else {
|
} else {
|
||||||
w.Write(ctx.Response.body)
|
w.Write(ctx.Response.body)
|
||||||
}
|
}
|
||||||
|
|
11
response.go
11
response.go
|
@ -27,6 +27,17 @@ type header struct {
|
||||||
val string
|
val string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO add doc
|
||||||
|
func (rs *Response) BufferPDF(name string, b bytes.Buffer) *Response {
|
||||||
|
|
||||||
|
if rs.isTerminated == false {
|
||||||
|
rs.HttpResponseWriter.Header().Add("Content-Type", "application/pdf")
|
||||||
|
rs.HttpResponseWriter.Header().Add("Content-Disposition", "attachment; filename="+name)
|
||||||
|
b.WriteTo(rs.HttpResponseWriter)
|
||||||
|
}
|
||||||
|
return rs
|
||||||
|
}
|
||||||
|
|
||||||
// TODO add doc
|
// TODO add doc
|
||||||
func (rs *Response) Any(body any) *Response {
|
func (rs *Response) Any(body any) *Response {
|
||||||
if rs.isTerminated == false {
|
if rs.isTerminated == false {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package components
|
package components
|
||||||
|
|
||||||
type ContentDropdown struct {
|
type ContentDropdown struct {
|
||||||
|
ID string
|
||||||
Label string
|
Label string
|
||||||
TypeClass string // type primary, secondary, success, danger, warning, info, light, dark, link, outline-primary
|
TypeClass string // type primary, secondary, success, danger, warning, info, light, dark, link, outline-primary
|
||||||
IsDisabled bool
|
IsDisabled bool
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package components
|
package components
|
||||||
|
|
||||||
type FormButton struct {
|
type FormButton struct {
|
||||||
|
ID string
|
||||||
|
Value string
|
||||||
Text string
|
Text string
|
||||||
Icon string
|
Icon string
|
||||||
IsSubmit bool
|
IsSubmit bool
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{{define "form_button"}}
|
{{define "form_button"}}
|
||||||
<button class="btn btn-{{.TypeClass}}" {{if eq .IsSubmit true}}type="submit"{{else}}type="button"{{end}} {{if .IsDisabled}}disabled{{end}}>
|
<button {{if .ID }}id="{{.ID}}" name="{{.ID}}"{{end}} {{if .Value }}value="{{.Value}}" name="{{.ID}}"{{end}} class="btn btn-{{.TypeClass}}" {{if eq .IsSubmit true}}type="submit"{{else}}type="button"{{end}} {{if .IsDisabled}}disabled{{end}}>
|
||||||
{{.Text}}
|
{{.Text}}
|
||||||
</button>
|
</button>
|
||||||
<!-- tailwind heroicons -->
|
<!-- tailwind heroicons -->
|
||||||
|
|
|
@ -9,5 +9,6 @@ type FormInput struct {
|
||||||
Hint string
|
Hint string
|
||||||
Error string
|
Error string
|
||||||
IsDisabled bool
|
IsDisabled bool
|
||||||
|
Autocomplete bool
|
||||||
IsRequired bool
|
IsRequired bool
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,9 @@
|
||||||
{{if eq .IsRequired true}}
|
{{if eq .IsRequired true}}
|
||||||
required
|
required
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{if eq .Autocomplete false}}
|
||||||
|
autocomplete="off"
|
||||||
|
{{end}}
|
||||||
{{if ne .Value ""}}
|
{{if ne .Value ""}}
|
||||||
value="{{.Value}}"
|
value="{{.Value}}"
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
Loading…
Reference in a new issue