mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
d1b2309e4a
1 changed files with 29 additions and 8 deletions
|
|
@ -2990,6 +2990,7 @@ func addAttributeViewBlock(now int64, avID, dbBlockID, groupID, previousItemID,
|
||||||
// The database date field supports filling the current time by default https://github.com/siyuan-note/siyuan/issues/10823
|
// The database date field supports filling the current time by default https://github.com/siyuan-note/siyuan/issues/10823
|
||||||
for _, keyValues := range attrView.KeyValues {
|
for _, keyValues := range attrView.KeyValues {
|
||||||
if av.KeyTypeDate == keyValues.Key.Type && nil != keyValues.Key.Date && keyValues.Key.Date.AutoFillNow {
|
if av.KeyTypeDate == keyValues.Key.Type && nil != keyValues.Key.Date && keyValues.Key.Date.AutoFillNow {
|
||||||
|
if nil == keyValues.GetValue(addingItemID) { // 避免覆盖已有值(可能前面已经通过过滤或者分组条件填充了值)
|
||||||
dateVal := &av.Value{
|
dateVal := &av.Value{
|
||||||
ID: ast.NewNodeID(), KeyID: keyValues.Key.ID, BlockID: addingItemID, Type: av.KeyTypeDate, IsDetached: isDetached, CreatedAt: now, UpdatedAt: now + 1000,
|
ID: ast.NewNodeID(), KeyID: keyValues.Key.ID, BlockID: addingItemID, Type: av.KeyTypeDate, IsDetached: isDetached, CreatedAt: now, UpdatedAt: now + 1000,
|
||||||
Date: &av.ValueDate{Content: now, IsNotEmpty: true},
|
Date: &av.ValueDate{Content: now, IsNotEmpty: true},
|
||||||
|
|
@ -2997,6 +2998,7 @@ func addAttributeViewBlock(now int64, avID, dbBlockID, groupID, previousItemID,
|
||||||
keyValues.Values = append(keyValues.Values, dateVal)
|
keyValues.Values = append(keyValues.Values, dateVal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !isDetached {
|
if !isDetached {
|
||||||
bindBlockAv0(tx, avID, node, tree)
|
bindBlockAv0(tx, avID, node, tree)
|
||||||
|
|
@ -3019,6 +3021,25 @@ func addAttributeViewBlock(now int64, avID, dbBlockID, groupID, previousItemID,
|
||||||
} else {
|
} else {
|
||||||
v.ItemIDs = append([]string{addingItemID}, v.ItemIDs...)
|
v.ItemIDs = append([]string{addingItemID}, v.ItemIDs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 在所有分组视图中添加,目的是为了在重新分组的过程中保住排序状态 https://github.com/siyuan-note/siyuan/issues/15560
|
||||||
|
for _, g := range v.Groups {
|
||||||
|
if "" != previousItemID {
|
||||||
|
changed := false
|
||||||
|
for i, id := range g.GroupItemIDs {
|
||||||
|
if id == previousItemID {
|
||||||
|
g.GroupItemIDs = append(g.GroupItemIDs[:i+1], append([]string{addingItemID}, g.GroupItemIDs[i+1:]...)...)
|
||||||
|
changed = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !changed {
|
||||||
|
g.GroupItemIDs = append(g.GroupItemIDs, addingItemID)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
g.GroupItemIDs = append([]string{addingItemID}, g.GroupItemIDs...)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
regenAttrViewGroups(attrView, "force")
|
regenAttrViewGroups(attrView, "force")
|
||||||
|
|
@ -3026,10 +3047,10 @@ func addAttributeViewBlock(now int64, avID, dbBlockID, groupID, previousItemID,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func fillDefaultValue(attrView *av.AttributeView, view, groupView *av.View, previousBlockID, addingBlockID string) {
|
func fillDefaultValue(attrView *av.AttributeView, view, groupView *av.View, previousItemID, addingItemID string) {
|
||||||
defaultValues := getAttrViewAddingBlockDefaultValues(attrView, view, groupView, previousBlockID, addingBlockID)
|
defaultValues := getAttrViewAddingBlockDefaultValues(attrView, view, groupView, previousItemID, addingItemID)
|
||||||
for keyID, newValue := range defaultValues {
|
for keyID, newValue := range defaultValues {
|
||||||
newValue.BlockID = addingBlockID
|
newValue.BlockID = addingItemID
|
||||||
keyValues, getErr := attrView.GetKeyValues(keyID)
|
keyValues, getErr := attrView.GetKeyValues(keyID)
|
||||||
if nil != getErr {
|
if nil != getErr {
|
||||||
continue
|
continue
|
||||||
|
|
@ -3052,7 +3073,7 @@ func fillDefaultValue(attrView *av.AttributeView, view, groupView *av.View, prev
|
||||||
updateTwoWayRelationDestAttrView(attrView, keyValues.Key, newValue, 1, []string{})
|
updateTwoWayRelationDestAttrView(attrView, keyValues.Key, newValue, 1, []string{})
|
||||||
}
|
}
|
||||||
|
|
||||||
existingVal := keyValues.GetValue(addingBlockID)
|
existingVal := keyValues.GetValue(addingItemID)
|
||||||
if nil == existingVal {
|
if nil == existingVal {
|
||||||
keyValues.Values = append(keyValues.Values, newValue)
|
keyValues.Values = append(keyValues.Values, newValue)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue