Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Nov 30, 2023
2 parents 63e9e70 + 1947500 commit 76822c6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
15 changes: 8 additions & 7 deletions kernel/av/av.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func ShallowCloneAttributeView(av *AttributeView) (ret *AttributeView) {
view.ID = ast.NewNodeID()
ret.ViewID = view.ID
} else {
view = NewView()
view, _ = NewView()
ret.ViewID = view.ID
ret.Views = append(ret.Views, view)
}
Expand Down Expand Up @@ -559,9 +559,9 @@ const (
LayoutTypeTable LayoutType = "table" // 属性视图类型 - 表格
)

func NewView() *View {
func NewView() (view *View, blockKey *Key) {
name := "Table"
return &View{
view = &View{
ID: ast.NewNodeID(),
Name: name,
LayoutType: LayoutTypeTable,
Expand All @@ -572,6 +572,9 @@ func NewView() *View {
Sorts: []*ViewSort{},
},
}
blockKey = NewKey(ast.NewNodeID(), "Block", "", KeyTypeBlock)
view.Table.Columns = []*ViewTableColumn{{ID: blockKey.ID}}
return
}

// Viewable 描述了视图的接口。
Expand All @@ -585,16 +588,14 @@ type Viewable interface {
}

func NewAttributeView(id string) (ret *AttributeView) {
view := NewView()
key := NewKey(ast.NewNodeID(), "Block", "", KeyTypeBlock)
view, blockKey := NewView()
ret = &AttributeView{
Spec: 0,
ID: id,
KeyValues: []*KeyValues{{Key: key}},
KeyValues: []*KeyValues{{Key: blockKey}},
ViewID: view.ID,
Views: []*View{view},
}
view.Table.Columns = []*ViewTableColumn{{ID: key.ID}}
return
}

Expand Down
2 changes: 1 addition & 1 deletion kernel/model/attribute_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func RenderAttributeView(avID, viewID string) (viewable av.Viewable, attrView *a

func renderAttributeView(attrView *av.AttributeView, viewID string) (viewable av.Viewable, err error) {
if 1 > len(attrView.Views) {
view := av.NewView()
view, _ := av.NewView()
attrView.Views = append(attrView.Views, view)
attrView.ViewID = view.ID
if err = av.SaveAttributeView(attrView); nil != err {
Expand Down
2 changes: 1 addition & 1 deletion kernel/model/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func (tx *Transaction) doAddAttrViewView(operation *Operation) (ret *TxErr) {
return &TxErr{code: TxErrCodeBlockNotFound, id: avID}
}

view := av.NewView()
view, _ := av.NewView()
view.ID = operation.ID
attrView.Views = append(attrView.Views, view)
attrView.ViewID = view.ID
Expand Down

0 comments on commit 76822c6

Please sign in to comment.