-
Notifications
You must be signed in to change notification settings - Fork 6
/
textbox_date.go
47 lines (38 loc) · 1.19 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
41
42
43
44
45
46
47
package generator
import (
"fmt"
"github.com/goradd/goradd/codegen/generator"
"github.com/goradd/goradd/pkg/orm/db"
"github.com/goradd/goradd/pkg/orm/query"
)
func init() {
generator.RegisterControlGenerator(DateTextbox{}, "github.com/goradd/goradd/pkg/page/control/DateTextbox")
}
// This structure describes the IntegerTextbox to the connector dialog and code generator
type DateTextbox struct {
}
func (d DateTextbox) SupportsColumn(ref interface{}) bool {
if col,ok := ref.(*db.Column); ok &&
col.ColumnType == query.ColTypeDateTime {
return true
}
return false
}
func (d DateTextbox) GenerateCreator(ref interface{}, desc *generator.ControlDescription) (s string) {
col := ref.(*db.Column)
s = fmt.Sprintf(
`%s.DateTextboxCreator{
ID: p.ID() + "-%s",
ControlOptions: page.ControlOptions{
IsRequired: %#v,
DataConnector: %s{},
},
}`, desc.Package, desc.ControlID, !col.IsNullable, desc.Connector)
return
}
func (d DateTextbox) GenerateRefresh(ref interface{}, desc *generator.ControlDescription) (s string) {
return `ctrl.SetValue(val)`
}
func (d DateTextbox) GenerateUpdate(ref interface{}, desc *generator.ControlDescription) (s string) {
return `val := ctrl.Date()`
}