mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Improve av https://github.com/siyuan-note/siyuan/issues/15560
This commit is contained in:
parent
bce519ae99
commit
469d9e24db
1 changed files with 23 additions and 4 deletions
|
|
@ -3021,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")
|
||||||
|
|
@ -3028,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
|
||||||
|
|
@ -3054,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