mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
🎨 Improve database field default filling https://github.com/siyuan-note/siyuan/issues/11966
This commit is contained in:
parent
dc765676aa
commit
2f01f3224d
1 changed files with 22 additions and 0 deletions
|
@ -79,6 +79,26 @@ func getAttrViewAddingBlockDefaultValues(attrView *av.AttributeView, view, group
|
|||
filterKeyIDs[f.Column] = true
|
||||
}
|
||||
|
||||
// 对库中存在模板字段的情况进行处理
|
||||
existTemplateField := false
|
||||
for _, keyValues := range attrView.KeyValues {
|
||||
if av.KeyTypeTemplate == keyValues.Key.Type {
|
||||
existTemplateField = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if existTemplateField {
|
||||
if nil != nearItem {
|
||||
// 存在模板字段且存在临近项时从临近项获取新值
|
||||
for _, keyValues := range attrView.KeyValues {
|
||||
newValue := getNewValueByNearItem(nearItem, keyValues.Key, addingBlockID)
|
||||
ret[keyValues.Key.ID] = newValue
|
||||
}
|
||||
} else { // 存在模板字段但不存在临近项时不生成任何新值
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
for _, filter := range view.Filters {
|
||||
keyValues, _ := attrView.GetKeyValues(filter.Column)
|
||||
if nil == keyValues {
|
||||
|
@ -87,8 +107,10 @@ func getAttrViewAddingBlockDefaultValues(attrView *av.AttributeView, view, group
|
|||
|
||||
var newValue *av.Value
|
||||
if nil != nearItem {
|
||||
// 存在临近项时优先通过临近项获取新值
|
||||
newValue = getNewValueByNearItem(nearItem, keyValues.Key, addingBlockID)
|
||||
} else {
|
||||
// 不存在临近项时通过过滤条件计算新值
|
||||
newValue = filter.GetAffectValue(keyValues.Key, addingBlockID)
|
||||
}
|
||||
if nil != newValue {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue