-
Notifications
You must be signed in to change notification settings - Fork 6
/
modal.go
57 lines (47 loc) · 1.36 KB
/
modal.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
package panels
import (
"context"
. "github.com/goradd/goradd/pkg/bootstrap/control"
"github.com/goradd/goradd/pkg/bootstrap/examples"
"github.com/goradd/goradd/pkg/page"
"github.com/goradd/goradd/pkg/page/action"
"github.com/goradd/goradd/pkg/page/control"
)
const (
PopupClick int = iota + 10
)
type ModalPanel struct {
control.Panel
}
func NewModalPanel(ctx context.Context, parent page.ControlI) {
p := new(ModalPanel)
p.Init(p, ctx, parent, "modalPanel")
}
func (p *ModalPanel) Init(self any, ctx context.Context, parent page.ControlI, id string) {
p.Panel.Init(self, parent, id)
p.Panel.AddControls(ctx,
ButtonCreator{
ID: "popupButton",
Text: "Popup Modal",
OnSubmit: action.Do().ID(PopupClick),
},
)
m := NewModal(p.ParentForm(), "modal")
m.AddCloseButton("Close Me", "close")
m.SetTitle("My Modal")
t := control.NewPanel(m, "modbody")
t.SetText("What is in the modal?")
}
func (p *ModalPanel) DoAction(ctx context.Context, a action.Params) {
switch a.ID {
case PopupClick:
m := GetModal(p, "modal")
m.Show()
}
}
func init() {
examples.RegisterPanel("modal", "Modal", NewModalPanel, 6)
page.RegisterControl(&ModalPanel{})
//browsertest.RegisterTestFunction("Bootstrap Standard Form Do Submit", testForms1AjaxSubmit)
//browsertest.RegisterTestFunction("Bootstrap Standard Form Server Submit", testForms1ServerSubmit)
}