Skip to content

Commit

Permalink
🎨 New a row in the database no longer require to create a relevant doc
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Sep 27, 2023
1 parent 85aca52 commit 863eb5e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
9 changes: 5 additions & 4 deletions kernel/av/av.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ type KeySelectOption struct {
}

type Value struct {
ID string `json:"id,omitempty"`
KeyID string `json:"keyID,omitempty"`
BlockID string `json:"blockID,omitempty"`
Type KeyType `json:"type,omitempty"`
ID string `json:"id,omitempty"`
KeyID string `json:"keyID,omitempty"`
BlockID string `json:"blockID,omitempty"`
Type KeyType `json:"type,omitempty"`
IsDetached bool `json:"isDetached,omitempty"`

Block *ValueBlock `json:"block,omitempty"`
Text *ValueText `json:"text,omitempty"`
Expand Down
14 changes: 10 additions & 4 deletions kernel/model/attribute_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,12 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
}

// 过滤掉不存在的行
notFound := []string{}
for blockID, _ := range rows {
var notFound []string
for blockID, v := range rows {
if v[0].IsDetached {
continue
}

if treenode.GetBlockTree(blockID) == nil {
notFound = append(notFound, blockID)
}
Expand Down Expand Up @@ -417,7 +421,7 @@ func (tx *Transaction) doInsertAttrViewBlock(operation *Operation) (ret *TxErr)

func addAttributeViewBlock(blockID string, operation *Operation, tree *parse.Tree, tx *Transaction) (err error) {
var node *ast.Node
if "" != blockID {
if !operation.IsDetached {
node = treenode.GetNodeInTree(tree, blockID)
if nil == node {
err = ErrBlockNotFound
Expand All @@ -428,6 +432,8 @@ func addAttributeViewBlock(blockID string, operation *Operation, tree *parse.Tre
// 不能将一个属性视图拖拽到另一个属性视图中
return
}
} else {
blockID = ast.NewNodeID()
}

attrView, err := av.ParseAttributeView(operation.AvID)
Expand All @@ -448,7 +454,7 @@ func addAttributeViewBlock(blockID string, operation *Operation, tree *parse.Tre
}
}

value := &av.Value{ID: ast.NewNodeID(), KeyID: blockValues.Key.ID, BlockID: blockID, Type: av.KeyTypeBlock, Block: &av.ValueBlock{ID: blockID, Content: getNodeRefText(node)}}
value := &av.Value{ID: ast.NewNodeID(), KeyID: blockValues.Key.ID, BlockID: blockID, Type: av.KeyTypeBlock, IsDetached: operation.IsDetached, Block: &av.ValueBlock{ID: blockID, Content: getNodeRefText(node)}}
blockValues.Values = append(blockValues.Values, value)

if nil != node {
Expand Down
15 changes: 8 additions & 7 deletions kernel/model/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -1099,13 +1099,14 @@ type Operation struct {

DeckID string `json:"deckID"` // 用于添加/删除闪卡

AvID string `json:"avID"` // 属性视图 ID
SrcIDs []string `json:"srcIDs"` // 用于将块拖拽到属性视图中
Name string `json:"name"` // 属性视图列名
Typ string `json:"type"` // 属性视图列类型
Format string `json:"format"` // 属性视图列格式化
KeyID string `json:"keyID"` // 属性视列 ID
RowID string `json:"rowID"` // 属性视图行 ID
AvID string `json:"avID"` // 属性视图 ID
SrcIDs []string `json:"srcIDs"` // 用于将块拖拽到属性视图中
IsDetached bool `json:"isDetached"` // 用于标识是否是脱离块,仅存在于属性视图中
Name string `json:"name"` // 属性视图列名
Typ string `json:"type"` // 属性视图列类型
Format string `json:"format"` // 属性视图列格式化
KeyID string `json:"keyID"` // 属性视列 ID
RowID string `json:"rowID"` // 属性视图行 ID

discard bool // 用于标识是否在事务合并中丢弃
}
Expand Down

0 comments on commit 863eb5e

Please sign in to comment.