mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 The database rollup field supports using the template field https://github.com/siyuan-note/siyuan/issues/12384
This commit is contained in:
parent
bc16cd658f
commit
f2dda8b389
4 changed files with 22 additions and 10 deletions
|
|
@ -46,11 +46,20 @@ func RenderGroupView(attrView *av.AttributeView, view, groupView *av.View, query
|
|||
}
|
||||
|
||||
func RenderView(attrView *av.AttributeView, view *av.View, query string) (ret av.Viewable) {
|
||||
depth := 1
|
||||
return renderView(attrView, view, query, &depth)
|
||||
}
|
||||
|
||||
func renderView(attrView *av.AttributeView, view *av.View, query string, depth *int) (ret av.Viewable) {
|
||||
if 7 < *depth {
|
||||
return
|
||||
}
|
||||
|
||||
switch view.LayoutType {
|
||||
case av.LayoutTypeTable:
|
||||
ret = RenderAttributeViewTable(attrView, view, query)
|
||||
ret = RenderAttributeViewTable(attrView, view, query, depth)
|
||||
case av.LayoutTypeGallery:
|
||||
ret = RenderAttributeViewGallery(attrView, view, query)
|
||||
ret = RenderAttributeViewGallery(attrView, view, query, depth)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
@ -285,7 +294,7 @@ func fillAttributeViewBaseValue(baseValue *av.BaseValue, fieldID, itemID string,
|
|||
}
|
||||
}
|
||||
|
||||
func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection av.Collection, ials map[string]map[string]string, items map[string][]*av.KeyValues) {
|
||||
func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection av.Collection, ials map[string]map[string]string, items map[string][]*av.KeyValues, depth *int) {
|
||||
avCache := map[string]*av.AttributeView{}
|
||||
avCache[attrView.ID] = attrView
|
||||
for _, item := range collection.GetItems() {
|
||||
|
|
@ -336,12 +345,13 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
|
|||
|
||||
var viewable av.Viewable
|
||||
if av.KeyTypeTemplate == destKey.Type {
|
||||
viewable = RenderView(destAv, destAv.Views[0], "")
|
||||
// 渲染目标视图,这样才能汇总渲染后的模板字段值
|
||||
viewable = renderView(destAv, destAv.Views[0], "", depth)
|
||||
}
|
||||
|
||||
for _, blockID := range relVal.Relation.BlockIDs {
|
||||
destVal := destAv.GetValue(rollupKey.Rollup.KeyID, blockID)
|
||||
if nil == destVal && av.KeyTypeTemplate == destKey.Type && nil != viewable {
|
||||
if nil != viewable && nil == destVal && av.KeyTypeTemplate == destKey.Type {
|
||||
destVal = viewable.(av.Collection).GetValue(blockID, destKey.ID)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue