func (v *AddPopupView) modal(markup ...vecty.MarkupOrComponentOrHTML) *vecty.HTML { return elem.Div( prop.ID("add-modal"), prop.Class("modal"), vecty.Data("backdrop", "static"), vecty.Data("keyboard", "false"), elem.Div( prop.Class("modal-dialog"), elem.Div( prop.Class("modal-content"), elem.Div( prop.Class("modal-header"), elem.Button( prop.Type(prop.TypeButton), prop.Class("close"), elem.Span( vecty.Text("×"), ), event.Click(func(ev *vecty.Event) { v.App.Dispatch(&actions.CloseAddPopup{}) }).PreventDefault(), ), elem.Header4( prop.Class("modal-title"), vecty.Text("Add item"), ), ), vecty.List(markup), elem.Div( prop.Class("modal-footer"), elem.Button( prop.Type(prop.TypeButton), prop.Class("btn btn-default"), elem.Span( vecty.Text("Close"), ), event.Click(func(ev *vecty.Event) { v.App.Dispatch(&actions.CloseAddPopup{}) }).PreventDefault(), ), elem.Button( prop.Type(prop.TypeButton), prop.Class("btn btn-primary"), elem.Span( vecty.Text("Save"), ), event.Click(func(ev *vecty.Event) { v.save() }).PreventDefault(), ), ), ), ), ) }
func (v *PageView) Render() *vecty.HTML { return elem.Body( prop.ID("wrapper"), NewHeader(v.Ctx), elem.Div( prop.Class("wrapper"), elem.Div( prop.ID("tree"), prop.Class("split split-horizontal"), NewTreeView(v.Ctx), ), elem.Div( prop.ID("main"), prop.Class("split split-horizontal"), NewPanelView(v.Ctx), ), ), NewAddPopupView(v.Ctx), ) }
func (v *Header) Render() *vecty.HTML { return elem.Navigation( prop.Class("navbar navbar-inverse navbar-fixed-top"), elem.Div( prop.Class("container-fluid"), elem.Div( prop.Class("navbar-header"), elem.Button( prop.Type("button"), prop.Class("navbar-toggle collapsed"), vecty.Data("toggle", "collapse"), vecty.Data("target", "#navbar"), elem.Span( prop.Class("sr-only"), vecty.Text("Toggle navigation"), ), elem.Span( prop.Class("icon-bar"), ), elem.Span( prop.Class("icon-bar"), ), elem.Span( prop.Class("icon-bar"), ), ), /* elem.Anchor( prop.Class("navbar-brand"), prop.Href("#"), vecty.Text("Ke"), ), */ ), elem.Div( prop.ID("navbar"), prop.Class("navbar-collapse collapse"), elem.UnorderedList( prop.Class("nav navbar-nav"), NewViewMenuView(v.Ctx), NewEditMenuView(v.Ctx), NewSaveView(v.Ctx), ), elem.Form( prop.Class("navbar-form navbar-right"), elem.Input( prop.Type("text"), prop.Class("form-control"), prop.Placeholder("Search..."), ), ), ), ), ) }
func (v *AddPopupView) Render() *vecty.HTML { if v.model == nil || !v.model.Visible { return v.modal() } v.nameInput = nil v.typeSelect = nil var nameControl, typeControl *vecty.HTML if v.model.HasName() { v.nameInput = elem.Input( prop.Class("form-control"), prop.ID("add-modal-name"), ) nameControl = elem.Div( prop.Class("form-group"), elem.Label( prop.For("add-modal-name"), vecty.Text("name"), ), v.nameInput, elem.Paragraph( prop.Class("help-block"), vecty.Text("Enter a name for the new item"), ), ) } if len(v.model.Types) > 1 { var options vecty.List for _, t := range v.model.Types { displayName, err := t.Id.ValueContext(v.Ctx) if err != nil { // we shouldn't be able to get here v.App.Fail <- kerr.Wrap("NTSWPIEAHC", err) } options = append(options, elem.Option( prop.ID(t.Id.String()), vecty.Text(displayName), )) } v.typeSelect = elem.Select( prop.Class("form-control"), prop.ID("add-modal-type"), elem.Option( prop.ID(""), vecty.Text(""), ), options, ) typeControl = elem.Div( prop.Class("form-group"), elem.Label( prop.For("add-modal-type"), vecty.Text("type"), ), v.typeSelect, elem.Paragraph( prop.Class("help-block"), vecty.Text("Select a type for the new object"), ), ) } return v.modal( elem.Div( prop.Class("modal-body"), elem.Form( event.Submit(func(ev *vecty.Event) { v.save() }).PreventDefault(), nameControl, typeControl, ), ), ) }