mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-07 09:18:49 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
7a203eabdd
3 changed files with 29 additions and 37 deletions
|
|
@ -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"`
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -390,19 +394,9 @@ func setAttributeViewColumnCalc(operation *Operation) (err error) {
|
|||
}
|
||||
|
||||
func (tx *Transaction) doInsertAttrViewBlock(operation *Operation) (ret *TxErr) {
|
||||
if 1 > len(operation.SrcIDs) {
|
||||
// 不绑定到任何块的情况,比如直接在属性视图中添加一个块
|
||||
// New a row in the database no longer require to create a relevant doc https://github.com/siyuan-note/siyuan/issues/9294
|
||||
var avErr error
|
||||
if avErr = addAttributeViewBlock("", operation, nil, tx); nil != avErr {
|
||||
return &TxErr{code: TxErrWriteAttributeView, id: operation.AvID, msg: avErr.Error()}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
for _, id := range operation.SrcIDs {
|
||||
tree, err := tx.loadTree(id)
|
||||
if nil != err {
|
||||
if nil != err && !operation.IsDetached {
|
||||
logging.LogErrorf("load tree [%s] failed: %s", id, err)
|
||||
return &TxErr{code: TxErrCodeBlockNotFound, id: id, msg: err.Error()}
|
||||
}
|
||||
|
|
@ -417,7 +411,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
|
||||
|
|
@ -428,6 +422,8 @@ func addAttributeViewBlock(blockID string, operation *Operation, tree *parse.Tre
|
|||
// 不能将一个属性视图拖拽到另一个属性视图中
|
||||
return
|
||||
}
|
||||
} else {
|
||||
blockID = ast.NewNodeID()
|
||||
}
|
||||
|
||||
attrView, err := av.ParseAttributeView(operation.AvID)
|
||||
|
|
@ -448,10 +444,14 @@ 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)}}
|
||||
var content string
|
||||
if !operation.IsDetached {
|
||||
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: content}}
|
||||
blockValues.Values = append(blockValues.Values, value)
|
||||
|
||||
if nil != node {
|
||||
if !operation.IsDetached {
|
||||
attrs := parse.IAL2Map(node.KramdownIAL)
|
||||
|
||||
if "" == attrs[NodeAttrNameAvs] {
|
||||
|
|
@ -925,16 +925,6 @@ func UpdateAttributeViewCell(avID, keyID, rowID, cellID string, valueData interf
|
|||
break
|
||||
}
|
||||
|
||||
tree, err := loadTreeByBlockID(val.BlockID)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
node := treenode.GetNodeInTree(tree, val.BlockID)
|
||||
if nil == node {
|
||||
return
|
||||
}
|
||||
|
||||
data, err := gulu.JSON.MarshalJSON(valueData)
|
||||
if nil != err {
|
||||
return
|
||||
|
|
|
|||
|
|
@ -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 // 用于标识是否在事务合并中丢弃
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue