Added datalists
This commit is contained in:
parent
664debf024
commit
ae32a1a6cb
@ -13,10 +13,12 @@ component InputNumber(id string, value float64, label string, placeholder string
|
|||||||
label(for=id)= label + ":"
|
label(for=id)= label + ":"
|
||||||
input.widget-ui-element.action(id=id, data-field=id, type="number", value=value, min=min, max=max, step=step, placeholder=placeholder, title=placeholder, data-action="save", data-trigger="change")
|
input.widget-ui-element.action(id=id, data-field=id, type="number", value=value, min=min, max=max, step=step, placeholder=placeholder, title=placeholder, data-action="save", data-trigger="change")
|
||||||
|
|
||||||
component InputSelection(id string, value string, label string, placeholder string, values []string)
|
component InputSelection(id string, value string, label string, placeholder string, options []*arn.Option)
|
||||||
.widget-section
|
.widget-section
|
||||||
label(for=id)= label + ":"
|
label(for=id)= label + ":"
|
||||||
select.widget-ui-element.action(id=id, data-field=id, value=value, title=placeholder, data-action="save", data-trigger="change")
|
select.widget-ui-element.action(id=id, data-field=id, value=value, title=placeholder, data-action="save", data-trigger="change")
|
||||||
|
each option in options
|
||||||
|
option(value=option.Value)= option.Label
|
||||||
|
|
||||||
component InputTags(id string, value []string, label string, tooltip string)
|
component InputTags(id string, value []string, label string, tooltip string)
|
||||||
.widget-section
|
.widget-section
|
||||||
|
@ -66,10 +66,14 @@ func RenderField(b *bytes.Buffer, v *reflect.Value, field reflect.StructField, i
|
|||||||
|
|
||||||
switch field.Type.String() {
|
switch field.Type.String() {
|
||||||
case "string":
|
case "string":
|
||||||
if field.Tag.Get("type") == "textarea" {
|
if field.Tag.Get("datalist") != "" {
|
||||||
b.WriteString(components.InputTextArea(idPrefix+field.Name, fieldValue.String(), field.Name, ""))
|
dataList := field.Tag.Get("datalist")
|
||||||
|
values := arn.DataLists[dataList]
|
||||||
|
b.WriteString(components.InputSelection(idPrefix+field.Name, fieldValue.String(), field.Name, field.Tag.Get("tooltip"), values))
|
||||||
|
} else if field.Tag.Get("type") == "textarea" {
|
||||||
|
b.WriteString(components.InputTextArea(idPrefix+field.Name, fieldValue.String(), field.Name, field.Tag.Get("tooltip")))
|
||||||
} else {
|
} else {
|
||||||
b.WriteString(components.InputText(idPrefix+field.Name, fieldValue.String(), field.Name, ""))
|
b.WriteString(components.InputText(idPrefix+field.Name, fieldValue.String(), field.Name, field.Tag.Get("tooltip")))
|
||||||
}
|
}
|
||||||
case "[]string":
|
case "[]string":
|
||||||
b.WriteString(components.InputTags(idPrefix+field.Name, fieldValue.Interface().([]string), field.Name, field.Tag.Get("tooltip")))
|
b.WriteString(components.InputTags(idPrefix+field.Name, fieldValue.Interface().([]string), field.Name, field.Tag.Get("tooltip")))
|
||||||
|
Loading…
Reference in New Issue
Block a user