-
Notifications
You must be signed in to change notification settings - Fork 6
/
textbox_date.go
40 lines (36 loc) · 1.13 KB
/
textbox_date.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
package generator
import (
"fmt"
generator2 "github.com/goradd/goradd/codegen/generator"
"github.com/goradd/goradd/pkg/config"
"github.com/goradd/goradd/pkg/orm/db"
generator3 "github.com/goradd/goradd/pkg/page/control/generator"
)
func init() {
generator2.RegisterControlGenerator(DateTextbox{}, "github.com/goradd/goradd/pkg/bootstrap/control/DateTextbox")
}
// This structure describes the textbox to the connector dialog and code generator
type DateTextbox struct {
generator3.DateTextbox // base it on the built-in generator
}
func (d DateTextbox) GenerateCreator(ref interface{}, desc *generator2.ControlDescription) (s string) {
col := ref.(*db.Column)
var format string
if col.IsDateOnly {
format = config.DefaultDateEntryFormat
} else if col.IsTimeOnly {
format = config.DefaultTimeEntryFormat
} else {
format = config.DefaultDateTimeEntryFormat
}
s = fmt.Sprintf(
`%s.DateTextboxCreator{
ID: p.ID() + "-%s",
Formats: []string{%#v},
ControlOptions: page.ControlOptions{
IsRequired: %#v,
DataConnector: %s{},
},
}`, desc.Package, desc.ControlID, format, !col.IsNullable, desc.Connector)
return
}