func (s *BranchStore) InsertNodeBranchModelChild(b *models.BranchModel, n *node.Node, index int, name string, filename string) *models.BranchModel { if n.Missing || n.Null { return nil } e := models.GetEditable(s.ctx, n) if e == nil || e.Format(n.Rule) == editable.Branch { var child *models.BranchModel if filename == "" { child = s.NewNodeBranchModel(s.ctx, n, name) } else { child = s.NewFileBranchModel(s.ctx, n, name, filename) } b.Insert(index, child) return child } return nil }
func (v *EditorListView) Render() *vecty.HTML { if v.model == nil || v.model.Node.Missing || v.model.Node.Null { return elem.Div(vecty.Text("editor (nil)")) } children := vecty.List{} add := func(n *node.Node) { for _, v := range v.exclude { if n.Key == v { return } } if n.Null || n.Missing { children = append(children, nullEditor(v.Ctx, n, v.App)) return } f := editable.Branch if e := models.GetEditable(v.Ctx, n); e != nil { f = e.Format(n.Rule) if f == editable.Block || f == editable.Inline { children = append(children, NewEditorView(v.Ctx, n).Controls( func() vecty.MarkupOrComponentOrHTML { return e.EditorView(v.Ctx, n, editable.Block) }, ), ) return } } if f == editable.Branch { b := v.App.Branches.Get(n) children = append(children, NewEditorView(v.Ctx, n).Icons( func() vecty.MarkupOrComponentOrHTML { return elem.Anchor( prop.Href("#"), event.Click(func(e *vecty.Event) { v.App.Dispatch(&actions.BranchSelecting{Branch: b, Op: models.BranchOpClickEditorLink}) }).PreventDefault(), elem.Italic( prop.Class("editor-icon editor-icon-after glyphicon glyphicon-share-alt"), ), ) }, )) } } for _, n := range v.model.Node.Map { // TODO: hide optional fields //if n.Missing || n.Null { // continue //} if v.filter != nil && *n.Origin != *v.filter { continue } add(n) } for _, n := range v.model.Node.Array { add(n) } v.items = len(children) if len(children) == 0 { v.container = elem.Div() } else { v.container = elem.Form( event.Submit(func(*vecty.Event) {}).PreventDefault(), children, ) } return v.container }