560 lines
12 KiB
Go
560 lines
12 KiB
Go
// Code generated by templ@(devel) DO NOT EDIT.
|
|
|
|
package bulkupdate
|
|
|
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
|
|
|
import "github.com/a-h/templ"
|
|
import "context"
|
|
import "io"
|
|
import "bytes"
|
|
|
|
// GoExpression
|
|
import (
|
|
"fmt"
|
|
|
|
"examples/shared"
|
|
)
|
|
|
|
func demo(users []user) templ.Component {
|
|
return templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) {
|
|
templBuffer, templIsBuffer := w.(*bytes.Buffer)
|
|
if !templIsBuffer {
|
|
templBuffer = templ.GetBuffer()
|
|
defer templ.ReleaseBuffer(templBuffer)
|
|
}
|
|
ctx = templ.InitializeContext(ctx)
|
|
var_1 := templ.GetChildren(ctx)
|
|
if var_1 == nil {
|
|
var_1 = templ.NopComponent
|
|
}
|
|
ctx = templ.ClearChildren(ctx)
|
|
// Element (standard)
|
|
_, err = templBuffer.WriteString("<h3")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element Attributes
|
|
_, err = templBuffer.WriteString(" class=\"subtitle\"")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString(">")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Text
|
|
var_2 := `Select Rows And Activate Or Deactivate Below`
|
|
_, err = templBuffer.WriteString(var_2)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString("</h3>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element (standard)
|
|
_, err = templBuffer.WriteString("<form")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element Attributes
|
|
_, err = templBuffer.WriteString(" id=\"checked-contacts\"")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString(">")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element (standard)
|
|
_, err = templBuffer.WriteString("<table")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element Attributes
|
|
_, err = templBuffer.WriteString(" class=\"table\"")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString(">")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element (standard)
|
|
_, err = templBuffer.WriteString("<thead>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element (standard)
|
|
_, err = templBuffer.WriteString("<tr>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element (standard)
|
|
_, err = templBuffer.WriteString("<td>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString("</td>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element (standard)
|
|
_, err = templBuffer.WriteString("<td>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Text
|
|
var_3 := `Name`
|
|
_, err = templBuffer.WriteString(var_3)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString("</td>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element (standard)
|
|
_, err = templBuffer.WriteString("<td>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Text
|
|
var_4 := `Email`
|
|
_, err = templBuffer.WriteString(var_4)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString("</td>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element (standard)
|
|
_, err = templBuffer.WriteString("<td>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Text
|
|
var_5 := `Status`
|
|
_, err = templBuffer.WriteString(var_5)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString("</td>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString("</tr>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString("</thead>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// TemplElement
|
|
err = tbody(users, map[int]bool{}).Render(ctx, templBuffer)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString("</table>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString("</form>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element (standard)
|
|
_, err = templBuffer.WriteString("<div")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element Attributes
|
|
_, err = templBuffer.WriteString(" hx-swap=\"outerHTML\"")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString(" hx-include=\"#checked-contacts\"")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString(" hx-target=\"#tbody\"")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString(" class=\"field is-grouped\"")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString(">")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element (standard)
|
|
_, err = templBuffer.WriteString("<div")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element Attributes
|
|
_, err = templBuffer.WriteString(" class=\"control\"")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString(">")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element (standard)
|
|
_, err = templBuffer.WriteString("<a")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element Attributes
|
|
_, err = templBuffer.WriteString(" class=\"button is-black\"")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString(" hx-put=\"/bulk-update/activate\"")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString(">")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Text
|
|
var_6 := `Activate`
|
|
_, err = templBuffer.WriteString(var_6)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString("</a>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString("</div>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element (standard)
|
|
_, err = templBuffer.WriteString("<div")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element Attributes
|
|
_, err = templBuffer.WriteString(" class=\"control\"")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString(">")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element (standard)
|
|
_, err = templBuffer.WriteString("<a")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element Attributes
|
|
_, err = templBuffer.WriteString(" class=\"button\"")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString(" hx-put=\"/bulk-update/deactivate\"")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString(">")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Text
|
|
var_7 := `Deactivate`
|
|
_, err = templBuffer.WriteString(var_7)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString("</a>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString("</div>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString("</div>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// RawElement
|
|
_, err = templBuffer.WriteString("<style>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Text
|
|
var_8 := `
|
|
.htmx-settling tr.deactivate td {
|
|
background: lightcoral;
|
|
}
|
|
.htmx-settling tr.activate td {
|
|
background: darkseagreen;
|
|
}
|
|
tr td {
|
|
transition: all 1.2s;
|
|
}
|
|
`
|
|
_, err = templBuffer.WriteString(var_8)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString("</style>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if !templIsBuffer {
|
|
_, err = io.Copy(w, templBuffer)
|
|
}
|
|
return err
|
|
})
|
|
}
|
|
|
|
func tbody(users []user, modified map[int]bool) templ.Component {
|
|
return templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) {
|
|
templBuffer, templIsBuffer := w.(*bytes.Buffer)
|
|
if !templIsBuffer {
|
|
templBuffer = templ.GetBuffer()
|
|
defer templ.ReleaseBuffer(templBuffer)
|
|
}
|
|
ctx = templ.InitializeContext(ctx)
|
|
var_9 := templ.GetChildren(ctx)
|
|
if var_9 == nil {
|
|
var_9 = templ.NopComponent
|
|
}
|
|
ctx = templ.ClearChildren(ctx)
|
|
// Element (standard)
|
|
_, err = templBuffer.WriteString("<tbody")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element Attributes
|
|
_, err = templBuffer.WriteString(" id=\"tbody\"")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString(">")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// For
|
|
for k, u := range users {
|
|
// Element (standard)
|
|
_, err = templBuffer.WriteString("<tr")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element Attributes
|
|
if modified[k] && u.active {
|
|
// Element Attributes
|
|
_, err = templBuffer.WriteString(" class=\"activate\"")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
if modified[k] && !u.active {
|
|
// Element Attributes
|
|
_, err = templBuffer.WriteString(" class=\"deactivate\"")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
_, err = templBuffer.WriteString(">")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element (standard)
|
|
_, err = templBuffer.WriteString("<td>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element (void)
|
|
_, err = templBuffer.WriteString("<input")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element Attributes
|
|
_, err = templBuffer.WriteString(" type=\"checkbox\"")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString(" name=\"ids\"")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString(" value=")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString("\"")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString(templ.EscapeString(fmt.Sprint(k)))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString("\"")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString(">")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString("</td>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element (standard)
|
|
_, err = templBuffer.WriteString("<td>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// StringExpression
|
|
var var_10 string = u.name
|
|
_, err = templBuffer.WriteString(templ.EscapeString(var_10))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString("</td>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element (standard)
|
|
_, err = templBuffer.WriteString("<td>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// StringExpression
|
|
var var_11 string = u.email
|
|
_, err = templBuffer.WriteString(templ.EscapeString(var_11))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString("</td>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element (standard)
|
|
_, err = templBuffer.WriteString("<td>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// If
|
|
if u.active {
|
|
// Text
|
|
var_12 := `Active`
|
|
_, err = templBuffer.WriteString(var_12)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
} else {
|
|
// Text
|
|
var_13 := `Inactive`
|
|
_, err = templBuffer.WriteString(var_13)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
_, err = templBuffer.WriteString("</td>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString("</tr>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
_, err = templBuffer.WriteString("</tbody>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if !templIsBuffer {
|
|
_, err = io.Copy(w, templBuffer)
|
|
}
|
|
return err
|
|
})
|
|
}
|
|
|
|
func Index(users []user) templ.Component {
|
|
return templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) {
|
|
templBuffer, templIsBuffer := w.(*bytes.Buffer)
|
|
if !templIsBuffer {
|
|
templBuffer = templ.GetBuffer()
|
|
defer templ.ReleaseBuffer(templBuffer)
|
|
}
|
|
ctx = templ.InitializeContext(ctx)
|
|
var_14 := templ.GetChildren(ctx)
|
|
if var_14 == nil {
|
|
var_14 = templ.NopComponent
|
|
}
|
|
ctx = templ.ClearChildren(ctx)
|
|
// TemplElement
|
|
var_15 := templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) {
|
|
templBuffer, templIsBuffer := w.(*bytes.Buffer)
|
|
if !templIsBuffer {
|
|
templBuffer = templ.GetBuffer()
|
|
defer templ.ReleaseBuffer(templBuffer)
|
|
}
|
|
// Element (standard)
|
|
_, err = templBuffer.WriteString("<h2")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Element Attributes
|
|
_, err = templBuffer.WriteString(" class=\"title\"")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString(">")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Text
|
|
var_16 := `Bulk Update`
|
|
_, err = templBuffer.WriteString(var_16)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = templBuffer.WriteString("</h2>")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Whitespace (normalised)
|
|
_, err = templBuffer.WriteString(` `)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// TemplElement
|
|
err = demo(users).Render(ctx, templBuffer)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if !templIsBuffer {
|
|
_, err = io.Copy(w, templBuffer)
|
|
}
|
|
return err
|
|
})
|
|
err = shared.Layout("Bulk Update").Render(templ.WithChildren(ctx, var_15), templBuffer)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if !templIsBuffer {
|
|
_, err = io.Copy(w, templBuffer)
|
|
}
|
|
return err
|
|
})
|
|
}
|
|
|