mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 08:30:12 +01:00
🎨 New a row in the database no longer require to create a relevant doc https://github.com/siyuan-note/siyuan/issues/9294
This commit is contained in:
parent
85aca5230e
commit
863eb5e570
3 changed files with 23 additions and 15 deletions
|
|
@ -94,10 +94,11 @@ type KeySelectOption struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Value struct {
|
type Value struct {
|
||||||
ID string `json:"id,omitempty"`
|
ID string `json:"id,omitempty"`
|
||||||
KeyID string `json:"keyID,omitempty"`
|
KeyID string `json:"keyID,omitempty"`
|
||||||
BlockID string `json:"blockID,omitempty"`
|
BlockID string `json:"blockID,omitempty"`
|
||||||
Type KeyType `json:"type,omitempty"`
|
Type KeyType `json:"type,omitempty"`
|
||||||
|
IsDetached bool `json:"isDetached,omitempty"`
|
||||||
|
|
||||||
Block *ValueBlock `json:"block,omitempty"`
|
Block *ValueBlock `json:"block,omitempty"`
|
||||||
Text *ValueText `json:"text,omitempty"`
|
Text *ValueText `json:"text,omitempty"`
|
||||||
|
|
|
||||||
|
|
@ -171,8 +171,12 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
|
||||||
}
|
}
|
||||||
|
|
||||||
// 过滤掉不存在的行
|
// 过滤掉不存在的行
|
||||||
notFound := []string{}
|
var notFound []string
|
||||||
for blockID, _ := range rows {
|
for blockID, v := range rows {
|
||||||
|
if v[0].IsDetached {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if treenode.GetBlockTree(blockID) == nil {
|
if treenode.GetBlockTree(blockID) == nil {
|
||||||
notFound = append(notFound, blockID)
|
notFound = append(notFound, blockID)
|
||||||
}
|
}
|
||||||
|
|
@ -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) {
|
func addAttributeViewBlock(blockID string, operation *Operation, tree *parse.Tree, tx *Transaction) (err error) {
|
||||||
var node *ast.Node
|
var node *ast.Node
|
||||||
if "" != blockID {
|
if !operation.IsDetached {
|
||||||
node = treenode.GetNodeInTree(tree, blockID)
|
node = treenode.GetNodeInTree(tree, blockID)
|
||||||
if nil == node {
|
if nil == node {
|
||||||
err = ErrBlockNotFound
|
err = ErrBlockNotFound
|
||||||
|
|
@ -428,6 +432,8 @@ func addAttributeViewBlock(blockID string, operation *Operation, tree *parse.Tre
|
||||||
// 不能将一个属性视图拖拽到另一个属性视图中
|
// 不能将一个属性视图拖拽到另一个属性视图中
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
blockID = ast.NewNodeID()
|
||||||
}
|
}
|
||||||
|
|
||||||
attrView, err := av.ParseAttributeView(operation.AvID)
|
attrView, err := av.ParseAttributeView(operation.AvID)
|
||||||
|
|
@ -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)
|
blockValues.Values = append(blockValues.Values, value)
|
||||||
|
|
||||||
if nil != node {
|
if nil != node {
|
||||||
|
|
|
||||||
|
|
@ -1099,13 +1099,14 @@ type Operation struct {
|
||||||
|
|
||||||
DeckID string `json:"deckID"` // 用于添加/删除闪卡
|
DeckID string `json:"deckID"` // 用于添加/删除闪卡
|
||||||
|
|
||||||
AvID string `json:"avID"` // 属性视图 ID
|
AvID string `json:"avID"` // 属性视图 ID
|
||||||
SrcIDs []string `json:"srcIDs"` // 用于将块拖拽到属性视图中
|
SrcIDs []string `json:"srcIDs"` // 用于将块拖拽到属性视图中
|
||||||
Name string `json:"name"` // 属性视图列名
|
IsDetached bool `json:"isDetached"` // 用于标识是否是脱离块,仅存在于属性视图中
|
||||||
Typ string `json:"type"` // 属性视图列类型
|
Name string `json:"name"` // 属性视图列名
|
||||||
Format string `json:"format"` // 属性视图列格式化
|
Typ string `json:"type"` // 属性视图列类型
|
||||||
KeyID string `json:"keyID"` // 属性视列 ID
|
Format string `json:"format"` // 属性视图列格式化
|
||||||
RowID string `json:"rowID"` // 属性视图行 ID
|
KeyID string `json:"keyID"` // 属性视列 ID
|
||||||
|
RowID string `json:"rowID"` // 属性视图行 ID
|
||||||
|
|
||||||
discard bool // 用于标识是否在事务合并中丢弃
|
discard bool // 用于标识是否在事务合并中丢弃
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue