-
Notifications
You must be signed in to change notification settings - Fork 0
/
datefield.go
64 lines (55 loc) · 1.68 KB
/
datefield.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package xdommask
import (
"fmt"
"strconv"
"github.com/webability-go/wajaf"
)
type DateField struct {
*TextField
}
func NewDateField(name string) *DateField {
df := &DateField{
TextField: NewTextField(name),
}
df.Type = FIELD
return df
}
func (f *DateField) Compile() wajaf.NodeDef {
t := wajaf.NewTextFieldElement(f.ID)
t.SetAttribute("style", f.Style)
t.SetAttribute("classname", f.ClassName)
t.SetData(f.Title)
t.SetAttribute("size", f.Size)
if f.MinLength >= 0 {
t.SetAttribute("minlength", strconv.Itoa(f.MinLength))
}
if f.MaxLength >= 0 {
t.SetAttribute("maxlength", strconv.Itoa(f.MaxLength))
}
if f.MinWords >= 0 {
t.SetAttribute("minwords", strconv.Itoa(f.MinWords))
}
if f.MaxWords >= 0 {
t.SetAttribute("maxwords", strconv.Itoa(f.MaxWords))
}
t.SetAttribute("format", f.FormatJS)
t.SetAttribute("visible", convertModes(f.AuthModes))
t.SetAttribute("info", convertModes(f.ViewModes))
t.SetAttribute("readonly", convertModes(f.ReadOnlyModes))
t.SetAttribute("notnull", convertModes(f.NotNullModes))
t.SetAttribute("disabled", convertModes(f.DisabledModes))
t.SetAttribute("helpmode", convertModes(f.HelpModes))
t.AddHelp("", "", f.HelpDescription)
t.AddMessage("defaultvalue", fmt.Sprint(f.DefaultValue))
t.AddMessage("statusnotnull", f.StatusNotNull)
t.AddMessage("statusbadformat", f.StatusBadFormat)
t.AddMessage("statustooshort", f.StatusTooShort)
t.AddMessage("statustoolong", f.StatusTooLong)
t.AddMessage("statustoofewwords", f.StatusTooFewWords)
t.AddMessage("statustoomanywords", f.StatusTooManyWords)
t.AddMessage("statuscheck", f.StatusCheck)
t.AddEvent("keyup", f.KeyUpJS)
t.AddEvent("blur", f.BlurJS)
t.AddEvent("focus", f.FocusJS)
return t
}