bootstrap start
This commit is contained in:
parent
f80c062099
commit
8706aae5ee
54 changed files with 59752 additions and 6 deletions
|
|
@ -5,6 +5,7 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
|
|
@ -62,11 +63,59 @@ func Themeform(c *core.Context) *core.Response {
|
|||
|
||||
// first, include all compoments
|
||||
type templateData struct {
|
||||
FormText components.FormInput
|
||||
FormEmail components.FormInput
|
||||
FormButton components.FormButton
|
||||
FormText components.FormInput
|
||||
FormEmail components.FormInput
|
||||
FormButton components.FormButton
|
||||
FormSelectCity components.FormSelect
|
||||
FormTextarea components.FormTextarea
|
||||
FormRadio components.FormRadio
|
||||
FormCheckbox components.FormCheckbox
|
||||
}
|
||||
|
||||
// for select options
|
||||
var allOptions []components.FormSelectOption
|
||||
var option components.FormSelectOption
|
||||
option.Value = "ch"
|
||||
option.Caption = "China"
|
||||
allOptions = append(allOptions, option)
|
||||
option.Value = "ba"
|
||||
option.Caption = "Buenos Aires"
|
||||
allOptions = append(allOptions, option)
|
||||
option.Value = "fr"
|
||||
option.Caption = "France"
|
||||
selectedOption := option
|
||||
allOptions = append(allOptions, option)
|
||||
|
||||
// for radio options
|
||||
var allOptionsr []components.FormRadioItem
|
||||
var optionr components.FormRadioItem
|
||||
optionr.ID = "citysch"
|
||||
optionr.Name = "citys"
|
||||
optionr.Value = "china"
|
||||
optionr.Label = "China"
|
||||
allOptionsr = append(allOptionsr, optionr)
|
||||
optionr.ID = "citysba"
|
||||
optionr.Name = "citys"
|
||||
optionr.Value = "buenosaires"
|
||||
optionr.Label = "Buenos Aires"
|
||||
//optionr.IsDisabled = true
|
||||
allOptionsr = append(allOptionsr, optionr)
|
||||
|
||||
// for radio options
|
||||
var allOptionsc []components.FormCheckboxItem
|
||||
var optionc components.FormCheckboxItem
|
||||
optionc.ID = "citysch"
|
||||
optionc.Name = "citys"
|
||||
optionc.Value = "china"
|
||||
optionc.Label = "China"
|
||||
allOptionsc = append(allOptionsc, optionc)
|
||||
optionc.ID = "citysba"
|
||||
optionc.Name = "citys"
|
||||
optionc.Value = "buenosaires"
|
||||
optionc.Label = "Buenos Aires"
|
||||
//optionc.IsChecked = true
|
||||
allOptionsc = append(allOptionsc, optionc)
|
||||
|
||||
// now fill data of the components
|
||||
tmplData := templateData{
|
||||
FormText: components.FormInput{
|
||||
|
|
@ -87,6 +136,24 @@ func Themeform(c *core.Context) *core.Response {
|
|||
IsSubmit: true,
|
||||
IsPrimary: true,
|
||||
},
|
||||
FormSelectCity: components.FormSelect{
|
||||
ID: "city",
|
||||
Label: "Select city",
|
||||
AllOptions: allOptions,
|
||||
SelectedOption: selectedOption,
|
||||
},
|
||||
FormTextarea: components.FormTextarea{
|
||||
ID: "text",
|
||||
Label: "Example textarea",
|
||||
},
|
||||
FormRadio: components.FormRadio{
|
||||
Label: "Radio buttons",
|
||||
AllRadios: allOptionsr,
|
||||
},
|
||||
FormCheckbox: components.FormCheckbox{
|
||||
Label: "Checkbox options",
|
||||
AllCheckbox: allOptionsc,
|
||||
},
|
||||
}
|
||||
return c.Response.Template("custom_theme_formpage.html", tmplData)
|
||||
|
||||
|
|
@ -98,3 +165,62 @@ func Themeform(c *core.Context) *core.Response {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
// Show form element page
|
||||
func Themecontent(c *core.Context) *core.Response {
|
||||
|
||||
// check if template engine is enabled
|
||||
TemplateEnableStr := os.Getenv("TEMPLATE_ENABLE")
|
||||
if TemplateEnableStr == "" {
|
||||
TemplateEnableStr = "false"
|
||||
}
|
||||
TemplateEnable, _ := strconv.ParseBool(TemplateEnableStr)
|
||||
|
||||
if TemplateEnable {
|
||||
|
||||
// first, include all compoments
|
||||
type templateData struct {
|
||||
ContentTable components.ContentTable
|
||||
}
|
||||
|
||||
// TABLES
|
||||
// for th head
|
||||
var allTh []components.ContentTableTH
|
||||
var th components.ContentTableTH
|
||||
th.Value = "Column heading 1"
|
||||
allTh = append(allTh, th)
|
||||
th.Value = "Column heading 2"
|
||||
allTh = append(allTh, th)
|
||||
th.ID = "ba"
|
||||
th.Value = "Column heading 3"
|
||||
allTh = append(allTh, th)
|
||||
// for td items
|
||||
var allTd [][]components.ContentTableTD
|
||||
var vals []components.ContentTableTD
|
||||
// rows
|
||||
for i := 0; i < 5; i++ {
|
||||
for b := 0; b < len(allTh); b++ {
|
||||
vals[b].Value = fmt.Sprintf("%s%d%d", "TD data: ", b, i)
|
||||
}
|
||||
allTd = append(allTd, vals)
|
||||
}
|
||||
|
||||
// now fill data of the components
|
||||
tmplData := templateData{
|
||||
ContentTable: components.ContentTable{
|
||||
ID: "email",
|
||||
Label: "Email",
|
||||
AllTH: allTh,
|
||||
AllTD: allTd,
|
||||
},
|
||||
}
|
||||
return c.Response.Template("custom_theme_contentpage.html", tmplData)
|
||||
|
||||
} else {
|
||||
|
||||
message := "{\"message\": \"Error, template not enabled\"}"
|
||||
return c.Response.Json(message)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue