mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-20 02:50:58 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
7debd72d37
@ -102,6 +102,10 @@ func GetAttributeViewPrimaryKeyValues(avID, keyword string, page, pageSize int)
|
||||
end = len(keyValues.Values)
|
||||
}
|
||||
keyValues.Values = keyValues.Values[start:end]
|
||||
|
||||
sort.Slice(keyValues.Values, func(i, j int) bool {
|
||||
return keyValues.Values[i].Block.Updated > keyValues.Values[j].Block.Updated
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@ -2220,6 +2224,7 @@ func (tx *Transaction) doInsertAttrViewBlock(operation *Operation) (ret *TxErr)
|
||||
func AddAttributeViewBlock(tx *Transaction, srcs []map[string]interface{}, avID, blockID, previousBlockID string, ignoreFillFilter bool) (err error) {
|
||||
slices.Reverse(srcs) // https://github.com/siyuan-note/siyuan/issues/11286
|
||||
|
||||
now := time.Now().UnixMilli()
|
||||
for _, src := range srcs {
|
||||
srcID := src["id"].(string)
|
||||
isDetached := src["isDetached"].(bool)
|
||||
@ -2241,14 +2246,14 @@ func AddAttributeViewBlock(tx *Transaction, srcs []map[string]interface{}, avID,
|
||||
if nil != src["content"] {
|
||||
srcContent = src["content"].(string)
|
||||
}
|
||||
if avErr := addAttributeViewBlock(avID, blockID, previousBlockID, srcID, srcContent, isDetached, ignoreFillFilter, tree, tx); nil != avErr {
|
||||
if avErr := addAttributeViewBlock(now, avID, blockID, previousBlockID, srcID, srcContent, isDetached, ignoreFillFilter, tree, tx); nil != avErr {
|
||||
return avErr
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func addAttributeViewBlock(avID, blockID, previousBlockID, addingBlockID, addingBlockContent string, isDetached, ignoreFillFilter bool, tree *parse.Tree, tx *Transaction) (err error) {
|
||||
func addAttributeViewBlock(now int64, avID, blockID, previousBlockID, addingBlockID, addingBlockContent string, isDetached, ignoreFillFilter bool, tree *parse.Tree, tx *Transaction) (err error) {
|
||||
var node *ast.Node
|
||||
if !isDetached {
|
||||
node = treenode.GetNodeInTree(tree, addingBlockID)
|
||||
@ -2272,8 +2277,6 @@ func addAttributeViewBlock(avID, blockID, previousBlockID, addingBlockID, adding
|
||||
addingBlockContent = getNodeRefText(node)
|
||||
}
|
||||
|
||||
now := time.Now().UnixMilli()
|
||||
|
||||
// 检查是否重复添加相同的块
|
||||
blockValues := attrView.GetBlockKeyValues()
|
||||
for _, blockValue := range blockValues.Values {
|
||||
@ -3221,12 +3224,12 @@ func UpdateAttributeViewCell(tx *Transaction, avID, keyID, rowID, cellID string,
|
||||
// 将游离行绑定到新建的块上
|
||||
bindBlockAv(tx, avID, rowID)
|
||||
}
|
||||
} else { // 之前绑定了块
|
||||
} else { // 之前绑定了块
|
||||
if isUpdatingBlockKey { // 正在更新主键
|
||||
if val.IsDetached { // 现在是游离行
|
||||
// 将绑定的块从属性视图中移除
|
||||
unbindBlockAv(tx, avID, rowID)
|
||||
} else { // 现在绑定了块
|
||||
} else { // 现在绑定了块
|
||||
if oldBoundBlockID != val.BlockID { // 之前绑定的块和现在绑定的块不一样
|
||||
// 换绑块
|
||||
unbindBlockAv(tx, avID, oldBoundBlockID)
|
||||
@ -3252,7 +3255,14 @@ func UpdateAttributeViewCell(tx *Transaction, avID, keyID, rowID, cellID string,
|
||||
if nil != key && av.KeyTypeRelation == key.Type && nil != key.Relation && key.Relation.IsTwoWay {
|
||||
// 双向关联需要同时更新目标字段的值
|
||||
|
||||
if destAv, _ := av.ParseAttributeView(key.Relation.AvID); nil != destAv {
|
||||
var destAv *av.AttributeView
|
||||
if avID == key.Relation.AvID {
|
||||
destAv = attrView
|
||||
} else {
|
||||
destAv, _ = av.ParseAttributeView(key.Relation.AvID)
|
||||
}
|
||||
|
||||
if nil != destAv {
|
||||
// relationChangeMode
|
||||
// 0:关联列值不变(仅排序),不影响目标值
|
||||
// 1:关联列值增加,增加目标值
|
||||
@ -3304,7 +3314,9 @@ func UpdateAttributeViewCell(tx *Transaction, avID, keyID, rowID, cellID string,
|
||||
}
|
||||
}
|
||||
|
||||
av.SaveAttributeView(destAv)
|
||||
if destAv != attrView {
|
||||
av.SaveAttributeView(destAv)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user